public ActionResult View(int id) { Mentor mentor = ctx.Mentors.FirstOrDefault(m => m.M_Id == id); Project project = ctx.Projects.FirstOrDefault(m => m.M_Id == mentor.M_Id); ViewBag.mentor = mentor; ViewBag.project = project; List <OnBoarder> OnBoarders = ctx.OnBoarders.Where(m => m.M_Id == id).ToList(); List <Models.OnBoarderDetailModel> details = new List <OnBoarderDetailModel>(); foreach (OnBoarder ob in OnBoarders) { OnBoarderDetailModel obm = new OnBoarderDetailModel(); obm.Name = ob.O_Name; obm.OnboarderId = ob.O_Id; List <ProjectAssignment> rotations = ctx.ProjectAssignments.Where(m => m.O_Id == ob.O_Id).ToList(); foreach (ProjectAssignment r in rotations) { if (obm.Rotation1.Equals("---")) { obm.Rotation1 = GetProject(r.P_Id); } else if (obm.Rotation2.Equals("---")) { obm.Rotation2 = GetProject(r.P_Id); } else if (obm.Rotation3.Equals("---")) { obm.Rotation3 = GetProject(r.P_Id); } else if (obm.Rotation4.Equals("---")) { obm.Rotation4 = GetProject(r.P_Id); } } details.Add(obm); } return(View(details)); }
public JsonResult GetOnboardersForMentor([DataSourceRequest] DataSourceRequest request, int id) { DateTime today = DateTime.Now; List <ProjectAssignment> projects = db.ProjectAssignments .Where(m => m.PA_Start_Date <today && m.PA_End_Date> today && m.M_Id == id) .ToList(); //Get All Onboarder Who are currently working under mentor List <OnBoarderDetailModel> onboarderslist = new List <OnBoarderDetailModel>(); //List of onboarderDetailModel which is to be passed to view foreach (ProjectAssignment project in projects) { OnBoarderDetailModel model = new OnBoarderDetailModel(); List <ProjectAssignment> onboarderProject = db.ProjectAssignments .Where(m => m.O_Id == project.O_Id) .ToList(); //get all projects of onboarder foreach (ProjectAssignment onboarderdetail in onboarderProject) { model.OnboarderId = onboarderdetail.O_Id; model.Name = GetOnboarderNameById(onboarderdetail.O_Id); String projectName = GetProjectNameById(onboarderdetail.P_Id); if (model.Rotation1.Equals("---")) { model.Rotation1 = projectName; } else if (model.Rotation2.Equals("---")) { model.Rotation2 = projectName; } else if (model.Rotation3.Equals("---")) { model.Rotation3 = projectName; } else if (model.Rotation4.Equals("---")) { model.Rotation4 = projectName; } } onboarderslist.Add(model); } return(Json(onboarderslist.ToDataSourceResult(request), JsonRequestBehavior.AllowGet)); }