diff --git a/samples/angular/MusicStore/Apis/AlbumsApiController.cs b/samples/angular/MusicStore/Apis/AlbumsApiController.cs index fc28d66..4bd695d 100644 --- a/samples/angular/MusicStore/Apis/AlbumsApiController.cs +++ b/samples/angular/MusicStore/Apis/AlbumsApiController.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNet.Authorization; -using Microsoft.AspNet.Mvc; -using Microsoft.Data.Entity; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using AutoMapper; using MusicStore.Models; using MusicStore.Infrastructure; @@ -97,7 +97,7 @@ namespace MusicStore.Apis if (!ModelState.IsValid) { // Return the model errors - return HttpBadRequest(ModelState); + return BadRequest(ModelState); } // Save the changes to the DB @@ -119,7 +119,7 @@ namespace MusicStore.Apis if (!ModelState.IsValid) { // Return the model errors - return HttpBadRequest(ModelState); + return BadRequest(ModelState); } var dbAlbum = await _storeContext.Albums.SingleOrDefaultAsync(a => a.AlbumId == albumId); diff --git a/samples/angular/MusicStore/Apis/ArtistsApiController.cs b/samples/angular/MusicStore/Apis/ArtistsApiController.cs index b698b39..f3568ae 100644 --- a/samples/angular/MusicStore/Apis/ArtistsApiController.cs +++ b/samples/angular/MusicStore/Apis/ArtistsApiController.cs @@ -1,8 +1,8 @@ using System; using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNet.Mvc; -using Microsoft.Data.Entity; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using MusicStore.Models; namespace MusicStore.Apis diff --git a/samples/angular/MusicStore/Apis/GenresApiController.cs b/samples/angular/MusicStore/Apis/GenresApiController.cs index 830340d..338ca2f 100644 --- a/samples/angular/MusicStore/Apis/GenresApiController.cs +++ b/samples/angular/MusicStore/Apis/GenresApiController.cs @@ -1,7 +1,7 @@ using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNet.Mvc; -using Microsoft.Data.Entity; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using MusicStore.Models; using MusicStore.Infrastructure; diff --git a/samples/angular/MusicStore/Apis/Models/MusicStoreContext.cs b/samples/angular/MusicStore/Apis/Models/MusicStoreContext.cs index 300bea4..aee7aed 100644 --- a/samples/angular/MusicStore/Apis/Models/MusicStoreContext.cs +++ b/samples/angular/MusicStore/Apis/Models/MusicStoreContext.cs @@ -1,5 +1,5 @@ -using Microsoft.AspNet.Identity.EntityFramework; -using Microsoft.Data.Entity; +using Microsoft.AspNetCore.Identity.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; namespace MusicStore.Models { @@ -7,7 +7,7 @@ namespace MusicStore.Models public class MusicStoreContext : IdentityDbContext { - public MusicStoreContext() + public MusicStoreContext(DbContextOptions options) : base(options) { } diff --git a/samples/angular/MusicStore/Apis/Models/SampleData.cs b/samples/angular/MusicStore/Apis/Models/SampleData.cs index ca81996..b1d98a7 100644 --- a/samples/angular/MusicStore/Apis/Models/SampleData.cs +++ b/samples/angular/MusicStore/Apis/Models/SampleData.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; using System.Threading.Tasks; -using Microsoft.AspNet.Identity; -using Microsoft.AspNet.Identity.EntityFramework; -using Microsoft.Data.Entity; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.OptionsModel; +using Microsoft.Extensions.Options; namespace MusicStore.Models { diff --git a/samples/angular/MusicStore/Apis/Models/ShoppingCart.cs b/samples/angular/MusicStore/Apis/Models/ShoppingCart.cs index 3e42600..1d2465a 100644 --- a/samples/angular/MusicStore/Apis/Models/ShoppingCart.cs +++ b/samples/angular/MusicStore/Apis/Models/ShoppingCart.cs @@ -1,5 +1,5 @@ -using Microsoft.AspNet.Http; -using Microsoft.Data.Entity; +using Microsoft.AspNetCore.Http; +using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; diff --git a/samples/angular/MusicStore/Controllers/HomeController.cs b/samples/angular/MusicStore/Controllers/HomeController.cs index 3e054d8..07e9702 100755 --- a/samples/angular/MusicStore/Controllers/HomeController.cs +++ b/samples/angular/MusicStore/Controllers/HomeController.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNet.Mvc; +using Microsoft.AspNetCore.Mvc; namespace MusicStore.Controllers { diff --git a/samples/angular/MusicStore/Infrastructure/NoCacheAttribute.cs b/samples/angular/MusicStore/Infrastructure/NoCacheAttribute.cs index d4b73c6..856023a 100644 --- a/samples/angular/MusicStore/Infrastructure/NoCacheAttribute.cs +++ b/samples/angular/MusicStore/Infrastructure/NoCacheAttribute.cs @@ -1,6 +1,6 @@ -using Microsoft.AspNet.Mvc; +using Microsoft.AspNetCore.Mvc; using System; -using Microsoft.AspNet.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.Filters; namespace MusicStore.Infrastructure { diff --git a/samples/angular/MusicStore/Infrastructure/PagedList.cs b/samples/angular/MusicStore/Infrastructure/PagedList.cs index b5593a6..b2cb2c5 100644 --- a/samples/angular/MusicStore/Infrastructure/PagedList.cs +++ b/samples/angular/MusicStore/Infrastructure/PagedList.cs @@ -1,4 +1,4 @@ -using Microsoft.Data.Entity; +using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; diff --git a/samples/angular/MusicStore/Infrastructure/SortExpression.cs b/samples/angular/MusicStore/Infrastructure/SortExpression.cs index 279efb7..88ba312 100644 --- a/samples/angular/MusicStore/Infrastructure/SortExpression.cs +++ b/samples/angular/MusicStore/Infrastructure/SortExpression.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; -using Microsoft.AspNet.Mvc.ViewFeatures; +using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal; namespace MusicStore.Infrastructure { diff --git a/samples/angular/MusicStore/SiteSettings.cs b/samples/angular/MusicStore/SiteSettings.cs deleted file mode 100644 index 50a86c2..0000000 --- a/samples/angular/MusicStore/SiteSettings.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace MusicStore -{ - public class SiteSettings - { - public string DefaultAdminUsername { get; set; } - public string DefaultAdminPassword { get; set; } - } -} diff --git a/samples/angular/MusicStore/Startup.cs b/samples/angular/MusicStore/Startup.cs index 67008f7..0072ebe 100755 --- a/samples/angular/MusicStore/Startup.cs +++ b/samples/angular/MusicStore/Startup.cs @@ -1,10 +1,12 @@ using System; using System.Collections.Generic; -using Microsoft.AspNet.Authorization; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; -using Microsoft.AspNet.Identity.EntityFramework; -using Microsoft.Data.Entity; +using System.IO; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Identity.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -17,39 +19,16 @@ namespace MusicStore { public class Startup { - public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv) - { - // Setup configuration sources. - var builder = new ConfigurationBuilder() - .SetBasePath(appEnv.ApplicationBasePath) - .AddJsonFile("appsettings.json") - .AddEnvironmentVariables(); - Configuration = builder.Build(); - } - - public IConfigurationRoot Configuration { get; set; } - - // This method gets called by the runtime. + // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.Configure(settings => - { - settings.DefaultAdminUsername = Configuration["DefaultAdminUsername"]; - settings.DefaultAdminPassword = Configuration["DefaultAdminPassword"]; - }); - - // Add MVC services to the services container. services.AddMvc(); - - // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers. - // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json. - // services.AddWebApiConventions(); - + // Add EF services to the service container services.AddEntityFramework() - .AddSqlite() + .AddEntityFrameworkSqlite() .AddDbContext(options => { - options.UseSqlite(Configuration["DbConnectionString"]); + options.UseSqlite("Data Source=music-db.sqlite"); }); // Add Identity services to the services container @@ -77,41 +56,24 @@ namespace MusicStore Mapper.CreateMap(); } - // Configure is called after ConfigureServices is called. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env) { + app.UseDeveloperExceptionPage(); + // Initialize the sample data - SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait(); + //SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait(); - loggerFactory.MinimumLevel = LogLevel.Warning; - loggerFactory.AddConsole(); - loggerFactory.AddDebug(); - - // Configure the HTTP request pipeline. - - // Add the platform handler to the request pipeline. - app.UseIISPlatformHandler(); - - // Add the following to the request pipeline only in development environment. - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - // Add Error handling middleware which catches all application specific errors and - // send the request to the following path or controller action. - app.UseExceptionHandler("/Home/Error"); - } - - // Add static files to the request pipeline. app.UseStaticFiles(); + loggerFactory.AddConsole(); // Add MVC to the request pipeline. app.UseMvc(routes => { // Matches requests that correspond to an existent controller/action pair - routes.MapRoute("default", "{controller}/{action}/{id:int?}"); + routes.MapRoute( + name: "default", + template: "{controller=Home}/{action=Index}/{id?}"); // Matches any other request that doesn't appear to have a filename extension (defined as 'having a dot in the last URI segment'). // This means you'll correctly get 404s for /some/dir/non-existent-image.png instead of returning the SPA HTML. @@ -121,10 +83,20 @@ namespace MusicStore // (which of course will match /customers/isaac.png too, so in that case it would serve the PNG image at that URL if one is on disk, // or the SPA HTML if not). routes.MapSpaFallbackRoute("spa-fallback", new { controller = "Home", action = "Index" }); - - // Uncomment the following line to add a route for porting Web API 2 controllers. - // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}"); }); } + + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseDefaultHostingConfiguration(args) + .UseIISPlatformHandlerUrl() + .UseKestrel() + .UseStartup() + .Build(); + + host.Run(); + } } } diff --git a/samples/angular/MusicStore/Views/_ViewImports.cshtml b/samples/angular/MusicStore/Views/_ViewImports.cshtml index 17fd71c..a657e0d 100755 --- a/samples/angular/MusicStore/Views/_ViewImports.cshtml +++ b/samples/angular/MusicStore/Views/_ViewImports.cshtml @@ -1,4 +1,4 @@ @using MusicStore @using Microsoft.AspNet.AngularServices -@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers" -@addTagHelper "*, Microsoft.AspNet.SpaServices" +@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers" +@addTagHelper "*, Microsoft.AspNet.AngularServices" diff --git a/samples/angular/MusicStore/appsettings.json b/samples/angular/MusicStore/appsettings.json deleted file mode 100755 index c8d7a43..0000000 --- a/samples/angular/MusicStore/appsettings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "DbConnectionString": "Data Source=music-db.sqlite" -} diff --git a/samples/angular/MusicStore/project.json b/samples/angular/MusicStore/project.json index a9aad1c..b74d48a 100755 --- a/samples/angular/MusicStore/project.json +++ b/samples/angular/MusicStore/project.json @@ -1,21 +1,27 @@ { - "webroot": "wwwroot", "version": "1.0.0-*", + "compilationOptions": { + "emitEntryPoint": true, + "warningsAsErrors": true, + "preserveCompilationContext": true + }, "tooling": { "defaultNamespace": "MusicStore" }, + "dependencies": { - "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-*", - "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-*", - "Microsoft.AspNet.Mvc": "6.0.0-rc1-*", - "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-*", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-*", - "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-*", - "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-*", - "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-*", - "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-*", - "EntityFramework.SQLite": "7.0.0-rc1-*", - "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-*", + "Microsoft.AspNetCore.Diagnostics": "1.0.0-*", + "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-*", + "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*", + "Microsoft.AspNetCore.Mvc": "1.0.0-*", + "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-*", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*", + "Microsoft.AspNetCore.StaticFiles": "1.0.0-*", + "Microsoft.Extensions.Configuration.Json": "1.0.0-*", + "Microsoft.Extensions.Logging.Console": "1.0.0-*", + "Microsoft.NETCore.Platforms": "1.0.1-*", + "Microsoft.Extensions.Logging.Debug": "1.0.0-*", + "Microsoft.EntityFrameworkCore.SQLite": "1.0.0-*", "Microsoft.AspNet.AngularServices": "1.0.0-*", "AutoMapper": "4.1.1" }, @@ -23,8 +29,15 @@ "web": "Microsoft.AspNet.Server.Kestrel" }, "frameworks": { - "dnx451": {}, - "dnxcore50": {} + "netstandardapp1.5": { + "imports": [ + "dnxcore50", + "portable-net451+win8" + ], + "dependencies": { + "NETStandard.Library": "1.5.0-*" + } + } }, "exclude": [ "wwwroot",