private IQueryable <GalleryPic> GetBasePicQuery(GalleryPicsListQueryOptions options) { var query = Context.GalleryPics.Include(x => x.Game) .Include(x => x.Developer) .Include(x => x.Cat).AsQueryable(); if (!options.WithUnPublishedPictures) { query = query.Where(x => x.Pub == 1); } return(query); }
public async Task <(IEnumerable <GalleryPic> models, int totalCount)> GetPics(GalleryPicsListQueryOptions options) { var query = GetBasePicQuery(options); if (options.Parent != null) { query = ApplyParentCondition(query, options.Parent); } if (options.Cat != null) { query = query.Where(x => x.CatId == options.Cat.Id); } var data = await GetDataAsync(query, options); foreach (var pic in data.models) { await ProccessPicAsync(pic, options.LoadPicPosition); } return(data); }