Example #1
0
        public ActionResult AddAbout(About p)
        {
            ValidationResult results = aboutValidator.Validate(p);

            if (results.IsValid)
            {
                abm.AboutAdd(p);
                return(RedirectToAction("Index"));
            }
            else
            {
                foreach (var item in results.Errors)
                {
                    ModelState.AddModelError(item.PropertyName, item.ErrorMessage);
                }
            }
            return(View());
        }
        public ActionResult AddAbout(About about)
        {
            AboutValidator   validationRules  = new AboutValidator();
            ValidationResult validationResult = validationRules.Validate(about);

            if (validationResult.IsValid)
            {
                am.AddAbout(about);
            }
            else
            {
                foreach (var item in validationResult.Errors)
                {
                    ModelState.AddModelError(item.PropertyName, item.ErrorMessage);
                }
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult AddAbout(About about)
        {
            AboutValidator   aboutValidator = new AboutValidator();
            ValidationResult result         = aboutValidator.Validate(about);

            if (result.IsValid)
            {
                abm.AboutAdd(about);
                return(RedirectToAction("Index"));
            }
            else
            {
                foreach (var item in result.Errors)
                {
                    ModelState.AddModelError(item.PropertyName, item.ErrorMessage);
                }
            }
            return(PartialView("AboutPartial"));
        }
        public ActionResult AddAbout(About about)
        {
            AboutValidator   aboutValidator   = new AboutValidator();
            ValidationResult validationResult = aboutValidator.Validate(about);

            if (validationResult.IsValid)
            {
                aboutManager.AboutAddBL(about);
                return(RedirectToAction("Index"));
            }
            else
            {
                foreach (var error in validationResult.Errors)
                {
                    ModelState.AddModelError(error.PropertyName, error.ErrorMessage);
                }
            }
            return(View());
        }