Ejemplo n.º 1
0
 public ActionProductValidator(IProductServices _productServices, ResourcesServices _resourcesServices)
 {
     RuleFor(x => x.ProductName).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.ListPrice).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.ModelYear).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.Picture).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
 }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="stockServices">declare stockServices</param>
 public StockController(IStockServices stockServices, IProductServices productServices, IStoreServices storeServices, ResourcesServices resourcesServices)
 {
     _stockServices     = stockServices;
     _productServices   = productServices;
     _storeServices     = storeServices;
     _resourcesServices = resourcesServices;
 }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="productServices">declare productServices</param>
 public ProductController(IProductServices productServices, IBrandServices brandServices, ICategoryServices categoryServices, ResourcesServices resourcesServices)
 {
     _productServices   = productServices;
     _brandServices     = brandServices;
     _categoryServices  = categoryServices;
     _resourcesServices = resourcesServices;
 }
Ejemplo n.º 4
0
 public BrandController(IBrandServices brandServices,
                        ResourcesServices <CommonResources> commonLocalizer,
                        ResourcesServices <BrandResources> brandLocalizer)
 {
     _brandServices   = brandServices;
     _commonLocalizer = commonLocalizer;
     _brandLocalizer  = brandLocalizer;
 }
Ejemplo n.º 5
0
 public CategoryController(ICategoryServices categoryServices,
                           ResourcesServices <CommonResources> commonLocalizer,
                           ResourcesServices <CategoryResources> categoryLocalizer)
 {
     _categoryServices  = categoryServices;
     _categoryLocalizer = categoryLocalizer;
     _commonLocalizer   = commonLocalizer;
 }
Ejemplo n.º 6
0
 public LoginController(IUserServices userServices,
                        ILoginServices loginServices,
                        ResourcesServices <UserResources> userLocalizer)
 {
     _userLocalizer = userLocalizer;
     _userServices  = userServices;
     _loginServices = loginServices;
 }
Ejemplo n.º 7
0
        public StockValidator(ResourcesServices <StockResources> localizer, ResourcesServices <CommonResources> commonlocalizer)
        {
            RuleFor(x => x.Quantity).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));

            RuleFor(x => x.Quantity).GreaterThanOrEqualTo(1)
            .WithMessage(localizer.GetLocalizedHtmlString("msg_QuantityGreaterThan1"));
        }
Ejemplo n.º 8
0
        public BrandValidator(ResourcesServices <CommonResources> commonlocalizer, IBrandServices brandService)
        {
            RuleFor(x => x.BrandName).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));

            RuleFor(x => x.BrandName).Must((reg, c) => !brandService.IsExistedName(reg.BrandName, reg.Id))
            .WithMessage((reg, c) => string.Format(commonlocalizer.GetLocalizedHtmlString("msg_AlreadyExists"), c));
        }
Ejemplo n.º 9
0
 public StoreController(IStoreServices storeService,
                        ResourcesServices <CommonResources> commonLocalizer,
                        ResourcesServices <StoreResources> storeLocalizer)
 {
     _commonLocalizer = commonLocalizer;
     _storeService    = storeService;
     _storeLocalizer  = storeLocalizer;
 }
Ejemplo n.º 10
0
        public CategoryValidator(ResourcesServices <CommonResources> commonlocalizer, ICategoryServices categoryServices)
        {
            RuleFor(x => x.CategoryName).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));

            RuleFor(x => x.CategoryName).Must((reg, c) => !categoryServices.IsExistedName(reg.CategoryName, reg.Id))
            .WithMessage((reg, c) => string.Format(commonlocalizer.GetLocalizedHtmlString("msg_AlreadyExists"), c));
        }
Ejemplo n.º 11
0
 public UserController(
     IUserServices userService,
     IStoreServices storeServices,
     ResourcesServices <CommonResources> commonLocalizer)
 {
     _userServices    = userService;
     _storeServices   = storeServices;
     _commonLocalizer = commonLocalizer;
 }
Ejemplo n.º 12
0
 public EditUserValidator(ResourcesServices _resourcesServices)
 {
     RuleFor(x => x.FullName).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.FullName).Length(1, 100).WithMessage(_resourcesServices.GetLocalizedHtmlString("To 1 between 100 characters"));
     RuleFor(x => x.Phone).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.IsActive).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.Address).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.StoreId).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.Picture).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
 }
Ejemplo n.º 13
0
        public CategoryValidator(ResourcesServices _resourcesServices, ICategoryServices _categoryServices)
        {
            var categories = _categoryServices.GetCategories();

            foreach (var category in categories)
            {
                RuleFor(x => x.CategoryName).NotEqual(category.CategoryName).WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_alreadyexists"));
            }
            RuleFor(x => x.CategoryName).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
        }
Ejemplo n.º 14
0
 public EditUserValidator(ResourcesServices _resourcesServices)
 {
     RuleFor(x => x.FullName).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
     RuleFor(x => x.FullName).Length(1, 100).WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_toonefromonehundred"));
     RuleFor(x => x.Phone).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
     RuleFor(x => x.IsActive).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
     RuleFor(x => x.Address).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
     RuleFor(x => x.StoreId).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
     RuleFor(x => x.Picture).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
 }
Ejemplo n.º 15
0
 public EditStoreValidator(ResourcesServices _resourcesServices)
 {
     RuleFor(x => x.StoreName).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.Phone).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.Email).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.Email).EmailAddress().WithMessage(_resourcesServices.GetLocalizedHtmlString("Formatted by email"));
     RuleFor(x => x.Street).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.City).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.ZipCode).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
 }
Ejemplo n.º 16
0
 public LoginVadidator(ResourcesServices _resourcesServices)
 {
     RuleFor(x => x.Email).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
     RuleFor(x => x.Email).Length(1, 50).WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_toonefrommfifty"));
     RuleFor(x => x.Email).EmailAddress().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_formatemail"));
     RuleFor(x => x.PassWord).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
     RuleFor(x => x.PassWord).Matches("^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$").WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_letterandnumber"));
     RuleFor(x => x.PassWord).MaximumLength(100).WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_max100characters"));
     RuleFor(x => x.PassWord).MinimumLength(6).WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_min6characters"));
 }
Ejemplo n.º 17
0
        public BrandValidator(ResourcesServices _resourcesServices, IBrandServices _brandServices)
        {
            var brands = _brandServices.GetBrands();

            foreach (var brand in brands)
            {
                RuleFor(x => x.BrandName).NotEqual(brand.BrandName).WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_alreadyexists"));
            }
            RuleFor(x => x.BrandName).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
        }
Ejemplo n.º 18
0
 public LoginVadidator(ResourcesServices _resourcesServices)
 {
     RuleFor(x => x.Email).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.Email).Length(1, 50).WithMessage(_resourcesServices.GetLocalizedHtmlString("To 1 between 50 characters"));
     RuleFor(x => x.Email).EmailAddress().WithMessage(_resourcesServices.GetLocalizedHtmlString("Formatted by email"));
     RuleFor(x => x.PassWord).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.PassWord).Matches("^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$").WithMessage(_resourcesServices.GetLocalizedHtmlString("Contain both letters and numbers"));
     RuleFor(x => x.PassWord).MaximumLength(100).WithMessage(_resourcesServices.GetLocalizedHtmlString("Maxlength 100 characters"));
     RuleFor(x => x.PassWord).MinimumLength(6).WithMessage(_resourcesServices.GetLocalizedHtmlString("Minlength 6 characters"));
 }
Ejemplo n.º 19
0
        public ProductValidator(ResourcesServices <CommonResources> commonlocalizer, IProductServices productServices)
        {
            RuleFor(x => x.ProductName).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));
            RuleFor(x => x.ModelYear).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));
            RuleFor(x => x.ListPrice).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));

            RuleFor(x => x.ProductName).Must((reg, c) => !productServices.IsExistedName(reg.ProductName, reg.Id))
            .WithMessage((reg, c) => string.Format(commonlocalizer.GetLocalizedHtmlString("msg_AlreadyExists"), c));
        }
Ejemplo n.º 20
0
        public LoginValidator(ResourcesServices <CommonResources> commonlocalizer)
        {
            RuleFor(x => x.Email).NotNull().WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));
            RuleFor(x => x.Password).NotNull().WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));

            RuleFor(x => x.Email).EmailAddress().WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_WithALetter"));
            RuleFor(x => x.Password).MinimumLength(8).WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_8Characters"));

            RuleFor(x => x.Password)
            .Matches("^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$")
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_LettersAndNumbers"));
        }
Ejemplo n.º 21
0
 public StockController(IStockServices stockServices,
                        IProductServices productServices,
                        IStoreServices storeServices,
                        ResourcesServices <CommonResources> commonLocalizer,
                        ResourcesServices <StockResources> stockLocalizer
                        )
 {
     _stockServices   = stockServices;
     _productServices = productServices;
     _storeServices   = storeServices;
     _commonLocalizer = commonLocalizer;
     _stockLocalizer  = stockLocalizer;
 }
Ejemplo n.º 22
0
 public EditPasswordValidator(ResourcesServices _resourcesServices)
 {
     RuleFor(x => x.NewPassword).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.NewPassword).Matches("^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$").WithMessage(_resourcesServices.GetLocalizedHtmlString("Contain both letters and numbers"));
     RuleFor(x => x.NewPassword).MaximumLength(100).WithMessage(_resourcesServices.GetLocalizedHtmlString("Maxlength 100 characters"));
     RuleFor(x => x.NewPassword).MinimumLength(6).WithMessage(_resourcesServices.GetLocalizedHtmlString("Minlength 6 characters"));
     RuleFor(x => x.ConfirmPassword).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.ConfirmPassword).Matches("^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$").WithMessage(_resourcesServices.GetLocalizedHtmlString("Contain both letters and numbers"));
     RuleFor(x => x.ConfirmPassword).MaximumLength(100).WithMessage(_resourcesServices.GetLocalizedHtmlString("Maxlength 100 characters"));
     RuleFor(x => x.ConfirmPassword).MinimumLength(6).WithMessage(_resourcesServices.GetLocalizedHtmlString("Minlength 6 characters"));
     RuleFor(x => x.ConfirmPassword).Equal(x => x.NewPassword)
     .WithMessage(_resourcesServices.GetLocalizedHtmlString("Confirm Password must equal New Password"));
 }
Ejemplo n.º 23
0
 public ProductController(IProductServices productServices,
                          ICategoryServices categoryServices,
                          IBrandServices brandServices,
                          ResourcesServices <CommonResources> commonLocalizer,
                          ResourcesServices <ProductResources> productLocalizer
                          )
 {
     _productServices  = productServices;
     _categoryServices = categoryServices;
     _brandServices    = brandServices;
     _commonLocalizer  = commonLocalizer;
     _productLocalizer = productLocalizer;
 }
 public EditPasswordValidator(ResourcesServices _resourcesServices)
 {
     RuleFor(x => x.NewPassword).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
     RuleFor(x => x.NewPassword).Matches("^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$").WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_letterandnumber"));
     RuleFor(x => x.NewPassword).MaximumLength(100).WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_max100characters"));
     RuleFor(x => x.NewPassword).MinimumLength(6).WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_min6characters"));
     RuleFor(x => x.ConfirmPassword).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
     RuleFor(x => x.ConfirmPassword).Matches("^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$").WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_letterandnumber"));
     RuleFor(x => x.ConfirmPassword).MaximumLength(100).WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_max100characters"));
     RuleFor(x => x.ConfirmPassword).MinimumLength(6).WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_min6characters"));
     RuleFor(x => x.ConfirmPassword).Equal(x => x.NewPassword)
     .WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_equalpassword"));
 }
        public ProductValidator(ResourcesServices _resourcesServices, IProductServices _productServices)
        {
            var products = _productServices.GetProducts();

            foreach (var product in products)
            {
                RuleFor(x => x.ProductName).NotEqual(product.ProductName).WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_alreadyexists"));
            }
            RuleFor(x => x.ProductName).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
            RuleFor(x => x.ListPrice).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
            RuleFor(x => x.ModelYear).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
            RuleFor(x => x.Picture).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
        }
Ejemplo n.º 26
0
        public IndexValidator(ResourcesServices <CommonResources> commonlocalizer, IUserServices userServices)
        {
            RuleFor(x => x.Email).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));
            RuleFor(x => x.FullName).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));
            RuleFor(x => x.Phone).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));

            RuleFor(x => x.Email).Must((reg, c) => !userServices.IsExistedName(reg.Email, reg.Id))
            .WithMessage((reg, c) => string.Format(commonlocalizer.GetLocalizedHtmlString("msg_AlreadyExists"), c));
            RuleFor(x => x.Email).EmailAddress()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_AValidEmail"));
        }
Ejemplo n.º 27
0
        public IHttpActionResult Get([FromUri] int providerId)
        {
            if (providerId == 0)
            {
                return(BadRequest($"Provider id cannot be null"));
            }

            var result = ResourcesServices.Find(providerId);

            if (result == null)
            {
                return(NotFound());
            }

            return(Ok(result));
        }
Ejemplo n.º 28
0
        public IHttpActionResult Search(SearchRequest searchRequest)
        {
            if (searchRequest == null)
            {
                return(BadRequest("Object cannot be null"));
            }

            try
            {
                return(Ok(ResourcesServices.Search(searchRequest)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 29
0
        public StoreValidator(ResourcesServices _resourcesServices, IStoreServices _storeServices)
        {
            var stores = _storeServices.GetStores();

            foreach (var store in stores)
            {
                RuleFor(x => x.Email).NotEqual(store.Email).WithMessage(_resourcesServices.GetLocalizedHtmlString("Already exists"));
            }
            RuleFor(x => x.StoreName).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
            RuleFor(x => x.Phone).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
            RuleFor(x => x.Email).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
            RuleFor(x => x.Email).EmailAddress().WithMessage(_resourcesServices.GetLocalizedHtmlString("Formatted by email"));
            RuleFor(x => x.Street).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
            RuleFor(x => x.City).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
            RuleFor(x => x.ZipCode).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
        }
Ejemplo n.º 30
0
 protected UserValidator(ResourcesServices _resourcesServices)
 {
     RuleFor(x => x.Email).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.Email).Length(1, 50).WithMessage(_resourcesServices.GetLocalizedHtmlString("To 1 between 50 characters"));
     RuleFor(x => x.Email).EmailAddress().WithMessage(_resourcesServices.GetLocalizedHtmlString("Formatted by email"));
     RuleFor(x => x.PassWord).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.PassWord).Matches("^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$").WithMessage(_resourcesServices.GetLocalizedHtmlString("Contain both letters and numbers"));
     RuleFor(x => x.PassWord).MaximumLength(100).WithMessage(_resourcesServices.GetLocalizedHtmlString("Maxlength 100 characters"));
     RuleFor(x => x.PassWord).MinimumLength(6).WithMessage(_resourcesServices.GetLocalizedHtmlString("Minlength 6 characters"));
     RuleFor(x => x.FullName).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.FullName).Length(1, 100).WithMessage(_resourcesServices.GetLocalizedHtmlString("To 1 between 100 characters"));
     RuleFor(x => x.Phone).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.Picture).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.IsActive).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.Address).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
     RuleFor(x => x.StoreId).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("Not Null"));
 }