public IActionResult Index() { HomeIndexViewModel model = new HomeIndexViewModel(); model.LoadModelData(_unitOfWork); return(View(model)); }
public IActionResult Index(IDictionary <string, string> routeValues) { HomeIndexViewModel model = new HomeIndexViewModel(); if (ModelState.IsValid) { model.LoadFilteredModelData(_unitOfWork, routeValues[nameof(model.FilterFrom)], routeValues[nameof(model.FilterTo)]); return(View(model)); } else { model.LoadModelData(_unitOfWork); return(View(model)); } }
public IActionResult Index(HomeIndexViewModel model) { if (ModelState.IsValid) { try { _unitOfWork.CategoryRepository.AddCategory(model.CategoryName); _unitOfWork.Save(); } catch (ValidationException ex) { foreach (var member in ex.ValidationResult.MemberNames) { ModelState.AddModelError(member, ex.ValidationResult.ErrorMessage); } } } model.LoadModelData(_unitOfWork); return(View(model)); }