public ActionResult AddCategory(Category p) { CategoryValidator categoryValidator = new CategoryValidator(); ValidationResult results = categoryValidator.Validate(p); if (results.IsValid) { cm.CategoryAdd(p); return(RedirectToAction("GetCatgoryList")); } else { foreach (var item in results.Errors) { ModelState.AddModelError(item.PropertyName, item.ErrorMessage); } } return(View()); ////cm.CategoryAddBL(p); return(RedirectToAction("GetCatgoryList")); { } }
public ActionResult AddCategory(Category c) { CategoryValidator cv = new CategoryValidator(); ValidationResult results = cv.Validate(c); if (results.IsValid) { categoryManager.CategoryAdd(c); return RedirectToAction("Index"); } else { foreach (var item in results.Errors) { ModelState.AddModelError(item.PropertyName, item.ErrorMessage); } } return View(); }
public ActionResult CategoryAdd(Category category) { CategoryValidator categoryValidator = new CategoryValidator(); ValidationResult result = categoryValidator.Validate(category); if (result.IsValid) { cm.CategoryAdd(category); return(RedirectToAction("Index")); } else { foreach (var item in result.Errors) { ModelState.AddModelError(item.PropertyName, item.ErrorMessage); } } return(View()); }
public ActionResult AddCategory(Category category) { CategoryValidator validator = new CategoryValidator(); ValidationResult result = validator.Validate(category); if (result.IsValid) { _cm.CategoryAdd(category); return(RedirectToAction("Index")); } else { foreach (var errors in result.Errors) { ModelState.AddModelError(errors.PropertyName, errors.ErrorMessage); } } return(View()); }
public ActionResult AddCategory(Category p) { CategoryValidatior categoryValidator = new CategoryValidatior(); ValidationResult results = categoryValidator.Validate(p); //results değişkeni gelen değerlere göre kontrol ediyor if (results.IsValid) { cm.CategoryAdd(p); return(RedirectToAction("index")); } else { foreach (var item in results.Errors) { ModelState.AddModelError(item.PropertyName, item.ErrorMessage); } } return(View()); }
public ActionResult AddCategory(Category p) { //categoryManager.CategoryAddBL(p); CategoryValidator categoryValidator = new CategoryValidator(); ValidationResult validationResult = categoryValidator.Validate(p); if (validationResult.IsValid) { categoryManager.CategoryAdd(p); return(RedirectToAction("GetCategoryList")); } else { foreach (var item in validationResult.Errors) { ModelState.AddModelError(item.PropertyName, item.ErrorMessage); } } return(View()); }
public ActionResult AddCategory(Category p) { CategoryValidator catVal = new CategoryValidator(); ValidationResult results = catVal.Validate(p); if (results.IsValid) { cm.CategoryAdd(p); p.CategoryStatus = true; return(RedirectToAction("Index")); } else { foreach (var item in results.Errors) { ModelState.AddModelError(item.PropertyName, item.ErrorMessage); } } return(View()); }
public ActionResult AddCategory(Category category) { //categoryManager.CategoryAddBL(category); CategoryValidator categoryValidator = new CategoryValidator(); ValidationResult results = categoryValidator.Validate(category); if (results.IsValid) { categoryManager.CategoryAdd(category); return(RedirectToAction("GetCategoryList")); } else { foreach (var result in results.Errors) { ModelState.AddModelError(result.PropertyName, result.ErrorMessage); } } return(View()); }
public ActionResult CategoryAdd(Category category) { //categoryManager.CategoryAddBL(category); CategoryValidator categoryValidator = new CategoryValidator(); ValidationResult results = categoryValidator.Validate(category); if (results.IsValid) { categoryManager.CategoryAdd(category); return(RedirectToAction("GetCategoryList"));//ekleme işlemi tamamlandıktan sonra GetCategoryList aksiyonuna yönlendirdik. } else { foreach (var result in results.Errors) { ModelState.AddModelError(result.PropertyName, result.ErrorMessage); } } return(View()); }
public ActionResult AddCategory(Category p) { //cm.CategoryAddBL(p); CategoryValidator categoryValidator = new CategoryValidator(); //validasyon kontrolü categoryvalidator sınıfındaki olan değerlere göre doğruluk kontrolü ValidationResult validationResult = categoryValidator.Validate(p); if (validationResult.IsValid) //doğrulanmış ise { cm.CategoryAdd(p); return(RedirectToAction("GetCategoryList")); } else { foreach (var item in validationResult.Errors) { ModelState.AddModelError(item.PropertyName, item.ErrorMessage); } } return(View()); }
[HttpPost] //Sayfaya tıklandığında çalışır public ActionResult AddCategory(Category p) { //cm.CategoryAddBL(p); //catorgy managerden yer alan metotu kullandık. //ekleme işleminden sonra " " metota yönlendir. CategoryValidatior categoryValidator = new CategoryValidatior(); ValidationResult results = categoryValidator.Validate(p); //results değişkeni gelen değerlere göre kontrol ediyor if (results.IsValid) { cm.CategoryAdd(p); return(RedirectToAction("GetCategoryList")); } else { foreach (var item in results.Errors) { //modele error ları ekliyoruz (önce ne üzerinde çalışıyorsak,hatanın kendisi) ModelState.AddModelError(item.PropertyName, item.ErrorMessage); } } return(View()); }