public ActionResult Edit(CRMLeadStatus cRMLeadStatus) { if (ModelState.IsValid) { var selectedLeadStatus = _crmLeadStatusRepository.Get(cRMLeadStatus.Id); if (selectedLeadStatus != null) { selectedLeadStatus.Name = cRMLeadStatus.Name; selectedLeadStatus.UpdatedByUserId = WebUser.Id; _crmLeadStatusRepository.Update(cRMLeadStatus); _unitOfWork.Commit(); return(RedirectToAction("Index")); } } return(View(cRMLeadStatus)); }
public ActionResult Update(CRMLeadStatus vm) { ApiResult <CRMLeadStatus> apiResult; if (ModelState.IsValid) { if (vm.Id > 0) { apiResult = TryExecute(() => { var selectedLeadStatus = _crmLeadStatusRepository.Get(vm.Id); selectedLeadStatus.Name = vm.Name; selectedLeadStatus.UpdatedByUserId = WebUser.Id; _crmLeadStatusRepository.Update(selectedLeadStatus); _unitOfWork.Commit(); return(selectedLeadStatus); }, "Lead Status updated sucessfully"); } else { apiResult = TryExecute(() => { var newLeadStatus = new CRMLeadStatus { Name = vm.Name, CreatedByUserId = WebUser.Id }; _crmLeadStatusRepository.Create(newLeadStatus); _unitOfWork.Commit(); return(newLeadStatus); }, "Lead Status created sucessfully"); } } else { apiResult = ApiResultFromModelErrors <CRMLeadStatus>(); } return(Json(apiResult, JsonRequestBehavior.AllowGet)); }