public async Task <IEnumerable <Model.Section> > GetSectionsAsync( Model.Menu menu, [ScopedService] ApplicationDbContext dbContext, SectionByIdDataLoader sectionById, CancellationToken cancellationToken) { Guid[] sectionIds = await dbContext.Sections .Where(s => s.MenuId == menu.Id) .OrderBy(s => s.DisplayOrder) .Select(s => s.Id) .ToArrayAsync(cancellationToken); return(await sectionById.LoadAsync(sectionIds, cancellationToken)); }
public async Task <Model.Section> GetSectionByIdAsync( Guid id, SectionByIdDataLoader dataLoader, CancellationToken cancellationToken) { Model.Section section = await dataLoader.LoadAsync(id, cancellationToken); if (section == null) { var extensions = new Dictionary <string, object?>() { { "code", "9001" }, { "id", id } }; Error error = new("Invalid id", extensions : extensions); throw new QueryException(error); } return(section); }