Beispiel #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(CookiePolicy.Configuration);

            services.AddDbContext <WebWalletDBContext>(dbContext =>
            {
                dbContext.UseSqlServer(this.Configuration.GetConnectionString("DefaultConnection"));
            },
                                                       ServiceLifetime.Transient
                                                       );

            services
            .AddIdentity <User, IdentityRole>(IdentityConfiguration.Options)
            .AddDefaultTokenProviders()
            .AddEntityFrameworkStores <WebWalletDBContext>();

            services
            .AddAuthentication()
            .AddCookie();

            // Do not move this configuration in AddCookie method it does not work for paths different than
            // /Account/Login ; /Account/Logout; /Account/AccessDenied
            services.ConfigureApplicationCookie(CookieAuthentication.Options);

            AppRepositories.Add(services);
            AppServices.Add(services);

            services.Configure <AuthMessageSenderOptions>(Configuration);

            var mappingConfig = new MapperConfiguration(mc =>
                                                        mc.AddProfile(new MappingProfile())
                                                        );

            IMapper mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);

            services.AddMemoryCache();
            services.AddResponseCaching();

            services.AddHttpCacheHeaders(CacheHeader.ExpirationOptions, CacheHeader.ValidationOptions);
            services
            .AddMvc(Mvc.Options)
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
 public VacationsController(AppRepositories repository)
 {
     _repository = repository;
 }