public JsonResult AddSection(Section newSection) { int highestUniqueSectionID = DBInterfacer.GetSections().Select(t => t.UniqueID).Concat(new[] { 0 }).Max(); //gets the highest unique section ID in the sections DB newSection.UniqueID = highestUniqueSectionID + 1; return(Json(DBInterfacer.AddSection(newSection), JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> Login(LoginViewModel model) { if (ModelState.IsValid) { User loggingInUser = DBInterfacer.GetUsers().Find(user => (user.UserName == model.UserName && user.Password == model.Password)); if (loggingInUser != null) { Session["username"] = loggingInUser.UserName; if (loggingInUser.Type == "Admin") { return(RedirectToAction("Editor", "Admin")); //user is an admin } return(RedirectToAction("Dashboard", "Student")); //user is not an admin } else { ModelState.AddModelError("", "Invalid username or password"); } } // If we got this far, something failed, redisplay form return(View(model)); }
public JsonResult SaveSchedule1(String input) { dynamic dyn = JObject.Parse(input); String name = dyn.myArray[0].name; Schedule s1 = new Schedule(); for (int i = 0; i < 5; i++) { s1.schedule[i] = new Section(); s1.schedule[i].Course = dyn.myArray[i].name; s1.schedule[i].Day1 = dyn.myArray[i].lDay1; s1.schedule[i].Day2 = dyn.myArray[i].lDay2; s1.schedule[i].StartTime = dyn.myArray[i].startL; s1.schedule[i].EndTime = dyn.myArray[i].endL; s1.schedule[i].TutorialDay1 = dyn.myArray[i].tDay1; s1.schedule[i].TutorialDay2 = dyn.myArray[i].tDay2; s1.schedule[i].TutorialStartTime = dyn.myArray[i].startT; s1.schedule[i].TutorialEndTime = dyn.myArray[i].endT; s1.schedule[i].LabDay = dyn.myArray[i].labDay1; s1.schedule[i].LabStartTime = dyn.myArray[i].startLab; s1.schedule[i].LabEndTime = dyn.myArray[i].endLab; } return(Json(DBInterfacer.SaveSchedule1((Session["username"] ?? TEST_STUDENT_USER).ToString(), s1), JsonRequestBehavior.AllowGet)); }
public ContentResult GetSequence() //receives AJAX call from front-end and returns a JSON array { Sequence sequence = DBInterfacer.GetSequence((Session["username"] ?? TEST_STUDENT_USER).ToString()); var sequenceJson = JObject.FromObject(sequence); return(Content(sequenceJson.ToString(), "application/json")); }
public JsonResult DeleteSection(int sectionUniqueID) { return(Json(DBInterfacer.DeleteSection(sectionUniqueID), JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateExistingSection(Section section) { return(Json(DBInterfacer.UpdateExistingSection(section))); }
public JsonResult GetSections() { var sections = DBInterfacer.GetSections(); return(Json(sections, JsonRequestBehavior.AllowGet)); }
public ContentResult GenerateSchedules() { var x = Scheduler.GenerateSchedules(Sequencer.GenerateSequence(DBInterfacer.GetStudent((Session["username"] ?? TEST_STUDENT_USER).ToString()), 2, 0), 2, 0); var scheduleJson = JObject.FromObject(x); return(Content(scheduleJson.ToString(), "application/json")); }
public JsonResult ChangePassword(String newPassword) { return(Json(DBInterfacer.SetPassword((Session["username"] ?? TEST_STUDENT_USER).ToString(), newPassword), JsonRequestBehavior.AllowGet)); }
public JsonResult ViewRecord() { return(Json(DBInterfacer.GetRecord((Session["username"] ?? TEST_STUDENT_USER).ToString()), JsonRequestBehavior.AllowGet)); }
public JsonResult SaveSequence(Sequence sequence) { return(Json(DBInterfacer.SaveSequence((Session["username"] ?? TEST_STUDENT_USER).ToString(), sequence), JsonRequestBehavior.AllowGet)); }
public JsonResult TestEchoUsernameFromDB() { return(Json(DBInterfacer.GetUser((Session["username"] ?? TEST_STUDENT_USER).ToString()).UserName, JsonRequestBehavior.AllowGet)); }
public JsonResult TestGetSections() { return(Json(DBInterfacer.GetSections(), JsonRequestBehavior.AllowGet)); }
public JsonResult TestGetCourses() { return(Json(DBInterfacer.GetCourses().Count, JsonRequestBehavior.AllowGet)); }
public JsonResult GetSavedPreferences(Student.Preference prefs) { return(Json(DBInterfacer.GetSavedPreferences((Session["username"] ?? TEST_STUDENT_USER).ToString()), JsonRequestBehavior.AllowGet)); }