Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });

            var mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);
            MediatRRegistration.RegisterMediatR(services);
            RepositoryRegistration.RegisterRepo(services);
            ServicesRegistration.RegisterService(services);
            services.AddScoped <IUnitOfWork, UnitOfWork>();



            services.AddDistributedMemoryCache();
            services.AddSession(options =>
            {
                options.IdleTimeout        = TimeSpan.FromSeconds(10);
                options.Cookie.HttpOnly    = true;
                options.Cookie.IsEssential = true;
            });
            services.AddControllersWithViews();
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void   ConfigureServices(IServiceCollection services)
        {
            services.AddScoped <IUnitOfWork, UnitOfWork>();
            services.Configure <ApiBehaviorOptions>(opt =>
            {
                opt.SuppressModelStateInvalidFilter = true;
            });

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

            var mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);

            MediatRRegistration.RegisterMediatR(services);
            RepositoryRegistration.RegisterRepo(services);
            ServicesRegistration.RegisterService(services);

            services.AddTransient <IUserStore <ApplicationUser>, UserStore>();
            services.AddTransient <IRoleStore <ApplicationRole>, RoleStore>();
            services.AddIdentity <ApplicationUser, ApplicationRole>()
            .AddDefaultTokenProviders();
            services.AddControllersWithViews();
        }