示例#1
0
        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));
        }
示例#2
0
        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);
        }