Beispiel #1
0
        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));
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        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"));
        }
Beispiel #5
0
 public JsonResult DeleteSection(int sectionUniqueID)
 {
     return(Json(DBInterfacer.DeleteSection(sectionUniqueID), JsonRequestBehavior.AllowGet));
 }
Beispiel #6
0
 public JsonResult UpdateExistingSection(Section section)
 {
     return(Json(DBInterfacer.UpdateExistingSection(section)));
 }
Beispiel #7
0
        public JsonResult GetSections()
        {
            var sections = DBInterfacer.GetSections();

            return(Json(sections, JsonRequestBehavior.AllowGet));
        }
Beispiel #8
0
        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"));
        }
Beispiel #9
0
 public JsonResult ChangePassword(String newPassword)
 {
     return(Json(DBInterfacer.SetPassword((Session["username"] ?? TEST_STUDENT_USER).ToString(), newPassword), JsonRequestBehavior.AllowGet));
 }
Beispiel #10
0
 public JsonResult ViewRecord()
 {
     return(Json(DBInterfacer.GetRecord((Session["username"] ?? TEST_STUDENT_USER).ToString()), JsonRequestBehavior.AllowGet));
 }
Beispiel #11
0
 public JsonResult SaveSequence(Sequence sequence)
 {
     return(Json(DBInterfacer.SaveSequence((Session["username"] ?? TEST_STUDENT_USER).ToString(), sequence), JsonRequestBehavior.AllowGet));
 }
Beispiel #12
0
 public JsonResult TestEchoUsernameFromDB()
 {
     return(Json(DBInterfacer.GetUser((Session["username"] ?? TEST_STUDENT_USER).ToString()).UserName, JsonRequestBehavior.AllowGet));
 }
Beispiel #13
0
 public JsonResult TestGetSections()
 {
     return(Json(DBInterfacer.GetSections(), JsonRequestBehavior.AllowGet));
 }
Beispiel #14
0
 public JsonResult TestGetCourses()
 {
     return(Json(DBInterfacer.GetCourses().Count, JsonRequestBehavior.AllowGet));
 }
Beispiel #15
0
 public JsonResult GetSavedPreferences(Student.Preference prefs)
 {
     return(Json(DBInterfacer.GetSavedPreferences((Session["username"] ?? TEST_STUDENT_USER).ToString()), JsonRequestBehavior.AllowGet));
 }