public SearchService(IMapper mapper,
                             SPNDbContext dbContext,
                             IMakeService makeService,
                             ValidatePrimaryPropertiesSearch primaryPropertiesValidator,
                             ValidateInteriorSearch interiorsValidator,
                             ValidateInteriorMaterialsSearch interiorMaterialsvalidator,
                             ValidateSafetySearch safetyValidator,
                             ValidateSpecializedFeaturesSearch specializedFeaturesValidator,
                             ValidateSuspensionsSearch suspensionsValidator,
                             ValidateExtraFeaturesSearch extraFeaturesValidator)
            :

            base(mapper, dbContext)
        {
            this.makeService = makeService;
            this.primaryPropertiesValidator   = primaryPropertiesValidator;
            this.interiorsValidator           = interiorsValidator;
            this.interiorMaterialsvalidator   = interiorMaterialsvalidator;
            this.safetyValidator              = safetyValidator;
            this.specializedFeaturesValidator = specializedFeaturesValidator;
            this.suspensionsValidator         = suspensionsValidator;
            this.extraFeaturesValidator       = extraFeaturesValidator;
        }
Exemplo 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.AddDbContext <SPNDbContext>(options =>
                                                 options.UseSqlServer(
                                                     Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity <User, IdentityRole>()
            .AddEntityFrameworkStores <SPNDbContext>()
            .AddDefaultTokenProviders();

            services.Configure <IdentityOptions>(options =>
            {
                // Password settings.

                options.Password.RequireDigit           = false;
                options.Password.RequireLowercase       = false;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = false;
                options.Password.RequiredLength         = 3;
                options.Password.RequiredUniqueChars    = 0;

                options.User.RequireUniqueEmail = false;
            });

            services
            .ConfigureApplicationCookie(options =>
            {
                options.LoginPath  = "/Identity/Account/Login";
                options.LogoutPath = "/Identity/Account/Logout";
            });

            services.AddAutoMapper(AutoMapperConfig.GetAutoMapperProfilesFromAllAssemblies()
                                   .ToArray());
            services.AddScoped <SPNUserRoleSeeder>();
            services.AddScoped <SPNCategorySeeder>();
            services.AddScoped <SPNConciseAutoSeed>();

            //Forum Services
            services.AddScoped <ICategoryService, CategoryService>();
            services.AddScoped <IPostService, PostService>();
            services.AddScoped <IUserService, UserService>();
            services.AddScoped <IReplyService, ReplyService>();
            services.AddScoped <IQuoteService, QuoteService>();


            //Auto Services
            services.AddScoped <IMakeService, MakeService>();
            services.AddScoped <IModelService, ModelService>();
            services.AddScoped <IAutoService, AutoService>();
            services.AddScoped <ISearchService, SearchService>();



            // Cloudinary Setup
            var cloudinaryAccount = new CloudinaryDotNet.Account(CloudinaryConfig.CloudName, CloudinaryConfig.ApiKey, CloudinaryConfig.ApiSecret);
            var cloudinary        = new Cloudinary(cloudinaryAccount);

            services.AddSingleton(cloudinary);

            //Helpers Setup
            var imagesHelper = new ImagesHelper();

            var primaryPropertiesValidator   = new ValidatePrimaryPropertiesSearch();
            var interiorsValidator           = new ValidateInteriorSearch();
            var interiorMaterialsvalidator   = new ValidateInteriorMaterialsSearch();
            var safetyValidator              = new ValidateSafetySearch();
            var specializedFeaturesValidator = new ValidateSpecializedFeaturesSearch();
            var suspensionsValidator         = new ValidateSuspensionsSearch();
            var extraFeaturesValidator       = new ValidateExtraFeaturesSearch();

            services.AddSingleton(imagesHelper);

            services.AddSingleton(imagesHelper);
            services.AddSingleton(primaryPropertiesValidator);
            services.AddSingleton(interiorsValidator);
            services.AddSingleton(interiorMaterialsvalidator);
            services.AddSingleton(safetyValidator);
            services.AddSingleton(specializedFeaturesValidator);
            services.AddSingleton(suspensionsValidator);
            services.AddSingleton(extraFeaturesValidator);


            services.AddControllersWithViews();
            services.AddRazorPages();
        }