Some api work

This commit is contained in:
Joseph Milazzo 2020-12-20 17:47:18 -06:00
parent b6e0e05205
commit 8156aeb495
9 changed files with 82 additions and 64 deletions

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using API.DTOs;
using API.Entities;
@ -41,5 +42,12 @@ namespace API.Data
{
return await _context.Library.AnyAsync(x => x.Name == libraryName);
}
public async Task<IEnumerable<LibraryDto>> GetLibrariesForUserAsync(AppUser user)
{
return await _context.Library.Where(library => library.AppUsers.Contains(user))
.Include(l => l.Folders)
.ProjectTo<LibraryDto>(_mapper.ConfigurationProvider).ToListAsync();
}
}
}