public async Task <ApiResponse <ExamsAllViewModel> > Handle(AllExamsQuery request, CancellationToken cancellationToken) { var exams = await dbContext.SchoolSubjects .Select(x => new ExamViewModel(null, ExamTypeExtensions.ReverseParseStr(x.Name), x.Name, 0)).ToListAsync(); ExamsAllViewModel vm = new ExamsAllViewModel(exams); return(ApiResponse <ExamsAllViewModel> .Success(vm)); }
public async Task <ApiResponse <ExamsAllBySubjectListViewModel> > Handle(ExamsAllBySubjectQuery request, CancellationToken cancellationToken) { ExamType examType = (ExamType)Enum.Parse(typeof(ExamType), request.ExamTypeUrl); IEnumerable <ExamViewModel> exams = await dbContext.Exams.AsNoTracking() .Where(x => x.ExamType == examType) .OrderBy(e => e.YearOfCreation) .Select(x => new ExamViewModel(x.Id, x.ExamType.ToString(), ExamTypeExtensions.Parse(x), x.YearOfCreation)) .ToListAsync(); ExamsAllBySubjectListViewModel vm = new ExamsAllBySubjectListViewModel(exams); return(ApiResponse <ExamsAllBySubjectListViewModel> .Success(vm)); }