// 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?}");
            });
        }
Exemple #2
0
 public OrderService(CRSDbContext repositoryContext, IMapper mapper, ICustomerService customerService, IVehicleService vehicleService)
     : base(repositoryContext)
 {
     _customerService = customerService;
     _vehicleService  = vehicleService;
     _mapper          = mapper;
 }
Exemple #3
0
        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();
        }
Exemple #4
0
 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;
 }
Exemple #5
0
        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);
                }
            }
        }
Exemple #7
0
 public VehicleModelService(CRSDbContext repositoryContext, IMapper mapper)
     : base(repositoryContext)
 {
     _mapper = mapper;
 }
Exemple #8
0
 public HostRoleAndUserCreator(CRSDbContext context)
 {
     _context = context;
 }
 public DefaultTenantBuilder(CRSDbContext context)
 {
     _context = context;
 }
Exemple #10
0
 public BrandService(CRSDbContext repositoryContext, IMapper mapper)
     : base(repositoryContext)
 {
     _mapper = mapper;
 }
Exemple #11
0
 public DefaultSettingsCreator(CRSDbContext context)
 {
     _context = context;
 }
 public DefaultLanguagesCreator(CRSDbContext context)
 {
     _context = context;
 }
Exemple #13
0
 public DefaultEditionCreator(CRSDbContext context)
 {
     _context = context;
 }
Exemple #14
0
 public Repository(CRSDbContext context)
 {
     _context = context;
     entities = context.Set <T>();
 }
 public CustomerService(CRSDbContext repositoryContext, IMapper mapper)
     : base(repositoryContext)
 {
     _mapper = mapper;
 }
Exemple #16
0
 public TenantRoleAndUserBuilder(CRSDbContext context, int tenantId)
 {
     _context  = context;
     _tenantId = tenantId;
 }
 public InitialHostDbBuilder(CRSDbContext context)
 {
     _context = context;
 }