public ActionResult Index(string arm, string studentID) { if (User.IsInRole("Parent")) { Int32 theUser = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> thSchoolStudents; // string userid = User.Identity.Name; List <Parent> theP = work.ParentRepository.Get(a => a.UserID == theUser).ToList(); Parent theRealParent = theP[0]; int idParent = theRealParent.ParentID; thSchoolStudents = work.PrimarySchoolStudentRepository.Get(a => a.ParentID == idParent).ToList(); List <SelectListItem> theItem1 = new List <SelectListItem>(); foreach (var s in thSchoolStudents) { theItem1.Add(new SelectListItem() { Text = s.LastName + " " + s.FirstName, Value = s.PersonID.ToString() }); ViewData["Students"] = theItem1; } } List <Level> theLevels = work.LevelRepository.Get().ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); theItem.Add(new SelectListItem() { Text = "None", Value = "" }); foreach (var level in theLevels) { theItem.Add(new SelectListItem() { Text = level.LevelName + ":" + level.Type, Value = level.LevelName + ":" + level.Type }); } ViewData["arm"] = theItem; List <List <TimeTable> > theTimeTable1 = TimeTableCollisionAviodance.DisplayTimeTable(arm); ViewBag.TimeTable = theTimeTable1; int userId = 0;// Convert.ToInt32(User.Identity.Name); if (User.IsInRole("Parent")) { Int32 theUser = Convert.ToInt32(User.Identity.Name); Parent theP = work.ParentRepository.Get(a => a.UserID == theUser).First(); if (studentID != null) { int id = Convert.ToInt32(studentID); // userId = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> theStaff = work.PrimarySchoolStudentRepository.Get(a => a.PersonID == id).ToList(); if (theStaff.Count() > 0) { PrimarySchoolStudent theRealStudent = theStaff[0]; string theArm = theRealStudent.LevelType; List <List <TimeTable> > theTimeTable = TimeTableCollisionAviodance.DisplayTimeTable(theArm); ViewBag.TimeTable = theTimeTable; return(View()); } } } if (string.IsNullOrEmpty(arm) && User.IsInRole("Student")) { userId = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> theStaff = work.PrimarySchoolStudentRepository.Get(a => a.UserID == userId).ToList(); if (theStaff.Count() > 0) { PrimarySchoolStudent theRealStudent = theStaff[0]; string theArm = theRealStudent.LevelType; List <List <TimeTable> > theTimeTable = TimeTableCollisionAviodance.DisplayTimeTable(theArm); ViewBag.TimeTable = theTimeTable; return(View()); } } return(View()); }
public ActionResult StudentTimeTableView(string studentID) { if (User.IsInRole("Parent")) { Int32 theUser = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> thSchoolStudents; // string userid = User.Identity.Name; List <Parent> theP = work.ParentRepository.Get(a => a.UserID == theUser).ToList(); Parent theRealParent = theP[0]; int idParent = theRealParent.ParentID; thSchoolStudents = work.PrimarySchoolStudentRepository.Get(a => a.ParentID == idParent).ToList(); List <SelectListItem> theItem = new List <SelectListItem>(); foreach (var s in thSchoolStudents) { theItem.Add(new SelectListItem() { Text = s.LastName + " " + s.FirstName, Value = s.PersonID.ToString() }); ViewData["Students"] = theItem; } } int userId = 0;//Convert.ToInt32(User.Identity.Name); // int userID = 0; //=// Convert.ToInt32(User.Identity.Name); if (User.IsInRole("Parent")) { // int userID = Convert.ToInt32(User.Identity.Name); Int32 theUser = Convert.ToInt32(User.Identity.Name); Parent theP = work.ParentRepository.Get(a => a.UserID == theUser).First(); if (studentID != null) { int id = Convert.ToInt32(studentID); PrimarySchoolStudent theStudents = work.PrimarySchoolStudentRepository.GetByID(id); if (theStudents != null) { userId = theStudents.UserID; // work.PrimarySchoolStudentRepository.Get(a=>a.UserID == ids).First(); } else { userId = -1; } } else { userId = -1; } } else { // userID = Convert.ToInt32(User.Identity.Name); userId = Convert.ToInt32(User.Identity.Name); } //int userId = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> theStaff = work.PrimarySchoolStudentRepository.Get(a => a.UserID == userId).ToList(); List <List <TimeTable> > theTimeTable = new List <List <TimeTable> >(); if (theStaff.Count() > 0) { PrimarySchoolStudent theRealStudent = theStaff[0]; string theArm = theRealStudent.LevelType; theTimeTable = TimeTableCollisionAviodance.DisplayTimeTable(theArm); } // ViewBag.TimeTable = theTimeTable; // ViewBag.Name = theRealStaff.LastName + " " + theRealStaff.FirstName; return(View("Index", theTimeTable)); }