public async Task <GetCategoryByIdResponse> Handle(GetCategoryByIdRequest request) { return(new GetCategoryByIdResponse() { Category = CategoryApiModel.FromCategory(await _context.Categories .Include(x => x.Tenant) .SingleAsync(x => x.Id == request.Id && x.Tenant.UniqueId == request.TenantUniqueId)) }); }
public async Task <GetCategoriesResponse> Handle(GetCategoriesRequest request) { var categories = await _context.Categories .Include(x => x.Tenant) .Where(x => x.Tenant.UniqueId == request.TenantUniqueId) .ToListAsync(); return(new GetCategoriesResponse() { Categories = categories.Select(x => CategoryApiModel.FromCategory(x)).ToList() }); }