public ActionResult LaborEdit() { LaborPlanningViewModel model = new LaborPlanningViewModel(); try { int jobId = Convert.ToInt32(Request.Params["jobId"].Trim()); if (Request.Params["jobId"].Any()) { model = bll.getLaborPlanningViewModel(jobId); List<JobScopeSet> jobScopeList = bll.getJobScope(); ViewBag.JobScopeList = jobScopeList; return View(model); } } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); } return RedirectToAction("LaborPlanning"); }
// public List<LaborPlanningViewModel> getLaborPlanningViewModelList(int activityId) { using (Youth_Center_DB_Conn db = new Youth_Center_DB_Conn()) { try { List<LaborPlanningViewModel> laborPlanningViewModelList = new List<LaborPlanningViewModel>(); List<JobSet> jobList = (from j in db.JobSets where j.ActivitySetId == activityId select j).ToList(); foreach (JobSet j in jobList) { LaborPlanningViewModel model = new LaborPlanningViewModel(); model.jobScope = j.JobScopeSet.scopeName; model.job = j; laborPlanningViewModelList.Add(model); } return laborPlanningViewModelList; } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); return new List<LaborPlanningViewModel>(); } } }
// // public ProjectViewModel getProjectViewModel(int projectId) { using (Youth_Center_DB_Conn db = new Youth_Center_DB_Conn()) { try { var projectList = from p in db.ProjectSets where p.Id == projectId select p; if (projectList.Any()) { ProjectViewModel projectModel = new ProjectViewModel(); ProjectSet project = projectList.First(); projectModel.project = project; projectModel.contact = project.Contact; List<ActivityModel> activityModelList = new List<ActivityModel>(); foreach(ActivitySet ac in project.ActivitySets) { ActivityModel activityModel = new ActivityModel(); activityModel.activity = ac; List<LaborPlanningViewModel> laborPlanModelList = new List<LaborPlanningViewModel>(); foreach (JobSet j in ac.JobSets) { LaborPlanningViewModel laborPlanModel = new LaborPlanningViewModel(); laborPlanModel.job = j; laborPlanModel.jobScope = j.JobScopeSet.scopeName; laborPlanModelList.Add(laborPlanModel); } activityModel.laborPlan = laborPlanModelList; activityModelList.Add(activityModel); } projectModel.activityModels = activityModelList; return projectModel; } } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); } return new ProjectViewModel(); } }
// // public LaborPlanningViewModel getLaborPlanningViewModel(int jobId) { using (Youth_Center_DB_Conn db = new Youth_Center_DB_Conn()) { try { LaborPlanningViewModel model = new LaborPlanningViewModel(); JobSet job = (from j in db.JobSets where j.Id == jobId select j).First(); string scopeName = job.JobScopeSet.scopeName; model.job = job; model.jobScope = scopeName; return model; } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); return new LaborPlanningViewModel(); } } }