public ActionResult Create(JobPosition jobposition)
        {
            if (ModelState.IsValid)
            {
                uow.JobPositiontRepository.Add(jobposition);
                uow.Save();
                return RedirectToAction("Index", "JobPosition", new { recruitmentAgencyId = jobposition.RecruitmentAgencyId } );
            }

            PopulateFields(jobposition);
            return View(jobposition);
        }
 public object Update(JobPosition record)
 {
     try
     {
         uow.JobPositiontRepository.Update(record);
         uow.Save();
         return new { Result = "OK" };
     }
     catch (Exception ex)
     {
         return new { Result = "ERROR", Message = ex.Message };
     }
 }
        //
        // GET: /JobPosition/Create
        public ActionResult Create(int? RecruitmentAgencyId)
        {
            JobPosition jobposition = new JobPosition();
            if (RecruitmentAgencyId != null)
            {
                jobposition.RecruitmentAgencyId = RecruitmentAgencyId.Value;
            }
            else
            {
                PopulateFields();
            }

            return View(jobposition);
        }
 private void PopulateFields(JobPosition jobposition = null)
 {
     if (jobposition != null)
     {
         ViewBag.RecruitmentAgencyId = new SelectList(uow.RecruitmentAgencyRepository.All(), "RecruitmentAgencyId", "Name", jobposition.RecruitmentAgencyId);
     }
     else
     {
         ViewBag.RecruitmentAgencyId = new SelectList(uow.RecruitmentAgencyRepository.All(), "RecruitmentAgencyId", "Name");
     }
 }
 public ActionResult Edit(JobPosition jobposition)
 {
     if (ModelState.IsValid)
     {
         uow.JobPositiontRepository.Update(jobposition);
         uow.Save();
         return RedirectToAction("Index");
     }
     uow.JobPositiontRepository.Add(jobposition);
     return View(jobposition);
 }