mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Update React Music Store to RC2
This commit is contained in:
@@ -2,9 +2,9 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using MusicStore.Models;
|
using MusicStore.Models;
|
||||||
using MusicStore.Infrastructure;
|
using MusicStore.Infrastructure;
|
||||||
@@ -97,7 +97,7 @@ namespace MusicStore.Apis
|
|||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
// Return the model errors
|
// Return the model errors
|
||||||
return HttpBadRequest(ModelState);
|
return BadRequest(ModelState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the changes to the DB
|
// Save the changes to the DB
|
||||||
@@ -119,7 +119,7 @@ namespace MusicStore.Apis
|
|||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
{
|
||||||
// Return the model errors
|
// Return the model errors
|
||||||
return HttpBadRequest(ModelState);
|
return BadRequest(ModelState);
|
||||||
}
|
}
|
||||||
|
|
||||||
var dbAlbum = await _storeContext.Albums.SingleOrDefaultAsync(a => a.AlbumId == albumId);
|
var dbAlbum = await _storeContext.Albums.SingleOrDefaultAsync(a => a.AlbumId == albumId);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using MusicStore.Models;
|
using MusicStore.Models;
|
||||||
|
|
||||||
namespace MusicStore.Apis
|
namespace MusicStore.Apis
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using MusicStore.Models;
|
using MusicStore.Models;
|
||||||
using MusicStore.Infrastructure;
|
using MusicStore.Infrastructure;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Microsoft.AspNet.Identity.EntityFramework;
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace MusicStore.Models
|
namespace MusicStore.Models
|
||||||
{
|
{
|
||||||
@@ -7,7 +7,7 @@ namespace MusicStore.Models
|
|||||||
|
|
||||||
public class MusicStoreContext : IdentityDbContext<ApplicationUser>
|
public class MusicStoreContext : IdentityDbContext<ApplicationUser>
|
||||||
{
|
{
|
||||||
public MusicStoreContext()
|
public MusicStoreContext(DbContextOptions options) : base(options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNet.Identity.EntityFramework;
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.OptionsModel;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace MusicStore.Models
|
namespace MusicStore.Models
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace MusicStore.Controllers
|
namespace MusicStore.Controllers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNet.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
|
||||||
namespace MusicStore.Infrastructure
|
namespace MusicStore.Infrastructure
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Microsoft.Data.Entity;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
|
||||||
|
|
||||||
namespace MusicStore.Infrastructure
|
namespace MusicStore.Infrastructure
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
using AutoMapper;
|
using System;
|
||||||
using Microsoft.AspNet.Authorization;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNet.Builder;
|
using System.IO;
|
||||||
using Microsoft.AspNet.Hosting;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNet.Identity.EntityFramework;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||||
using Microsoft.AspNet.SpaServices.Webpack;
|
using Microsoft.AspNet.SpaServices.Webpack;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.PlatformAbstractions;
|
||||||
|
using AutoMapper;
|
||||||
using MusicStore.Apis;
|
using MusicStore.Apis;
|
||||||
using MusicStore.Models;
|
using MusicStore.Models;
|
||||||
|
|
||||||
@@ -15,38 +20,16 @@ namespace MusicStore
|
|||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
public Startup(IHostingEnvironment env)
|
|
||||||
{
|
|
||||||
// Set up configuration sources.
|
|
||||||
var builder = new ConfigurationBuilder()
|
|
||||||
.AddJsonFile("appsettings.json")
|
|
||||||
.AddEnvironmentVariables();
|
|
||||||
Configuration = builder.Build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IConfigurationRoot Configuration { get; set; }
|
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to add services to the container.
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.Configure<SiteSettings>(settings =>
|
|
||||||
{
|
|
||||||
settings.DefaultAdminUsername = Configuration["DefaultAdminUsername"];
|
|
||||||
settings.DefaultAdminPassword = Configuration["DefaultAdminPassword"];
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add MVC services to the services container.
|
|
||||||
services.AddMvc();
|
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
|
// Add EF services to the service container
|
||||||
services.AddEntityFramework()
|
services.AddEntityFramework()
|
||||||
.AddSqlite()
|
.AddEntityFrameworkSqlite()
|
||||||
.AddDbContext<MusicStoreContext>(options => {
|
.AddDbContext<MusicStoreContext>(options => {
|
||||||
options.UseSqlite(Configuration["DbConnectionString"]);
|
options.UseSqlite("Data Source=music-db.sqlite");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add Identity services to the services container
|
// Add Identity services to the services container
|
||||||
@@ -75,21 +58,13 @@ namespace MusicStore
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env)
|
||||||
{
|
{
|
||||||
loggerFactory.AddConsole(LogLevel.Warning);
|
app.UseDeveloperExceptionPage();
|
||||||
|
|
||||||
// Initialize the sample data
|
// Initialize the sample data
|
||||||
SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
|
SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
|
||||||
|
|
||||||
if (env.IsDevelopment()) {
|
|
||||||
app.UseDeveloperExceptionPage();
|
|
||||||
} else {
|
|
||||||
app.UseExceptionHandler("/Home/Error");
|
|
||||||
}
|
|
||||||
|
|
||||||
app.UseIISPlatformHandler();
|
|
||||||
|
|
||||||
// In dev mode, the JS/TS/etc is compiled and served dynamically and supports hot replacement.
|
// In dev mode, the JS/TS/etc is compiled and served dynamically and supports hot replacement.
|
||||||
// In production, we assume you've used webpack to emit the prebuilt content to disk.
|
// In production, we assume you've used webpack to emit the prebuilt content to disk.
|
||||||
if (env.IsDevelopment()) {
|
if (env.IsDevelopment()) {
|
||||||
@@ -100,19 +75,38 @@ namespace MusicStore
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
loggerFactory.AddConsole();
|
||||||
|
|
||||||
app.UseMvc(routes => {
|
// Add MVC to the request pipeline.
|
||||||
|
app.UseMvc(routes =>
|
||||||
|
{
|
||||||
|
// Matches requests that correspond to an existent controller/action pair
|
||||||
routes.MapRoute(
|
routes.MapRoute(
|
||||||
name: "default",
|
name: "default",
|
||||||
template: "{controller=Home}/{action=Index}/{id?}");
|
template: "{controller=Home}/{action=Index}/{id?}");
|
||||||
|
|
||||||
routes.MapSpaFallbackRoute(
|
// Matches any other request that doesn't appear to have a filename extension (defined as 'having a dot in the last URI segment').
|
||||||
name: "spa-fallback",
|
// This means you'll correctly get 404s for /some/dir/non-existent-image.png instead of returning the SPA HTML.
|
||||||
defaults: new { controller = "Home", action = "Index" });
|
// However, it means requests like /customers/isaac.newton will *not* be mapped into the SPA, so if you need to accept
|
||||||
|
// URIs like that you'll need to match all URIs, e.g.:
|
||||||
|
// routes.MapRoute("spa-fallback", "{*anything}", new { controller = "Home", action = "Index" });
|
||||||
|
// (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" });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Entry point for the application.
|
public static void Main(string[] args)
|
||||||
public static void Main(string[] args) => Microsoft.AspNet.Hosting.WebApplication.Run<Startup>(args);
|
{
|
||||||
|
var host = new WebHostBuilder()
|
||||||
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
|
.UseDefaultHostingConfiguration(args)
|
||||||
|
.UseIISPlatformHandlerUrl()
|
||||||
|
.UseKestrel()
|
||||||
|
.UseStartup<Startup>()
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
host.Run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
@using MusicStore
|
@using MusicStore
|
||||||
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
|
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
|
||||||
@addTagHelper "*, Microsoft.AspNet.SpaServices"
|
@addTagHelper "*, Microsoft.AspNet.SpaServices"
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"DbConnectionString": "Data Source=music-db.sqlite",
|
|
||||||
"Logging": {
|
|
||||||
"IncludeScopes": false,
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Warning",
|
|
||||||
"System": "Information",
|
|
||||||
"Microsoft": "Information"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,6 +20,9 @@
|
|||||||
"webpack-hot-middleware": "^2.6.4"
|
"webpack-hot-middleware": "^2.6.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"aspnet-prerendering": "^1.0.0",
|
||||||
|
"aspnet-webpack": "^1.0.3",
|
||||||
|
"aspnet-webpack-react": "^1.0.1",
|
||||||
"bootstrap": "^3.3.6",
|
"bootstrap": "^3.3.6",
|
||||||
"domain-context": "^0.5.1",
|
"domain-context": "^0.5.1",
|
||||||
"domain-task": "^1.0.0",
|
"domain-task": "^1.0.0",
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"version": "1.0.0-*",
|
||||||
"compilationOptions": {
|
"compilationOptions": {
|
||||||
"emitEntryPoint": true
|
"emitEntryPoint": true,
|
||||||
|
"warningsAsErrors": true,
|
||||||
|
"preserveCompilationContext": true
|
||||||
},
|
},
|
||||||
"tooling": {
|
"tooling": {
|
||||||
"defaultNamespace": "MusicStore"
|
"defaultNamespace": "MusicStore"
|
||||||
},
|
},
|
||||||
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
|
"Microsoft.AspNetCore.Diagnostics": "1.0.0-*",
|
||||||
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
|
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
|
"Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
|
"Microsoft.AspNetCore.Mvc": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
|
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-*",
|
||||||
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
|
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
|
"Microsoft.AspNetCore.StaticFiles": "1.0.0-*",
|
||||||
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
|
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
|
||||||
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
|
"Microsoft.Extensions.Logging.Console": "1.0.0-*",
|
||||||
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
|
"Microsoft.NETCore.Platforms": "1.0.1-*",
|
||||||
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
|
"Microsoft.Extensions.Logging.Debug": "1.0.0-*",
|
||||||
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
|
"Microsoft.EntityFrameworkCore.SQLite": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-*",
|
|
||||||
"Microsoft.AspNet.ReactServices": "1.0.0-*",
|
"Microsoft.AspNet.ReactServices": "1.0.0-*",
|
||||||
"EntityFramework.SQLite": "7.0.0-rc1-*",
|
|
||||||
"AutoMapper": "4.1.1"
|
"AutoMapper": "4.1.1"
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -31,8 +31,15 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"dnx451": {},
|
"netstandardapp1.5": {
|
||||||
"dnxcore50": {}
|
"imports": [
|
||||||
|
"dnxcore50",
|
||||||
|
"portable-net451+win8"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"NETStandard.Library": "1.5.0-*"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
|||||||
Reference in New Issue
Block a user