public ActionResult Update(JobOffer round) { ApiResult <JobOffer> apiResult; if (ModelState.IsValid) { if (round.Id > 0) { apiResult = TryExecute(() => { _jobOfferRepository.Update(round); _unitOfWork.Commit(); return(round); }, "Job Offer updated sucessfully"); } else { apiResult = TryExecute(() => { _jobOfferRepository.Create(round); _unitOfWork.Commit(); return(round); }, "Job Offer created sucessfully"); } } else { apiResult = ApiResultFromModelErrors <JobOffer>(); } return(Json(apiResult, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(JobOffer jobOffer) { if (ModelState.IsValid) { var selectedCandidate = _candidateRepository.Get(jobOffer.CandidateId); if (selectedCandidate != null) { selectedCandidate.Status = CandidateStatus.Offered; _candidateRepository.Update(selectedCandidate); } _jobOfferRepository.Create(jobOffer); _unitOfWork.Commit(); return(RedirectToAction("Index")); } ViewBag.CandidateId = new SelectList(_candidateRepository.GetAll(o => o.OrderByDescending(c => c.Id), "Person").Select(c => new { c.Id, Name = c.Person.Name + "- [" + c.Code + "]" }), "Id", "Name", jobOffer.CandidateId); ViewBag.DesignationId = new SelectList(_designationRepository.GetAll(), "Id", "Title", jobOffer.DesignationId); return(View(jobOffer)); }