public async Task <IActionResult> GetAllLevelByCourseId(CancellationToken cancellationToken, Guid CourseId) { var search = Query <TrainingBuildCourse> .Create(x => x.CourseId == CourseId); var query = new EntityQuery <TrainingBuildCourse>(search, 1, int.MaxValue, string.Empty); var command = new LevelCourseReadCommand <TrainingBuildCourse>(query, CourseId); var result = await Mediator.Send(command, cancellationToken).ConfigureAwait(false); return(new OkObjectResult(new { Data = result, Status = StatusCodes.Status200OK })); }
protected override async Task <EntityListResult <LevelReadModel> > ProcessAsync(LevelCourseReadCommand <Core.Data.Entities.TrainingBuildCourse> message, CancellationToken cancellationToken) { var entityQuery = message.EntityQuery; var query = await _dataContext.TrainingBuildCourses .Include(x => x.Course) .ThenInclude(x => x.Training) .Include(x => x.Question) .Include(x => x.Level) .ThenInclude(x => x.Subjects) .Where(x => x.CourseId == message.CourseId) .ToListAsync(cancellationToken) .ConfigureAwait(false); var question = await _dataContext.LevelQuestions .Include(x => x.CourseLevel) .ToListAsync(cancellationToken) .ConfigureAwait(false); foreach (var origitem in question) { foreach (var subitem in query) { } } if (query.Count() == 0) { return new EntityListResult <LevelReadModel> { Data = _emptyList.Value } } ; var map = ExistsTraining(query); return(new EntityListResult <LevelReadModel> { Total = map.Count(), Data = map.AsReadOnly() }); }