Пример #1
0
        public ActionResult StudentResults(int id)
        {
            var student = _context.Students.SingleOrDefault(s => s.Id == id);

            var currentResultSet = _context.ResultSets.SingleOrDefault(r => r.IsCurrent);

            var resultSets = _context.ResultSets.OrderBy(x => x.Name).ToList();

            var subjects = _context.Subjects.OrderBy(x => x.Name).ToList();

            if (student == null)
            {
                return(HttpNotFound());
            }

            if (currentResultSet == null)
            {
                return(Content("ERROR: No Current Result Set Found"));
            }


            var viewModel = new StudentResultsViewModel
            {
                Student            = student,
                CurrentResultSetId = currentResultSet.Id,
                ResultSets         = resultSets,
                Subjects           = subjects
            };

            return(View(viewModel));
        }
Пример #2
0
        public ActionResult Results()
        {
            var userId = User.Identity.GetUserId();

            var student = _context.Students.SingleOrDefault(s => s.UserId == userId);

            if (student == null)
            {
                return(HttpNotFound());
            }

            var resultSets = _context.ResultSets.ToList();

            var currentResultSet = _context.ResultSets.Single(x => x.IsCurrent);

            if (currentResultSet == null)
            {
                return(Content("No result sets exist in database"));
            }

            var currentResultSetId = currentResultSet.Id;

            var viewModel = new StudentResultsViewModel
            {
                Student            = student,
                ResultSets         = resultSets,
                CurrentResultSetId = currentResultSetId
            };

            return(View(viewModel));
        }
Пример #3
0
        public async Task <IActionResult> Results(string searchText, string searchCriteria, int page = 1, int countPerPage = PerPageDefaultValue)
        {
            var studentId = this.userManager.GetUserId(this.User);
            var model     = new StudentResultsViewModel()
            {
                CurrentPage  = page,
                PagesCount   = 0,
                SearchType   = searchCriteria,
                SearchString = searchText,
            };

            var allResultsCount = await this.resultService.GetResultsCountByStudentIdAsync(studentId, searchCriteria, searchText);

            if (allResultsCount > 0)
            {
                var results = await this.resultService.GetPerPageByStudentIdAsync <StudentResultViewModel>(studentId, page, countPerPage, searchCriteria, searchText);

                var timeZoneIana = this.Request.Cookies[GlobalConstants.Coockies.TimeZoneIana];
                foreach (var result in results)
                {
                    result.Date = this.dateTimeConverter.GetDate(result.EventActivationDateAndTime, timeZoneIana);
                }

                model.PagesCount = (int)Math.Ceiling(allResultsCount / (decimal)countPerPage);
                model.Results    = results;
            }

            return(this.View(model));
        }