public async Task <ArtistDto> CreateAsync(ArtistDto item) { var result = _context.Artist.Add(ArtistConverter.Convert(item)); await _context.SaveChangesAsync(); return(ArtistConverter.Convert(result.Entity)); }
public async Task <ArtistViewModel> GetArtistByIdAsync(int id, CancellationToken ct = default(CancellationToken)) { var artistViewModel = ArtistConverter.Convert(await _artistRepository.GetByIdAsync(id, ct)); artistViewModel.Albums = await GetAlbumByArtistIdAsync(artistViewModel.ArtistId, ct); return(artistViewModel); }
public async Task <List <TrackDto> > GetByArtist(Guid id) //Поиск трэков по исполнителю { var artist = ArtistConverter.Convert(await _context.Artists.FindAsync(id)); List <TrackDto> tracks = new List <TrackDto>(); var track = TrackConverter.Convert(await _context.Tracks.FindAsync(id)); tracks = TrackConverter.Convert(_context.Tracks.Where(x => x.ArtistId == artist.Id).ToList()); return(tracks); }
public async Task <bool> UpdateAsync(ArtistDto item) { if (item == null) { return(false); } _context.Artist.Update(ArtistConverter.Convert(item)); await _context.SaveChangesAsync(); return(true); }
public static AlbumViewModel Convert(Album album) { var albumViewModel = new AlbumViewModel { AlbumId = album.AlbumId, ArtistId = album.ArtistId, Title = album.Title, ArtistName = album.Artist?.Name, Artist = album.Artist == null ? null : ArtistConverter.Convert(album.Artist), Tracks = album.Tracks == null ? null : TrackConverter.ConvertList(album.Tracks.OrderBy(t => t.TrackId)) }; return(albumViewModel); }
public async Task <ArtistDto> GetByIdAsync(Guid id) { return(ArtistConverter.Convert(await _context.Artist.FindAsync(id))); }
public async Task <List <ArtistDto> > GetAllAsync() { return(ArtistConverter.Convert(await _context.Artist.ToListAsync())); }
public async Task <List <AlbumDto> > GetAlbumsByArtist(Guid id) //Поиск альбома по id артиста { var artist = ArtistConverter.Convert(await _context.Artists.FindAsync(id)); //Находим артиста по id return(artist.Albums); }
public async Task <List <ArtistViewModel> > GetAllArtistAsync(CancellationToken ct = default(CancellationToken)) { var artists = ArtistConverter.ConvertList(await _artistRepository.GetAllAsync(ct)); return(artists.ToList()); }