public async Task <CollectionDetails> GetByIdAsync(Guid id, Guid userId) { using (var scope = ServiceScopeFactory.CreateScope()) { var dbContext = GetDatabaseContext(scope); var query = new UserCollectionDetailsQuery(userId); var collection = await query.Run(dbContext).FirstOrDefaultAsync(); return(collection); } }
public async Task <ICollection <CollectionDetails> > GetManyByUserIdAsync(Guid userId) { using (var scope = ServiceScopeFactory.CreateScope()) { var dbContext = GetDatabaseContext(scope); var query = new UserCollectionDetailsQuery(userId).Run(dbContext); var data = await query.ToListAsync(); return(data.GroupBy(c => c.Id).Select(c => c.First()).ToList()); } }