public ActionResult GetExamScores()
        {
            var examManager     = service.UnitOfWork.Exams;
            var scheduleManager = service.UnitOfWork.Schedules;

            var examList     = examManager.Get(x => x.IsActive == false);
            var scheduleList = scheduleManager.Get(x => x.IsActive == true);

            ViewBag.Schedules = scheduleList;
            var models = new List <ExamsGetVm>();

            foreach (var exam in examList)
            {
                var examStartTime = $"{exam.ExamDate.ToString("HH:mm")}";
                var model         = new ExamsGetVm
                {
                    Exam          = exam,
                    ExamStartTime = examStartTime,
                    DayName       = Converter.DayConverter(exam.ExamDate.DayOfWeek),
                    ScheduleName  = scheduleList.Where(x => x.StartTime == examStartTime).FirstOrDefault().Name,
                };
                models.Add(model);
            }
            return(View(models));
        }
Ejemplo n.º 2
0
        public ActionResult GetExams(int?selectedGroupId = 1)
        {
            if (HttpContext.User.IsInRole("student"))
            {
                var userManager      = service.UnitOfWork.Members.Users;
                var currentStudentId = userManager.FindByName(HttpContext.User.Identity.Name).Id;
                selectedGroupId = service.UnitOfWork.StudentGroups.Get(x => x.StudentId == currentStudentId).SingleOrDefault().GroupId;
            }
            var examManager      = service.UnitOfWork.Exams;
            var timeTableManager = service.UnitOfWork.TimeTables;
            var groupManager     = service.UnitOfWork.Groups;

            var       lessonList   = service.UnitOfWork.Lessons.Get(x => x.IsActive == true);
            var       groupList    = groupManager.Get(x => x.IsActive == true);
            var       examList     = examManager.Get(x => x.GroupId == selectedGroupId);
            var       scheduleList = service.UnitOfWork.Schedules.Get(x => x.IsActive == true);
            Converter Converter    = new Converter();

            ViewBag.Lessons         = lessonList;
            ViewBag.Groups          = groupList;
            ViewBag.Days            = service.UnitOfWork.Days.Get();
            ViewBag.Schedules       = scheduleList;
            ViewBag.selectedGroupId = selectedGroupId;
            ViewBag.TimeTables      = timeTableManager.Get(x => x.GroupId == selectedGroupId);
            var models = new List <ExamsGetVm>();

            foreach (var exam in examList)
            {
                var examStartTime = $"{exam.ExamDate.ToString("HH:mm")}";
                var model         = new ExamsGetVm
                {
                    Exam          = exam,
                    ExamStartTime = examStartTime,
                    DayName       = Converter.DayConverter(exam.ExamDate.DayOfWeek),
                    ScheduleName  = scheduleList.Where(x => x.StartTime == examStartTime).FirstOrDefault().Name,
                };
                models.Add(model);
            }
            return(View(models));
        }