public ActionResult Create(RequirementCategory requirementCategory) { if (ModelState.IsValid) { requirementCategory.CreatedByUserId = WebUser.Id; _requirementCategoryRepository.Create(requirementCategory); _unitOfWork.Commit(); return(RedirectToAction("Index")); } return(View(requirementCategory)); }
public ActionResult Update(RequirementCategory vm) { ApiResult <RequirementCategory> apiResult; if (ModelState.IsValid) { if (vm.Id > 0) { apiResult = TryExecute(() => { var category = _requirementCategoryRepository.Get(vm.Id); category.Title = vm.Title; category.UpdatedByUserId = WebUser.Id; category.UpdatedOn = DateTime.UtcNow; _requirementCategoryRepository.Update(category); _unitOfWork.Commit(); return(category); }, "Requirement Category updated sucessfully"); } else { apiResult = TryExecute(() => { vm.CreatedByUserId = WebUser.Id; _requirementCategoryRepository.Create(vm); _unitOfWork.Commit(); return(vm); }, "Requirement Category created sucessfully"); } } else { apiResult = ApiResultFromModelErrors <RequirementCategory>(); } return(Json(apiResult, JsonRequestBehavior.AllowGet)); }