#pragma warning disable 1998
        public async Task <List <ExamScheduleDatabaseModel> > GetByParameters(ExamScheduleParametersModel parameters)
#pragma warning restore 1998
        {
            try
            {
                if (parameters == null)
                {
                    throw new NotSupportedException();
                }

                var examScheduleDatabaseModels = _context.ExamSchedules
                                                 .Include(i => i.TeacherModel)
                                                 .Include(d => d.StudyGroupModel)
                                                 .ToList();

                var result = examScheduleDatabaseModels.Where(f =>
                                                              (f.CourseType == parameters.CourseTypeExam ||
                                                               f.CourseType == parameters.CourseTypeConsultation) &&
                                                              string.Equals(f.StudyGroupModel?.Name, parameters.StudyGroupModel.Name) &&
                                                              f.IsDeleted == false)
                             .ToList();

                return(result);
            }
            catch (Exception)
            {
                throw new NotSupportedException();
            }
        }
Ejemplo n.º 2
0
        public async Task <ExamScheduleViewModel> Get(ExamScheduleRequestModel requestModel)
        {
            try
            {
                _logger.LogInformation("Get: " + $"{requestModel?.GroupName}");

                if (requestModel == null)
                {
                    throw new NotSupportedException();
                }

                var parameters = new ExamScheduleParametersModel
                {
                    CourseTypeExam         = CourseType.ExamCourse,
                    CourseTypeConsultation = CourseType.СonsultationCourse,
                    StudyGroupModel        = new StudyGroupModel {
                        Name = requestModel.GroupName
                    }
                };

                var examScheduleList = await _examScheduleDatabaseService.GetByParameters(parameters);

                var examScheduleViewModel = PrepareViewModel(examScheduleList, requestModel);

                return(examScheduleViewModel);
            }
            catch (Exception ex)
            {
                _logger.LogError("GetExamSchedule Exception: " + ex);
                throw new NotSupportedException("Ошибка во время выполнения." + ex);
            }
        }