public ActionResult MyProfile() { StudentProfileViewModel ViewModel = new StudentProfileViewModel(); string studentid = User.Identity.Name; var studentprofile = db.StudentProfiles.Find(studentid); if (studentprofile == null) { Session["FlashMessage"] = "Student Profile not found"; return RedirectToAction("Index", "Home"); } var applications = db.Applications.ToList().Where(a => a.created_by == studentid.ToString()); ViewModel.student = studentprofile; List<ProgramAction> programactions = new List<ProgramAction>(); foreach (var application in applications) { ProgramAction programaction = new ProgramAction(); programaction.application = application; programaction.program = application.Program; programaction.student = studentprofile; //check student eligibility programaction.eligible = true; //check program application period programaction.inperiod = (application.Program.application_start_time <= DateTime.Now && DateTime.Now <= application.Program.application_end_time); //check if before program start time programaction.beforestart = (DateTime.Now < application.Program.application_start_time); //check existing application programaction.existed = true; //check application status programaction.saved = programaction.application.ApplicationStatus.name == "Saved"; //check program status programaction.open = application.Program.ProgramStatus.name == "Opened"; programactions.Add(programaction); } ViewModel.programactions = programactions; return View(ViewModel); }
public ActionResult Details(string id = null) { StudentProfile studentprofile = db.StudentProfiles.Find(id); if (studentprofile == null) { Session["FlashMessage"] = "Student Profile not found"; return RedirectToAction("Index", "StudentProfile"); } StudentProfileViewModel ViewModel = new StudentProfileViewModel(); ViewModel.student = studentprofile; var applications = studentprofile.Applications; List<ProgramAction> programactions = new List<ProgramAction>(); foreach (var application in applications) { ProgramAction programaction = new ProgramAction(); programaction.application = application; programaction.program = application.Program; programaction.student = studentprofile; //check student eligibility programaction.eligible = true; //check program application period programaction.inperiod = (application.Program.application_start_time <= DateTime.Now && DateTime.Now <= application.Program.application_end_time); //check if before program start time programaction.beforestart = (DateTime.Now < application.Program.application_start_time); //check existing application programaction.existed = true; //check application status programaction.saved = programaction.application.ApplicationStatus.name == "Saved"; //check program status programaction.open = application.Program.ProgramStatus.name == "Opened"; programactions.Add(programaction); } ViewModel.programactions = programactions; ViewModel.particulartypes = db.StudentParticularTypes.ToList(); ViewModel.experiencetypes = db.StudentExperienceTypes.ToList(); ViewBag.profilepic = System.IO.File.Exists(Server.MapPath("~/Images/StudentProfile/" + studentprofile.id + ".jpg")); return PartialView(ViewModel); }