public ActionResult NewJob(long id) { Department d = _departmentService.GetDepartmentById(id); List <Job> jobs = _jobService.GetAllJob(); AddJobForDepartmentViewModel model = new AddJobForDepartmentViewModel(d, jobs); return(View(model)); }
public ActionResult NewJob(AddJobForDepartmentViewModel model) { try { long departmentId = System.Convert.ToInt64(Url.RequestContext.RouteData.Values["id"]); Department department = _departmentService.GetDepartmentById(departmentId); long jobId = System.Convert.ToInt64(model.JobId); Job j = _jobService.GetJobById(jobId); _departmentService.AddJob(department, j); return(RedirectToAction("Details", "Department", new { id = departmentId })); } catch { return(View()); } }