public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider, IConfigurationReader configurationReader) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseDefaultFiles(); app.UseStaticFiles(); app.UseCors(c => { c.AllowAnyHeader(); c.AllowAnyMethod(); c.AllowAnyOrigin(); }); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "spa", template: "{operation:regex(^(?!api).*$)}", defaults: new { controller = "Spa", action = "Index" }); }); EllegiaContext.Seed(serviceProvider, configurationReader); }
public static void EnsureSeeded(this EllegiaContext context, IEnumerable <ISeeder> seeders) { foreach (var seeder in seeders) { seeder.Seed(context); } }
public UnitOfWork(EllegiaContext context) { _context = context; Colors = CreateCommonHandbookRepository <Color>(); PlasticBagTypes = CreateCommonHandbookRepository <PlasticBagType>(); FilmTypes = new FilmTypeRepository(context); FilmTypeOptions = new CommonHandbookRepository <FilmTypeOption>(context); Shifts = new CommonHandbookRepository <Shift>(context); Customers = new CustomerRepository(context); ContactTypes = new ContactTypeRepository(context); ProductTypes = new ProductTypeRepository(context); Orders = new OrderRepository(context); OrderRoutes = new Repository <OrderRoute>(context); Users = new UserRepository(context); Warehouses = new WarehouseRepository(context); WarehouseInOutHistory = new WarehouseInOutHistoryRepository(context); }
public static void EnsureSeeded(this EllegiaContext context, IServiceProvider serviceProvider, IConfigurationReader configurationReader) { var users = configurationReader.Read(); var userManager = serviceProvider.GetRequiredService <UserManager <EllegiaUser> >(); var roleManager = serviceProvider.GetRequiredService <RoleManager <EllegiaRole> >(); foreach (var user in users) { if (userManager.FindByNameAsync(user.Name).Result != null) { continue; } if (roleManager.FindByNameAsync(user.Role).Result == null) { var createRoleResult = roleManager.CreateAsync(new EllegiaRole { Name = user.Role }).Result; } var warehouse = context.Warehouses.First(); var ellegiaUser = new EllegiaUser(user.Name, user.Email, user.FullName, warehouse.Id); var createUserResult = userManager .CreateAsync(ellegiaUser, user.Password).Result; if (createUserResult.Succeeded) { var addUserToRoleResult = userManager.AddToRoleAsync(ellegiaUser, user.Role).Result; } } var ellegiaUsers = userManager.GetUsersInRoleAsync(Roles.SupervisorNormalizedName).Result; if (!context.Shifts.Any()) { context.Shifts.Add(new Shift("Смена #1", ellegiaUsers.First().Id)); context.SaveChanges(); } }
public WarehouseRepository(EllegiaContext context) : base(context) { }
public UserRepository(EllegiaContext context) : base(context) { }
public PlasticBagTypeRepository(EllegiaContext context) : base(context) { }
public Repository(EllegiaContext context) { Db = context; DbSet = Db.Set <TEntity>(); }
public CommonHandbookRepository(EllegiaContext context) : base(context) { _context = context; }
public WarehouseInOutHistoryRepository(EllegiaContext context) : base(context) { }
public ProductTypeRepository(EllegiaContext context) : base(context) { }
public CustomerRepository(EllegiaContext context) : base(context) { }
public FilmTypeRepository(EllegiaContext context) : base(context) { }
public ContactTypeRepository(EllegiaContext context) : base(context) { }