예제 #1
0
        // GET: Person
        public ActionResult Index()
        {
            string userId    = User.Identity.GetUserId();
            var    userFound = context.People.Where(p => p.ApplicationId == userId).FirstOrDefault();

            if (userFound == null)
            {
                return(RedirectToAction("Create"));
            }

            BigIndexViewModel bigModel = new BigIndexViewModel();

            bigModel.currentUser = userFound;

            return(View(bigModel));
        }
예제 #2
0
        public ActionResult TeacherIndex()
        {
            string userId    = User.Identity.GetUserId();
            var    userFound = context.People.Where(p => p.ApplicationId == userId).FirstOrDefault();

            if (userFound == null)
            {
                return(RedirectToAction("Create"));
            }


            // maybe redirect if teacher not setup?

            //int preferencesCheck = context.Preferences.Where(p => p.teacherId == userFound.PersonId).Count();
            //int availsCheck = context.TeacherAvailabilities.Where(p => p.PersonId == userFound.PersonId).Count();

            //if (userFound.subjects == null || preferencesCheck == 0 || availsCheck == 0)
            //{
            //    return RedirectToAction("Index"); // redirect to index/ or info page
            //}


            List <Lesson> teacherLessons = context.Lessons
                                           .Include("Student")
                                           .Include("Location")
                                           .Where(lesson => lesson.teacherId == userFound.PersonId && lesson.teacherApproval == true && lesson.requiresMakeup == false && lesson.studentId != null).ToList();

            List <Lesson> lessonRequests = context.Lessons
                                           .Include("Student")
                                           .Include("Location")
                                           .Where(lesson => lesson.teacherId == userFound.PersonId && lesson.teacherApproval == false && lesson.requiresMakeup == false).ToList();

            List <Lesson> makeupLessons = context.Lessons
                                          .Include("Student")
                                          .Include("Location")
                                          .Where(lesson => lesson.teacherId == userFound.PersonId && lesson.requiresMakeup == true).ToList();

            BigIndexViewModel bigModel = new BigIndexViewModel();

            bigModel.teacherLessons     = teacherLessons;
            bigModel.requestsForTeacher = lessonRequests;
            bigModel.currentUser        = userFound;
            bigModel.makeups            = makeupLessons;

            return(View(bigModel));
        }
예제 #3
0
        public ActionResult StudentIndex()
        {
            string userId    = User.Identity.GetUserId();
            var    userFound = context.People.Where(p => p.ApplicationId == userId).FirstOrDefault();

            if (userFound == null)
            {
                return(RedirectToAction("Create"));
            }
            List <PersonAndLocationViewModel> teachers = new List <PersonAndLocationViewModel>();
            List <Person> eligibleTeachers             = context.People.Where(s => s.subjects != null && s.PersonId != userFound.PersonId).ToList();

            foreach (Person teacher in eligibleTeachers)
            {
                PersonAndLocationViewModel info = new PersonAndLocationViewModel();
                info.person   = teacher;
                info.location = context.Locations.Where(l => l.LocationId == teacher.LocationId).Single();
                info.lessons  = context.Lessons.Where(lesson => lesson.teacherId == teacher.PersonId).ToList();
                info.avails   = context.TeacherAvailabilities.Where(av => av.PersonId == teacher.PersonId).ToList();
                teachers.Add(info);
            }
            List <Lesson> studentLessons = context.Lessons
                                           .Include("Teacher")
                                           .Include("Location")
                                           .Where(lesson => lesson.studentId == userFound.PersonId && lesson.teacherApproval == true && lesson.requiresMakeup == false).ToList();
            List <Lesson> lessonRequests = context.Lessons
                                           .Include("Student")
                                           .Include("Location")
                                           .Where(lesson => lesson.studentId == userFound.PersonId && lesson.teacherApproval == false && lesson.requiresMakeup == false).ToList();

            List <Lesson> makeupLessons = context.Lessons
                                          .Include("Teacher")
                                          .Include("Location")
                                          .Where(lesson => lesson.studentId == userFound.PersonId && lesson.requiresMakeup == true).ToList();

            BigIndexViewModel bigModel = new BigIndexViewModel();

            bigModel.teachersComp       = teachers;
            bigModel.studentLessons     = studentLessons;
            bigModel.currentUser        = userFound;
            bigModel.requestsForStudent = lessonRequests;
            bigModel.makeups            = makeupLessons;
            return(View(bigModel));
        }