public virtual Task <T> ReadAsync([FromServices] IQueryHandler <InstanceQuery <T>, T> handler, [FromQuery] Guid id) { var query = new InstanceQuery <T>() { Id = id }; return(handler.HandleAsync(query)); }
public async Task <FactLesson> HandleAsync(InstanceQuery <FactLesson> query) { var lesson = await _context.Lessons.FirstOrDefaultAsync(x => x.Id == query.Id); if (lesson == default) { throw new ApplicationException($"Не удалось найти урок по id {query.Id}"); } return(lesson); }