Exemple #1
0
        protected virtual FacultyModel GetDeaneryFaculty(string email)
        {
            var account = AccountManager.GetByEmail(email);
            var deanery = DeaneryManager.GetById(account.ReferenceId);
            var faculty = FacultyManager.GetById(deanery.FacultyId);

            return(faculty);
        }
        protected virtual IndexPageViewModel CreateIndexPageViewModel(int page, SheetFilterViewModel filter = null)
        {
            var model       = new IndexPageViewModel();
            var claim       = User.Claims.FirstOrDefault(x => x.Type.Equals(Constants.Claims.ReferenceId));
            var deanery     = DeaneryManager.GetById(claim.Value);
            var sheetFilter = CreateFilter(filter, deanery.FacultyId);
            var totalCount  = ExamSheetManager.GetTotal(sheetFilter);

            model.Page       = new PageViewModel(totalCount, page, PageSize);
            model.ExamSheets = ExamSheetManager.FindAll(sheetFilter, page, PageSize).Select(ExamSheetListViewModel).ToList();
            model.Filter     = CreateFilterModel(deanery.FacultyId, filter);
            return(model);
        }
        public IActionResult Subjects()
        {
            var referenceId = User.Claims.FirstOrDefault(x => x.Type.Equals(Constants.Claims.ReferenceId));
            var deanery     = DeaneryManager.GetById(referenceId.Value);
            var sheets      = ExamSheetManager.FindClosedForFaculty(deanery.FacultyId);
            var subjectsIds = sheets.Select(x => x.SubjectId).Distinct().ToList();
            var subjects    = SubjectManager.GetByIdList(subjectsIds);
            var model       = new SubjectStatisticViewModel();

            model.SubjectList = new List <SelectListItem>();
            foreach (var subject in subjects)
            {
                model.SubjectList.Add(new SelectListItem()
                {
                    Text = subject.Name, Value = subject.Id
                });
            }
            model.FacultyId = deanery.FacultyId;
            return(View(model));
        }
        public IActionResult Index()
        {
            var referenceId = User.Claims.FirstOrDefault(x => x.Type.Equals(Constants.Claims.ReferenceId));
            var model       = new GroupStatisticViewModel();

            if (User.IsInRole(AccountType.Deanery))
            {
                var deanery = DeaneryManager.GetById(referenceId.Value);
                var sheets  = ExamSheetManager.FindClosedForFaculty(deanery.FacultyId);
                model = CreateGroupStatisticViewModel(sheets);
            }
            else if (User.IsInRole(AccountType.Teacher))
            {
                var sheets = ExamSheetManager.FindClosedForTeacher(referenceId.Value);
                model           = CreateGroupStatisticViewModel(sheets);
                model.TeacherId = referenceId.Value;
            }

            return(View(model));
        }