From 293451490912204afa435385bb6985a68ba77b8b Mon Sep 17 00:00:00 2001 From: DamianEdwards Date: Mon, 16 Jun 2014 15:00:57 -0700 Subject: [PATCH] Fix MusicStore.Spa: - Support self-host via commands - Comment out calls to EF APIs that throw NIE --- .../Apis/AlbumsApiController.cs | 12 ++++---- .../Apis/GenresApiController.cs | 6 ++-- src/MusicStore.Spa/MusicStore.Spa.kproj | 1 + src/MusicStore.Spa/Project.json | 29 ++++++++++--------- src/MusicStore.Spa/Startup.cs | 1 - 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/MusicStore.Spa/Apis/AlbumsApiController.cs b/src/MusicStore.Spa/Apis/AlbumsApiController.cs index 083d81ae27..3193370fd4 100644 --- a/src/MusicStore.Spa/Apis/AlbumsApiController.cs +++ b/src/MusicStore.Spa/Apis/AlbumsApiController.cs @@ -20,8 +20,8 @@ namespace MusicStore.Apis public async Task Paged(int page = 1, int pageSize = 50, string sortBy = null) { var pagedAlbums = await _storeContext.Albums - .Include(a => a.Genre) - .Include(a => a.Artist) + //.Include(a => a.Genre) + //.Include(a => a.Artist) .SortBy(sortBy, a => a.Title) .ToPagedListAsync(page, pageSize); @@ -37,8 +37,8 @@ namespace MusicStore.Apis return new SmartJsonResult { Data = await _storeContext.Albums - .Include(a => a.Genre) - .Include(a => a.Artist) + //.Include(a => a.Genre) + //.Include(a => a.Artist) .OrderBy(a => a.Title) .ToListAsync() }; @@ -67,8 +67,8 @@ namespace MusicStore.Apis // TODO: Make async when EF supports SingleOrDefaultAsync var album = _storeContext.Albums - .Include(a => a.Artist) - .Include(a => a.Genre) + //.Include(a => a.Artist) + //.Include(a => a.Genre) .SingleOrDefault(a => a.AlbumId == albumId); // TODO: Add null checking and return 404 in that case diff --git a/src/MusicStore.Spa/Apis/GenresApiController.cs b/src/MusicStore.Spa/Apis/GenresApiController.cs index e2e155e6b1..5ddd30d85d 100644 --- a/src/MusicStore.Spa/Apis/GenresApiController.cs +++ b/src/MusicStore.Spa/Apis/GenresApiController.cs @@ -45,7 +45,7 @@ namespace MusicStore.Apis return new SmartJsonResult { Data = await _storeContext.Genres - .Include(g => g.Albums) + //.Include(g => g.Albums) .OrderBy(g => g.Name) .ToListAsync() }; @@ -56,8 +56,8 @@ namespace MusicStore.Apis { var albums = await _storeContext.Albums .Where(a => a.GenreId == genreId) - .Include(a => a.Genre) - .Include(a => a.Artist) + //.Include(a => a.Genre) + //.Include(a => a.Artist) //.OrderBy(a => a.Genre.Name) .ToListAsync(); diff --git a/src/MusicStore.Spa/MusicStore.Spa.kproj b/src/MusicStore.Spa/MusicStore.Spa.kproj index b1d7e79896..eb0734b933 100644 --- a/src/MusicStore.Spa/MusicStore.Spa.kproj +++ b/src/MusicStore.Spa/MusicStore.Spa.kproj @@ -799,6 +799,7 @@ + diff --git a/src/MusicStore.Spa/Project.json b/src/MusicStore.Spa/Project.json index 700afa8fe4..ecce486b9a 100644 --- a/src/MusicStore.Spa/Project.json +++ b/src/MusicStore.Spa/Project.json @@ -1,9 +1,14 @@ { - "compilationOptions" : { "define" : ["DEBUG"] }, + "authors": [ + "Microsoft" + ], + "description": "Music store application on K as a SPA", + "compilationOptions": { "define": [ "DEBUG" ] }, "dependencies": { - "Helios" : "0.1-alpha-*", - "Microsoft.AspNet.Mvc" : "0.1-alpha-*", - "Microsoft.AspNet.StaticFiles" : "0.1-alpha-*", + "Helios": "0.1-alpha-*", + "Microsoft.AspNet.Mvc": "0.1-alpha-*", + "Microsoft.AspNet.Server.WebListener": "0.1-alpha-*", + "Microsoft.AspNet.StaticFiles": "0.1-alpha-*", "Microsoft.Data.Entity.Relational": "0.1-alpha-*", "Microsoft.Data.Entity.InMemory": "0.1-alpha-*", "Microsoft.Data.Entity.SqlServer": "0.1-alpha-*", @@ -13,14 +18,12 @@ "Microsoft.Framework.ConfigurationModel": "0.1-alpha-*", "Microsoft.Framework.ConfigurationModel.Json": "0.1-alpha-build-*" }, - "configurations" : { - "net451" : { - "dependencies": { - "System.Runtime" : "", - "System.Data": "", - "System.ComponentModel.DataAnnotations": "" - } - }, - "k10" : { } + "commands": { + "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5002", + "run": "run server.urls=http://localhost:5003" + }, + "configurations": { + "net451": { }, + "k10": { } } } diff --git a/src/MusicStore.Spa/Startup.cs b/src/MusicStore.Spa/Startup.cs index ed6d073e72..61f1d6dbbf 100644 --- a/src/MusicStore.Spa/Startup.cs +++ b/src/MusicStore.Spa/Startup.cs @@ -3,7 +3,6 @@ using Microsoft.AspNet.Builder; using Microsoft.AspNet.FileSystems; using Microsoft.AspNet.Http; using Microsoft.AspNet.Identity; -using Microsoft.AspNet.Identity.Security; using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Routing; using Microsoft.AspNet.Security.Cookies;