Revision: 67490
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 28, 2014 02:36 by giventocode
Initial Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Microsoft.WindowsAzure.Mobile.Service;
using Microsoft.WindowsAzure.Storage.Table;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure;
using giventocode.m.DataObjects;
namespace giventocode.m.Controllers
{
public class BlogRecommendationsController : ApiController
{
public ApiServices Services { get; set; }
// GET api/BlogRecommendations
[AuthorizeLevel(Microsoft.WindowsAzure.Mobile.Service.Security.AuthorizationLevel.Application)]
public IEnumerable<BlogItem> Get(string title)
{
var resultsTable = GetCloudTable(CloudConfigurationManager.GetSetting("RecommendationsDataTable"));
Services.Log.Info(CloudConfigurationManager.GetSetting("RecommendationsDataTable"));
Services.Log.Info(title);
var cluster =resultsTable.CreateQuery<BlogEntryResult>()
.Where<BlogEntryResult>(b => b.Title == title)
.Select<BlogEntryResult, string>
(r => r.Assignments)
.FirstOrDefault<string>();
if (cluster != null)
{
return resultsTable.CreateQuery<BlogEntryResult>()
.Where<BlogEntryResult>(b => b.Assignments == cluster && b.Title != title)
.Select<BlogEntryResult, BlogItem>
(r => new BlogItem() { Title = r.Title, Link = r.Link });
}
return null;
}
private CloudTable GetCloudTable(string name)
{
var cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
CloudStorageAccount.TryParse(CloudConfigurationManager.GetSetting("StorageAcct"), out cloudStorageAccount);
var tClient = cloudStorageAccount.CreateCloudTableClient();
var tref = tClient.GetTableReference(name);
tref.CreateIfNotExists();
return tref;
}
}
}
Initial URL
http://giventocode.com/build-a-recommendations-system-for-your-blog-or-web-site-using-azure-machine-learning-and-azure-mobile-services#
Initial Description
Recommendations API implementation using Azure Mobile Services
Initial Title
BlogRecommendationsController
Initial Tags
Initial Language
C#