public ActionResult Courses() { CoursesVM model = new CoursesVM(); using (var ctx = new CSEntities()) { // Drop Down List For Teachers model.TeacherList = (from t in ctx.Teachers select t).ToList(); List <SelectListItem> itemsT = new List <SelectListItem>(); foreach (var item in model.TeacherList) { itemsT.Add(new SelectListItem { Value = item.ID.ToString(), Text = item.Person.FName + " " + item.Person.LName }); } model.ValuesT = itemsT; // Drop Down List For Courses model.CoursesList = (from c in ctx.CoursesLists select c).ToList(); List <SelectListItem> itemsC = new List <SelectListItem>(); foreach (var item in model.CoursesList) { itemsC.Add(new SelectListItem { Value = item.ID.ToString(), Text = item.Name }); } model.ValuesC = itemsC; //List of Courses // model.CoursesUser = ctx.Courses1(Convert.ToInt32(Session["ID"])).ToList(); model.CoursesUser = ctx.CoursesForAll(Convert.ToInt32(Session["ID"])).ToList(); } return(View(model)); }
public ActionResult AssignTeacherForCourse(CoursesVM post) { using (var ctx = new CSEntities()) { ctx.AssignTeacherForCourse(post.SelectedValuesT.FirstOrDefault(), post.SelectedValuesC.FirstOrDefault()); return(RedirectToAction("Courses", "Home")); } }
public ActionResult InvolveTeacher(int ID) { using (var ctx = new CSEntities()) { ctx.InvolveTeacher(ID); return(RedirectToAction("Teachers", "Home")); } }
public ActionResult LeaveCourse(int ID) { using (var ctx = new CSEntities()) { ctx.StudentLeaveCourse((int)Session["ID"], ID); return(RedirectToAction("Courses", "Home")); } }
public ActionResult UpdateTeacher(TeachersVM post) { using (var ctx = new CSEntities()) { ctx.UpdateTeacher(post.HelpID, post.FName, post.LName, post.Phone, post.Email, post.DofB, post.Degree, post.Login, post.Password); return(RedirectToAction("Teachers", "Home")); } }
public ActionResult UpdateStudent(StudentsVM post) { using (var ctx = new CSEntities()) { ctx.UpdateStudent(post.HelpID, post.FName, post.LName, post.Phone, post.Email, post.DofB, post.Spec, post.Login, post.Password); return(RedirectToAction("Students", "Home")); } }
public ActionResult StartCourse(int ID) { using (var ctx = new CSEntities()) { ctx.StartCourse(ID); return(RedirectToAction("Courses", "Home")); } }
public ActionResult UpdateCourse(CoursesVM post) { using (var ctx = new CSEntities()) { ctx.UpdateCourse(Int32.Parse(post.HelpID), post.Name, post.Description); return(RedirectToAction("Courses", "Home")); } }
public ActionResult PostNewCourse(CoursesVM post) { using (var ctx = new CSEntities()) { ctx.AddNewCourse(post.Name, post.Description); return(RedirectToAction("Courses", "Home")); } }
public ActionResult PostNewMark(MarksVM post) { using (var ctx = new CSEntities()) { ctx.AddNewMark(post.Course.FirstOrDefault(), post.StudentID, post.Mark, post.Date.FirstOrDefault().ToString(), post.Teacher); return(RedirectToAction("Marks", "Home")); } }
public ActionResult DelScheduleDate(int ID) { using (var ctx = new CSEntities()) { ctx.DelScheduleDate(ID, Int32.Parse(Session["ID"].ToString())); return(RedirectToAction("Schedule", "Home")); } }
public ActionResult UpdateSchedule(ScheduleVM post) { using (var ctx = new CSEntities()) { ctx.UpdateClassSchedule(post.HelpID, post.STime, post.ETime, post.SelectedValuesCl[0], post.SelectedValuesC[0], post.SelectedValuesT[0]); return(RedirectToAction("Schedule", "Home")); } }
public ActionResult InvolveStudent(int ID) { using (var ctx = new CSEntities()) { ctx.InvolveStudent(ID); return(RedirectToAction("Students", "Home")); } }
public ActionResult DelMark(int ID) { using (var ctx = new CSEntities()) { ctx.DelMark(ID); return(RedirectToAction("Marks", "Home")); } }
public ActionResult Students() { StudentsVM model = new StudentsVM(); using (var ctx = new CSEntities()) { model.StudentList = (from t in ctx.Students1 select t).ToList(); } return(View(model)); }
public ActionResult Main() { ScheduleVM model = new ScheduleVM(); using (var ctx = new CSEntities()) { model.ScheduleView = (from t in ctx.Schedules select t).ToList(); } return(View(model)); }
public ActionResult Teachers() { TeachersVM model = new TeachersVM(); using (var ctx = new CSEntities()) { model.TeacherList = (from t in ctx.Teachers1 select t).ToList(); } return(View(model)); }
public ActionResult Schedule() { ScheduleVM model = new ScheduleVM(); using (var ctx = new CSEntities()) { model.ScheduleList = (from t in ctx.ScheduleLists select t).ToList(); // model.ScheduleUser = ctx.ScheduleUserFunc(Convert.ToInt32(Session["ID"])).ToList(); model.ScheduleUser = ctx.ScheduleForAllUser(Convert.ToInt32(Session["ID"])).ToList(); //model.TeacherList = (from t in ctx.Teachers select t.Person.LName).ToList(); //model.CourseList = (from t in ctx.Courses where t.Closed == false select t.Name).ToList(); //TEST PART // Drop Down List For Teachers model.TeacherList = (from t in ctx.Teachers select t).ToList(); List <SelectListItem> itemsT = new List <SelectListItem>(); foreach (var item in model.TeacherList) { itemsT.Add(new SelectListItem { Value = item.ID.ToString(), Text = item.Person.FName + " " + item.Person.LName }); } model.ValuesT = itemsT; // Drop Down List For Courses model.CoursesList = (from c in ctx.CoursesLists select c).ToList(); List <SelectListItem> itemsC = new List <SelectListItem>(); foreach (var item in model.CoursesList) { itemsC.Add(new SelectListItem { Value = item.ID.ToString(), Text = item.Name }); } model.ValuesC = itemsC; // Drop Down List For Classes model.ClassList = (from t in ctx.ClassRooms select t).ToList(); List <SelectListItem> itemsCl = new List <SelectListItem>(); foreach (var item in model.ClassList) { itemsCl.Add(new SelectListItem { Value = item.ID.ToString(), Text = item.ClassNumber }); } model.ValuesCl = itemsCl; //END } return(View(model)); }
public ActionResult PostNewDate(ScheduleVM post) { if (post.STime != null || post.ETime != null) { using (var ctx = new CSEntities()) { // ctx.AddNewDate(post.STime, post.ETime, post.ClassList.FirstOrDefault(), post.CourseList.FirstOrDefault(), post.TeacherList.FirstOrDefault()); ctx.AddNewDate(post.STime, post.ETime, post.SelectedValuesCl.FirstOrDefault(), post.SelectedValuesC.FirstOrDefault(), post.SelectedValuesT.FirstOrDefault()); return(RedirectToAction("Schedule", "Home")); } } return(RedirectToAction("Schedule", "Home")); }
public ActionResult Marks() { MarksVM model = new MarksVM(); using (var ctx = new CSEntities()) { int UserIDint = Int32.Parse(Session["ID"].ToString()); var UserRole = from p in ctx.People where p.ID == UserIDint select p.RoleID; string UserIDstring = Session["ID"].ToString(); if (UserRole.FirstOrDefault().ToString() == "3" || UserRole.FirstOrDefault().ToString() == "4") { model.MarksByUser = ctx.MarksByUser(UserIDint).ToList(); } else { model.MarksList = (from t in ctx.MarkLists select t).ToList(); } model.Teacher = Session["LNAME"].ToString(); model.TeacherID = Int32.Parse(Session["ID"].ToString()); model.Course = (from c in ctx.Courses join ct in ctx.CourseTeachers on c.ID equals ct.CourseID join t in ctx.Teachers on ct.TeacherID equals t.ID join p in ctx.People on t.PersonID equals p.ID where p.ID == model.TeacherID && c.Closed == false select c.Name).ToList(); model.Date = (from cs in ctx.ClassSchedules join t in ctx.Teachers on cs.TeacherID equals t.ID join p in ctx.People on t.PersonID equals p.ID where p.ID == model.TeacherID select cs.StartTime).ToList(); } return(View(model)); }
public ActionResult PostLogin(string login, string password) { var loggedUser = new Person(); ScheduleVM lUser = new ViewModel.ScheduleVM(); using (var ctx = new CSEntities()) { loggedUser = ctx.GetLogin(login, password).FirstOrDefault(); if (loggedUser == null) { ViewBag.BadSignIn = "<p class=\"bg bg-warning\">Incorrect login or password, please try again.</p>"; return(View("Login")); } else { Session["ID"] = loggedUser.ID; Session["ROLE"] = loggedUser.RoleID; Session["FNAME"] = loggedUser.FName; Session["LNAME"] = loggedUser.LName; return(RedirectToAction("Main")); } } }