using AutoMapper; using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Identity.EntityFramework; using Microsoft.Data.Entity; using Microsoft.Framework.Configuration; using Microsoft.Framework.DependencyInjection; using Microsoft.Dnx.Runtime; using MusicStore.Apis; using MusicStore.Models; namespace MusicStore.Spa { public class Startup { public Startup(IApplicationEnvironment env) { var builder = new ConfigurationBuilder(env.ApplicationBasePath) .AddJsonFile("Config.json") .AddEnvironmentVariables(); Configuration = builder.Build(); } public Microsoft.Framework.Configuration.IConfiguration Configuration { get; set; } public void ConfigureServices(IServiceCollection services) { services.Configure(settings => { settings.DefaultAdminUsername = Configuration["DefaultAdminUsername"]; settings.DefaultAdminPassword = Configuration["DefaultAdminPassword"]; }); // Add MVC services to the service container services.AddMvc(); // Add EF services to the service container services.AddEntityFramework() .AddSqlServer() .AddDbContext(options => { options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]); }); // Add Identity services to the services container services.AddIdentity() .AddEntityFrameworkStores() .AddDefaultTokenProviders(); // Add application services to the service container //services.AddTransient(); // Configure Auth services.Configure(options => { options.AddPolicy("app-ManageStore", new AuthorizationPolicyBuilder().RequireClaim("app-ManageStore", "Allowed").Build()); }); Mapper.CreateMap(); Mapper.CreateMap(); Mapper.CreateMap(); Mapper.CreateMap(); Mapper.CreateMap(); Mapper.CreateMap(); Mapper.CreateMap(); Mapper.CreateMap(); } public void Configure(IApplicationBuilder app) { // Initialize the sample data SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait(); // Configure the HTTP request pipeline // Add cookie auth app.UseIdentity(); // Add static files app.UseStaticFiles(); // Add MVC app.UseMvc(); } } }