// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, CRSDbContext context, RoleManager <ApplicationRole> roleManager, UserManager <ApplicationUser> userManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseCors(bulider => bulider.WithOrigins(Configuration["JWTSettings:Client_URL"].ToString()) .AllowAnyMethod() .AllowAnyHeader()); app.UseHttpsRedirection(); UserInitializer.Initialize(context, userManager, roleManager).Wait(); TypeOfCustomerInitializer.Initialize(context).Wait(); CarModelInitializer.Initialize(context).Wait(); app.UseAuthentication(); app.UseMiddleware(typeof(ErrorHandlingMiddleware)); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); }
public OrderService(CRSDbContext repositoryContext, IMapper mapper, ICustomerService customerService, IVehicleService vehicleService) : base(repositoryContext) { _customerService = customerService; _vehicleService = vehicleService; _mapper = mapper; }
public static async Task Initialize(CRSDbContext context) { var individualClient = "Osoba prywatna"; var institutionalClient = "Przedsiębiorca"; if (context.TypeofCustomer.Any()) { return; } var typesOfCustomer = new TypeOfCustomer[] { new TypeOfCustomer { TypeName = individualClient }, new TypeOfCustomer { TypeName = institutionalClient } }; foreach (var item in typesOfCustomer) { await context.AddAsync(item); } await context.SaveChangesAsync(); }
public UserService(CRSDbContext repositoryContext, IMapper mapper, UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, IOptions <JWTSettings> jwtSettings, IEmailSender emailSender) : base(repositoryContext) { _mapper = mapper; _jwtSettings = jwtSettings.Value; _userManager = userManager; _signInManager = signInManager; _emailSender = emailSender; }
public static void SeedHostDb(CRSDbContext context) { context.SuppressAutoSetTenantId = true; // Host seed new InitialHostDbBuilder(context).Create(); // Default tenant seed (in host database). new DefaultTenantBuilder(context).Create(); new TenantRoleAndUserBuilder(context, 1).Create(); }
public static async Task Initialize(CRSDbContext context, UserManager <ApplicationUser> userManager, RoleManager <ApplicationRole> roleManager) { context.Database.EnsureCreated(); string role1 = "Admin"; string desc1 = "Rola administratora"; string role2 = "Pracownik"; string desc2 = "Rola pracownika"; string password = "******"; if (await roleManager.FindByNameAsync(role1) == null) { var admin = new ApplicationRole() { Name = role1, NormalizedName = desc1 }; await roleManager.CreateAsync(admin); } if (await roleManager.FindByNameAsync(role2) == null) { var employee = new ApplicationRole() { Name = role2, NormalizedName = desc2 }; await roleManager.CreateAsync(employee); } if (await userManager.FindByNameAsync("Admin") == null) { var user = new ApplicationUser { UserName = "******", Email = "*****@*****.**", }; var result = await userManager.CreateAsync(user); if (result.Succeeded) { await userManager.AddPasswordAsync(user, password); await userManager.AddToRoleAsync(user, role1); } } }
public VehicleModelService(CRSDbContext repositoryContext, IMapper mapper) : base(repositoryContext) { _mapper = mapper; }
public HostRoleAndUserCreator(CRSDbContext context) { _context = context; }
public DefaultTenantBuilder(CRSDbContext context) { _context = context; }
public BrandService(CRSDbContext repositoryContext, IMapper mapper) : base(repositoryContext) { _mapper = mapper; }
public DefaultSettingsCreator(CRSDbContext context) { _context = context; }
public DefaultLanguagesCreator(CRSDbContext context) { _context = context; }
public DefaultEditionCreator(CRSDbContext context) { _context = context; }
public Repository(CRSDbContext context) { _context = context; entities = context.Set <T>(); }
public CustomerService(CRSDbContext repositoryContext, IMapper mapper) : base(repositoryContext) { _mapper = mapper; }
public TenantRoleAndUserBuilder(CRSDbContext context, int tenantId) { _context = context; _tenantId = tenantId; }
public InitialHostDbBuilder(CRSDbContext context) { _context = context; }