Esempio n. 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <GuessContext>(options =>
                                                 options.UseSqlServer(
                                                     Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity <IdentityUser, IdentityRole>().AddEntityFrameworkStores <GuessContext>();

            services.Configure <IdentityOptions>(options =>
            {
                options.Password.RequiredLength         = 4;
                options.Password.RequireDigit           = false;
                options.Password.RequireUppercase       = false;
                options.Password.RequireNonAlphanumeric = false;
            });
            //RegistretionRepository(services);
            RegisterDIObjects(services);
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped(sp => ShoppingCartHelper.GetCart(sp));
            services.AddTransient(typeof(IProductRepository <Product>), typeof(ProductRepository <Product>));
            services.AddTransient(typeof(IOrderRepository), typeof(OrderRepository));
            services.AddSession();
            services.AddMemoryCache();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
Esempio 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.AddAutoMapper(typeof(Startup));
            services.AddControllers(setupAction => {
                setupAction.ReturnHttpNotAcceptable = true;
                setupAction.OutputFormatters.Add(new XmlDataContractSerializerOutputFormatter());
            }).AddNewtonsoftJson(
                setupAction =>
            {
                setupAction.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            }
                );
            services.AddControllersWithViews().AddNewtonsoftJson();
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("DefaultContext")));
            services.AddRazorPages().AddNewtonsoftJson();
            services.AddMvc().AddNewtonsoftJson(options => {
                options.SerializerSettings.ContractResolver      = new CamelCasePropertyNamesContractResolver();
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });



            services.AddSession();
            services.AddScoped <ShoppingCartHelper>(sp => ShoppingCartHelper.GetCart(sp));
            services.AddHttpContextAccessor();
            services.AddScoped <IShoppingCartService, ShoppingCartService>();
            services.AddScoped <IAppointmentService, AppointmentService>();
            services.AddScoped <IBannerService, BannerService>();
            services.AddScoped <IBannerStatisticService, BannerStatisticService>();
            services.AddScoped <IBlogCategoryService, BlogCategoryService>();
            services.AddScoped <IBlogPostService, BlogPostService>();
            services.AddScoped <IBlogPostCategoryService, BlogPostCategoryService>();
            services.AddScoped <IBrandService, BrandService>();
            services.AddScoped <IEventService, EventService>();
            services.AddScoped <IEventLocationService, EventLocationService>();
            services.AddScoped <IMediaService, MediaService>();
            services.AddScoped <IOfferDetailService, OfferDetailService>();
            services.AddScoped <IOfferService, OfferService>();
            services.AddScoped <IOrderDetailService, OrderDetailService>();
            services.AddScoped <IOrderService, OrderService>();
            services.AddScoped <IPressReleaseService, PressReleaseService>();
            services.AddScoped <IProductService, ProductService>();
            services.AddScoped <IFeatureService, FeatureService>();
            services.AddScoped <IFeatureAttributeService, FeatureAttributeService>();
            services.AddScoped <IShopCategoryService, ShopCategoryService>();
            services.AddScoped <IShoppingCartService, ShoppingCartService>();
            services.AddScoped <ITagService, TagService>();
            services.AddScoped <IBlogCategoryService, BlogCategoryService>();
            services.AddScoped <IBlogPostTagService, BlogPostTagService>();
            services.AddScoped <IBlogPostMediaService, BlogPostMediaService>();
            services.AddScoped <IEventMediaService, EventMediaService>();
            services.AddScoped <IEventTagService, EventTagService>();
            services.AddScoped <IShopCategoryFeatureService, ShopCategoryFeatureService>();
            services.AddScoped <IProductShopCategoryService, ProductShopCategoryService>();
            services.AddScoped <IProductMediaService, ProductMediaService>();
            services.AddScoped <IProductTagService, ProductTagService>();
            services.AddScoped <IProductAttributeService, ProductAttributeService>();
        }
Esempio n. 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddDefaultIdentity <IdentityUser>().AddEntityFrameworkStores <ApplicationDbContext>();

            services.AddScoped <IPieRepository, PieRepository>();
            services.AddScoped <ICategoryRepository, CategoryRepository>();
            services.AddScoped <IShoppingCartRepository, ShoppingCartRepository>();
            services.AddScoped <IOrderRepository, OrderRepository>();

            services.AddScoped(sp => ShoppingCartHelper.GetCart(sp));

            services.AddHttpContextAccessor();
            services.AddSession();
            services.AddControllersWithViews();
            services.AddRazorPages();
        }
Esempio n. 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAutoMapper(typeof(Startup));
            services.AddControllers();
            services.AddControllersWithViews().AddNewtonsoftJson();
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("DefaultContext")));
            services.AddRazorPages().AddNewtonsoftJson();
            services.AddMvc().AddNewtonsoftJson(options => {
                options.SerializerSettings.ContractResolver      = new CamelCasePropertyNamesContractResolver();
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });



            services.AddSession();
            services.AddHttpContextAccessor();
            services.AddIdentity <IdentityUser, IdentityRole>()
            // services.AddDefaultIdentity<IdentityUser>()
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders();

            services.AddMvc()
            .AddRazorPagesOptions(options =>
            {
                //options.AllowAreas = true;
                options.Conventions.AuthorizeAreaFolder("Identity", "/Account/Manage");
                options.Conventions.AuthorizeAreaPage("Identity", "/Account/Logout");
            });

            services.ConfigureApplicationCookie(options =>
            {
                options.LoginPath        = $"/Identity/Account/Login";
                options.LogoutPath       = $"/Identity/Account/Logout";
                options.AccessDeniedPath = $"/Identity/Account/AccessDenied";
            });
            services.AddSession();
            services.AddHttpContextAccessor();

            // using Microsoft.AspNetCore.Identity.UI.Services;
            services.AddSingleton <IEmailSender, EmailSender>();
            //services.AddApplicationInsightsTelemetry();
            services.AddScoped <ShoppingCartHelper>(sp => ShoppingCartHelper.GetCart(sp));
            services.AddScoped <IAppointmentService, AppointmentService>();
            services.AddScoped <IBannerService, BannerService>();
            services.AddScoped <IBannerStatisticService, BannerStatisticService>();
            services.AddScoped <IBlogCategoryService, BlogCategoryService>();
            services.AddScoped <IBlogPostService, BlogPostService>();
            services.AddScoped <IBlogPostCategoryService, BlogPostCategoryService>();
            services.AddScoped <IBrandService, BrandService>();
            services.AddScoped <IEventService, EventService>();
            services.AddScoped <IEventLocationService, EventLocationService>();
            services.AddScoped <IMediaService, MediaService>();
            services.AddScoped <IOfferDetailService, OfferDetailService>();
            services.AddScoped <IOfferService, OfferService>();
            services.AddScoped <IOrderDetailService, OrderDetailService>();
            services.AddScoped <IOrderService, OrderService>();
            services.AddScoped <IPressReleaseService, PressReleaseService>();
            services.AddScoped <IProductService, ProductService>();
            services.AddScoped <IFeatureService, FeatureService>();
            services.AddScoped <IFeatureAttributeService, FeatureAttributeService>();
            services.AddScoped <IShopCategoryService, ShopCategoryService>();
            services.AddScoped <IShoppingCartService, ShoppingCartService>();
            services.AddScoped <ITagService, TagService>();
            services.AddScoped <IBlogCategoryService, BlogCategoryService>();
            services.AddScoped <IBlogPostTagService, BlogPostTagService>();
            services.AddScoped <IBlogPostMediaService, BlogPostMediaService>();
            services.AddScoped <IEventMediaService, EventMediaService>();
            services.AddScoped <IEventTagService, EventTagService>();
            services.AddScoped <IShopCategoryFeatureService, ShopCategoryFeatureService>();
            services.AddScoped <IProductShopCategoryService, ProductShopCategoryService>();
            services.AddScoped <IProductMediaService, ProductMediaService>();
            services.AddScoped <IProductTagService, ProductTagService>();
            services.AddScoped <IProductAttributeService, ProductAttributeService>();
        }