Esempio 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"));
 }
Esempio n. 2
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));
        }
Esempio n. 3
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));
        }
        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"));
        }
Esempio n. 5
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));
        }
Esempio n. 6
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"));
        }
        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"));
        }
Esempio n. 8
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"));
        }
Esempio n. 9
0
        public async Task <IActionResult> Add(StoreViewModel storeViewModel)
        {
            if (ModelState.IsValid)
            {
                var store = await _storeService.AddAsync(storeViewModel);

                if (store)
                {
                    TempData["Success"] = _commonLocalizer.GetLocalizedHtmlString("msg_AddSuccess").ToString();
                    return(RedirectToAction("Index"));
                }
                ViewData["Error"] = _storeLocalizer.GetLocalizedHtmlString("err_AddStoreFailure");
                return(View(storeViewModel));
            }
            Log.Error("Add Store Error");
            return(View(storeViewModel));
        }
Esempio n. 10
0
        public async Task <IActionResult> Add(CategoryViewModel categoryViewModel)
        {
            if (ModelState.IsValid)
            {
                var categories = await _categoryServices.AddAsync(categoryViewModel);

                if (categories)
                {
                    TempData["Success"] = _commonLocalizer.GetLocalizedHtmlString("msg_AddSuccess").ToString();
                    return(RedirectToAction("Index"));
                }
                ViewData["Error"] = _categoryLocalizer.GetLocalizedHtmlString("err_AddCategoryFailure");
                return(View(categoryViewModel));
            }
            Log.Error("Add Category Error");
            return(View(categoryViewModel));
        }
Esempio n. 11
0
        public async Task <IActionResult> Add(BrandViewModel brandViewModel)
        {
            if (ModelState.IsValid)
            {
                var brands = await _brandServices.AddAsync(brandViewModel);

                if (brands)
                {
                    TempData["Success"] = _commonLocalizer.GetLocalizedHtmlString("msg_AddSuccess").ToString();
                    return(RedirectToAction("Index"));
                }
                ViewData["Error"] = _brandLocalizer.GetLocalizedHtmlString("err_AddBrandFailure");
                return(View(brandViewModel));
            }
            Log.Error("Add Brand Error");
            return(View(brandViewModel));
        }
Esempio n. 12
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"));
        }
Esempio n. 13
0
        public PasswordValidator(ResourcesServices <UserResources> localizer, ResourcesServices <CommonResources> commonlocalizer, IUserServices userServices)
        {
            RuleFor(x => x.NewPassword).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));
            RuleFor(x => x.ConfirmPassword).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));

//            RuleFor(x => x.NewPassword).Must((reg,c) => !userServices.IsExistedPassword(reg.NewPassword,reg.Id))
//                .WithMessage((reg,c) => string.Format(localizer.GetLocalizedHtmlString("msg_AlreadyExistsPassword"),c));

            RuleFor(x => x.NewPassword).MinimumLength(8)
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_8Characters"));
            RuleFor(x => x.NewPassword).Matches("^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$").
            WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_LettersAndNumbers"));
            RuleFor(x => x.ConfirmPassword).Matches("^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$").
            WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_LettersAndNumbers"));
            RuleFor(x => x.ConfirmPassword).Equal(x => x.NewPassword)
            .WithMessage(localizer.GetLocalizedHtmlString("msg_ConfirmPasswordMustBeEqualNewPassword"));
        }
Esempio n. 14
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"));
        }
        public async Task <IActionResult> LoginForm(LoginViewModel user)
        {
            if (ModelState.IsValid)
            {
                var isValidator = _userServices.Login(user.Email, user.PassWord);
                if (isValidator)
                {
                    var getEmail = await _userServices.GetEmail(user.Email);

                    HttpContext.Session.SetString("fullname", getEmail.FullName);
                    HttpContext.Session.SetString("picture", getEmail.Picture);
                    return(RedirectToAction("Index", "Home"));
                }
            }
            ViewData["errorMessage"] = _resourcesServices.GetLocalizedHtmlString("msg_ErrorLogin");
            return(View(user));
        }
Esempio n. 16
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"));
 }
Esempio n. 17
0
        public async Task <IActionResult> Add(StockViewModel stockViewModel)
        {
            if (ModelState.IsValid)
            {
                var stocks = await _stockServices.AddAsync(stockViewModel);

                if (stocks)
                {
                    TempData["Success"] = _commonLocalizer.GetLocalizedHtmlString("msg_AddSuccess").ToString();
                    return(RedirectToAction("Index"));
                }
                ViewBag.ProductId = new SelectList(_productServices.GetProducts(), "Id", "ProductName", stockViewModel.ProductId);
                ViewBag.StoreId   = new SelectList(_storeServices.GetStores(), "Id", "StoreName", stockViewModel.StoreId);
                ViewData["Error"] = _stockLocalizer.GetLocalizedHtmlString("err_AddStockFailure");
                return(View(stockViewModel));
            }
            ViewBag.ProductId = new SelectList(_productServices.GetProducts(), "Id", "ProductName", stockViewModel.ProductId);
            ViewBag.StoreId   = new SelectList(_storeServices.GetStores(), "Id", "StoreName", stockViewModel.StoreId);
            Log.Error("Add Stock Error");
            return(View(stockViewModel));
        }
Esempio n. 18
0
        public async Task <IActionResult> Add(ProductViewModel productViewModel)
        {
            if (ModelState.IsValid)
            {
                var products = await _productServices.AddAsync(productViewModel);

                if (products)
                {
                    TempData["Success"] = _commonLocalizer.GetLocalizedHtmlString("msg_AddSuccess").ToString();
                    return(RedirectToAction("Index"));
                }
                ViewData["Error"]  = _productLocalizer.GetLocalizedHtmlString("err_AddProductFailure");
                ViewBag.CategoryId = new SelectList(_categoryServices.GetCategorys(), "Id", "CategoryName", productViewModel.CategoryId);
                ViewBag.BrandId    = new SelectList(_brandServices.GetBrands(), "Id", "BrandName", productViewModel.BrandId);
                return(View(productViewModel));
            }
            ViewBag.CategoryId = new SelectList(_categoryServices.GetCategorys(), "Id", "CategoryName", productViewModel.CategoryId);
            ViewBag.BrandId    = new SelectList(_brandServices.GetBrands(), "Id", "BrandName", productViewModel.BrandId);
            Log.Error("Add Product Error");
            return(View(productViewModel));
        }
Esempio n. 19
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"));
 }
Esempio n. 20
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"));
 }
Esempio n. 21
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"));
        }
Esempio 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"));
 }
 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"));
 }
Esempio n. 24
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"));
 }
Esempio n. 25
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"));
 }
Esempio n. 26
0
        public StoreValidator(ResourcesServices <CommonResources> commonlocalizer, IStoreServices storeServices)
        {
            RuleFor(x => x.Phone).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));
            RuleFor(x => x.StoreName).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));
            RuleFor(x => x.State).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));
            RuleFor(x => x.Street).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));
            RuleFor(x => x.City).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));
            RuleFor(x => x.ZipCode).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));
            RuleFor(x => x.Email).NotNull()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_NotEmpty"));

            RuleFor(x => x.Email).Must((reg, c) => !storeServices.IsExistedName(reg.Email, reg.Id))
            .WithMessage((reg, c) => string.Format(commonlocalizer.GetLocalizedHtmlString("msg_AlreadyExists"), c));

            RuleFor(x => x.Email).EmailAddress()
            .WithMessage(commonlocalizer.GetLocalizedHtmlString("msg_WithALetter"));
        }
Esempio n. 27
0
 public async Task <IActionResult> Create(CustomerViewModel addCustomer)
 {
     if (ModelState.IsValid)
     {
         if (await _customerServices.CreateCustomer(addCustomer))
         {
             TempData["succcessMessage"] = _resourcesServices.GetLocalizedHtmlString("customer_msg_NewCustomerSuccess").ToString();
             return(RedirectToAction("Index"));
         }
     }
     ViewData["errorMessage"] = _resourcesServices.GetLocalizedHtmlString("customer_msg_NewCustomerError");
     return(View(addCustomer));
 }
Esempio n. 28
0
        public async Task <IActionResult> Add(UserViewModel userViewModel)
        {
            if (ModelState.IsValid)
            {
                var user = await _userServices.AddAsync(userViewModel);

                if (user)
                {
                    ViewBag.StoreId     = new SelectList(_storeServices.GetStores(), "Id", "StoreName", userViewModel.StoreId);
                    TempData["Succces"] = _commonLocalizer.GetLocalizedHtmlString("msg_AddSuccess").ToString();
                    return(RedirectToAction("Index"));
                }
                ViewData["Error"] = _commonLocalizer.GetLocalizedHtmlString("err_AddUserFailure");
                ViewBag.StoreId   = new SelectList(_storeServices.GetStores(), "Id", "StoreName", userViewModel.StoreId);
                return(View(userViewModel));
            }
            ViewBag.StoreId = new SelectList(_storeServices.GetStores(), "Id", "StoreName", userViewModel.StoreId);
            Log.Error("Add User Error");
            return(View(userViewModel));
        }
 public async Task <IActionResult> Create(BrandViewModel addBrand)
 {
     HttpContext.Session.GetString("fullname");
     if (ModelState.IsValid)
     {
         if (await _brandServices.CreateBrand(addBrand))
         {
             TempData["succcessMessage"] = _resourcesServices.GetLocalizedHtmlString("msg_NewCustomerSuccess").ToString();
             return(RedirectToAction("Index"));
         }
     }
     ViewData["errorMessage"] = _resourcesServices.GetLocalizedHtmlString("msg_NewCustomerError");
     return(View(addBrand));
 }
Esempio n. 30
0
 public async Task <IActionResult> Create(StoreViewModel addStore)
 {
     HttpContext.Session.GetString("fullname");
     if (ModelState.IsValid)
     {
         if (await _storeServices.CreateStore(addStore))
         {
             TempData["succcessMessage"] = _resourcesServices.GetLocalizedHtmlString("Add Success").ToString();
             return(RedirectToAction("Index"));
         }
     }
     ViewData["errorMessage"] = _resourcesServices.GetLocalizedHtmlString("Add Error");
     return(View(addStore));
 }