// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public async void Configure( IApplicationBuilder app, IWebHostEnvironment env, PromocodesAppContext context, UserManager <ApplicationUser> userManager, IHttpContextAccessor httpContextAccessor) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "PromocodesApp v1"); c.RoutePrefix = string.Empty; }); context.Codes.Add(new Code { Name = "Code 1" }); context.Services.Add(new Service { Name = "Service 1", Description = "Desc" }); var userService = new UserService (userManager, Configuration, httpContextAccessor); await userService.Register(new RegisterRequest { Email = "*****@*****.**", Username = "******", Password = "******" }); await context.SaveChangesAsync(); } // global cors policy app.UseCors(x => x .SetIsOriginAllowed(origin => true) .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers().RequireAuthorization(); }); }
public CodeServiceUserService(PromocodesAppContext context, IHttpContextAccessor httpContextAccessor) { _context = context; _httpContextAccessor = httpContextAccessor; }