public ActionResult Update(JobOpening jobOpening) { ApiResult <JobOpening> apiResult; if (ModelState.IsValid) { if (jobOpening.Id > 0) { apiResult = TryExecute(() => { _jobOpeningRepository.Update(jobOpening); _unitOfWork.Commit(); return(jobOpening); }, "Job Opening updated sucessfully"); } else { apiResult = TryExecute(() => { _jobOpeningRepository.Create(jobOpening); _unitOfWork.Commit(); return(jobOpening); }, "Job Opening created sucessfully"); } } else { apiResult = ApiResultFromModelErrors <JobOpening>(); } return(Json(apiResult, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(JobOpeningViewModel jobOpening) { if (ModelState.IsValid) { var selectedJobOpening = _jobOpeningRepository.Get(jobOpening.Id); selectedJobOpening.Title = jobOpening.Title; selectedJobOpening.NoOfVacancies = jobOpening.NoOfVacancies; selectedJobOpening.Description = jobOpening.Description; selectedJobOpening.OpeningStatus = jobOpening.OpeningStatus; selectedJobOpening.JobDescriptionPath = jobOpening.JobDescriptionFilePath; _jobOpeningRepository.Update(selectedJobOpening); _unitOfWork.Commit(); return(RedirectToAction("Index")); } return(View(jobOpening)); }