// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //services.AddTransient<IAuthorizationHandler, StreamingCategoryAuthorizationHandler>(); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(ProjectConfigurationHelper.GetConnectionString(Configuration))); services.ConfigureApplicationCookie(options => { options.Events.OnRedirectToLogin = context => { context.Response.Headers["Location"] = context.RedirectUri; context.Response.StatusCode = 401; return(Task.CompletedTask); }; options.Events.OnRedirectToAccessDenied = context => { context.Response.Headers["Location"] = context.RedirectUri; context.Response.StatusCode = 403; return(Task.CompletedTask); }; }); //Repositories services.AddScoped(typeof(IRepository <>), typeof(Repository <>)); //Automapper services.AddAutoMapper(x => { x.AddProfile(new ImageVmDTOMapper()); }); //Services services.AddScoped <IImageService, ImageService>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //services.AddTransient<IAuthorizationHandler, StreamingCategoryAuthorizationHandler>(); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(ProjectConfigurationHelper.GetConnectionString(Configuration))); services.AddIdentity <ApplicationUser, ApplicationIdentityRole>(options => { options.Password.RequiredLength = 4; options.Password.RequireLowercase = false; options.Password.RequireUppercase = false; options.Password.RequireNonAlphanumeric = false; options.Password.RequireDigit = false; options.SignIn.RequireConfirmedEmail = true; }) .AddEntityFrameworkStores <ApplicationDbContext>() .AddDefaultTokenProviders(); services.ConfigureApplicationCookie(options => { options.Events.OnRedirectToLogin = context => { context.Response.Headers["Location"] = context.RedirectUri; context.Response.StatusCode = 401; return(Task.CompletedTask); }; options.Events.OnRedirectToAccessDenied = context => { context.Response.Headers["Location"] = context.RedirectUri; context.Response.StatusCode = 403; return(Task.CompletedTask); }; }); // repositories services.AddScoped <IUserRepository, UserRepository>(); services.AddScoped(typeof(IRepository <>), typeof(Repository <>)); // api services services.AddScoped <IPatientService, PatientService>(); services.AddScoped <IVisitService, VisitService>(); services.AddScoped <IDoctorService, DoctorService>(); services.AddScoped <IUserService, UserService>(); services.AddScoped <ISpecializationService, SpecializationService>(); services.AddScoped <IMedicamentService, MedicamentService>(); services.AddScoped <IPrescriptionService, PrescriptionService>(); services.AddScoped <IReferralService, ReferralService>(); services.AddTransient <IEmailSender, SendGridEmailSender>(); services.AddAutoMapper(x => { x.AddProfile(new MappingDtoVM()); x.AddProfile(new MappingDtoEntity()); }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }