示例#1
0
        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);
     }
 }
示例#3
0
 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();
            }
        }
示例#5
0
 public WarehouseRepository(EllegiaContext context) : base(context)
 {
 }
示例#6
0
 public UserRepository(EllegiaContext context) : base(context)
 {
 }
 public PlasticBagTypeRepository(EllegiaContext context) : base(context)
 {
 }
示例#8
0
 public Repository(EllegiaContext context)
 {
     Db    = context;
     DbSet = Db.Set <TEntity>();
 }
示例#9
0
 public CommonHandbookRepository(EllegiaContext context) : base(context)
 {
     _context = context;
 }
示例#10
0
 public WarehouseInOutHistoryRepository(EllegiaContext context)
     : base(context)
 {
 }
示例#11
0
 public ProductTypeRepository(EllegiaContext context) : base(context)
 {
 }
示例#12
0
 public CustomerRepository(EllegiaContext context) : base(context)
 {
 }
示例#13
0
 public FilmTypeRepository(EllegiaContext context) : base(context)
 {
 }
示例#14
0
 public ContactTypeRepository(EllegiaContext context) : base(context)
 {
 }