Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
708 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2013 | ||
VisualStudioVersion = 12.0.21005.1 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UWPDevMVAService", "UWPDevMVAService\UWPDevMVAService.csproj", "{209FA716-A7AD-4095-BD70-C8710FC66FA7}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{209FA716-A7AD-4095-BD70-C8710FC66FA7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{209FA716-A7AD-4095-BD70-C8710FC66FA7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
51 changes: 51 additions & 0 deletions
51
AzureMobileApps/UWPDevMVA_Runtime/UWPDevMVAService/App_Start/WebApiConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data.Entity; | ||
using System.Web.Http; | ||
using Microsoft.Azure.Mobile.Server; | ||
using Microsoft.Azure.Mobile.Server.AppService.Config; | ||
using UWPDevMVAService.DataObjects; | ||
using UWPDevMVAService.Models; | ||
|
||
namespace UWPDevMVAService | ||
{ | ||
public static class WebApiConfig | ||
{ | ||
public static void Register() | ||
{ | ||
AppServiceExtensionConfig.Initialize(); | ||
|
||
// Use this class to set configuration options for your mobile service | ||
ConfigOptions options = new ConfigOptions(); | ||
|
||
// Use this class to set WebAPI configuration options | ||
HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options)); | ||
|
||
// To display errors in the browser during development, uncomment the following | ||
// line. Comment it out again when you deploy your service for production use. | ||
// config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; | ||
|
||
Database.SetInitializer(new UWPDevMVAInitializer()); | ||
} | ||
} | ||
|
||
public class UWPDevMVAInitializer : ClearDatabaseSchemaIfModelChanges<UWPDevMVAContext> | ||
{ | ||
protected override void Seed(UWPDevMVAContext context) | ||
{ | ||
List<TodoItem> todoItems = new List<TodoItem> | ||
{ | ||
new TodoItem { Id = Guid.NewGuid().ToString(), Text = "First item", Complete = false }, | ||
new TodoItem { Id = Guid.NewGuid().ToString(), Text = "Second item", Complete = false }, | ||
}; | ||
|
||
foreach (TodoItem todoItem in todoItems) | ||
{ | ||
context.Set<TodoItem>().Add(todoItem); | ||
} | ||
|
||
base.Seed(context); | ||
} | ||
} | ||
} | ||
|
52 changes: 52 additions & 0 deletions
52
AzureMobileApps/UWPDevMVA_Runtime/UWPDevMVAService/Controllers/TodoItemController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Web.Http; | ||
using System.Web.Http.Controllers; | ||
using System.Web.Http.OData; | ||
using Microsoft.Azure.Mobile.Server; | ||
using UWPDevMVAService.DataObjects; | ||
using UWPDevMVAService.Models; | ||
|
||
namespace UWPDevMVAService.Controllers | ||
{ | ||
public class TodoItemController : TableController<TodoItem> | ||
{ | ||
protected override void Initialize(HttpControllerContext controllerContext) | ||
{ | ||
base.Initialize(controllerContext); | ||
UWPDevMVAContext context = new UWPDevMVAContext(); | ||
DomainManager = new EntityDomainManager<TodoItem>(context, Request, Services); | ||
} | ||
|
||
// GET tables/TodoItem | ||
public IQueryable<TodoItem> GetAllTodoItems() | ||
{ | ||
return Query(); | ||
} | ||
|
||
// GET tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959 | ||
public SingleResult<TodoItem> GetTodoItem(string id) | ||
{ | ||
return Lookup(id); | ||
} | ||
|
||
// PATCH tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959 | ||
public Task<TodoItem> PatchTodoItem(string id, Delta<TodoItem> patch) | ||
{ | ||
return UpdateAsync(id, patch); | ||
} | ||
|
||
// POST tables/TodoItem | ||
public async Task<IHttpActionResult> PostTodoItem(TodoItem item) | ||
{ | ||
TodoItem current = await InsertAsync(item); | ||
return CreatedAtRoute("Tables", new { id = current.Id }, current); | ||
} | ||
|
||
// DELETE tables/TodoItem/48D68C86-6EA6-4C25-AA33-223FC9A27959 | ||
public Task DeleteTodoItem(string id) | ||
{ | ||
return DeleteAsync(id); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
AzureMobileApps/UWPDevMVA_Runtime/UWPDevMVAService/DataObjects/TodoItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Microsoft.Azure.Mobile.Server; | ||
|
||
namespace UWPDevMVAService.DataObjects | ||
{ | ||
public class TodoItem : EntityData | ||
{ | ||
public string Text { get; set; } | ||
|
||
public bool Complete { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%@ Application Codebehind="Global.asax.cs" Inherits="UWPDevMVAService.WebApiApplication" Language="C#" %> |
13 changes: 13 additions & 0 deletions
13
AzureMobileApps/UWPDevMVA_Runtime/UWPDevMVAService/Global.asax.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Web.Http; | ||
using System.Web.Routing; | ||
|
||
namespace UWPDevMVAService | ||
{ | ||
public class WebApiApplication : System.Web.HttpApplication | ||
{ | ||
protected void Application_Start() | ||
{ | ||
WebApiConfig.Register(); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
AzureMobileApps/UWPDevMVA_Runtime/UWPDevMVAService/Models/UWPDevMVAContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Data.Entity; | ||
using System.Data.Entity.ModelConfiguration.Conventions; | ||
using System.Linq; | ||
using Microsoft.Azure.Mobile.Server; | ||
using Microsoft.Azure.Mobile.Server.Tables; | ||
using UWPDevMVAService.DataObjects; | ||
|
||
namespace UWPDevMVAService.Models | ||
{ | ||
public class UWPDevMVAContext : DbContext | ||
{ | ||
// You can add custom code to this file. Changes will not be overwritten. | ||
// | ||
// If you want Entity Framework to alter your database | ||
// automatically whenever you change your model schema, please use data migrations. | ||
// For more information refer to the documentation: | ||
// http://msdn.microsoft.com/en-us/data/jj591621.aspx | ||
// | ||
// To enable Entity Framework migrations in the cloud, please ensure that the | ||
// service name, set by the 'MS_MobileServiceName' AppSettings in the local | ||
// Web.config, is the same as the service name when hosted in Azure. | ||
private const string connectionStringName = "Name=MS_TableConnectionString"; | ||
|
||
public UWPDevMVAContext() : base(connectionStringName) | ||
{ | ||
} | ||
|
||
public DbSet<TodoItem> TodoItems { get; set; } | ||
|
||
protected override void OnModelCreating(DbModelBuilder modelBuilder) | ||
{ | ||
string schema = ServiceSettingsDictionary.GetSchemaName(); | ||
if (!string.IsNullOrEmpty(schema)) | ||
{ | ||
modelBuilder.HasDefaultSchema(schema); | ||
} | ||
|
||
modelBuilder.Conventions.Add( | ||
new AttributeToColumnAnnotationConvention<TableColumnAttribute, string>( | ||
"ServiceTableColumn", (property, attributes) => attributes.Single().ColumnType.ToString())); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.