public async Task <AlbumDto> CreateAsync(AlbumDto item) { var result = _context.Albums.Add(AlbumConverter.Convert(item)); await _context.SaveChangesAsync(); return(AlbumConverter.Convert(result.Entity)); }
public async Task <List <AlbumViewModel> > GetAlbumByArtistIdAsync(int id, CancellationToken ct = default(CancellationToken)) { var albums = AlbumConverter.ConvertList(await _albumRepository.GetByArtistIdAsync(id, ct)); return(albums); }
public async Task <AlbumDto> GetByIdAsync(Guid id) { var album = AlbumConverter.Convert(await _context.Albums.FindAsync(id)); album.ArtistName = _artistRepo.GetByIdAsync(id).Result.Name; return(album); }
public async Task <AlbumViewModel> GetAlbumByIdAsync(int id, CancellationToken ct = default(CancellationToken)) { var albumViewModel = AlbumConverter.Convert(await _albumRepository.GetByIdAsync(id, ct)); albumViewModel.ArtistName = _artistRepository.GetByIdAsync(albumViewModel.ArtistId, ct).Result.Name; return(albumViewModel); }
public async Task <bool> UpdateAsync(AlbumDto item) { if (item == null) { return(false); } _context.Albums.Update(AlbumConverter.Convert(item)); await _context.SaveChangesAsync(); return(true); }
public async Task <IActionResult> Get() { try { return(Ok( AlbumConverter.ConvertList( await _context.Album .Include(a => a.Artist) .ToListAsync() ) )); } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(StatusCode(500, ex.Message)); } }
public async Task <IActionResult> GetByArtistId(int id) { try { var albums = await _context.Album.Where(a => a.ArtistId == id).ToListAsync(); if (albums == null) { return(NotFound()); } return(Ok(AlbumConverter.ConvertList(albums))); } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(StatusCode(500, ex)); } }
public async Task <IActionResult> Get(int id) { try { var album = await _context.Album .Where(a => a.AlbumId == id) .Include(a => a.Artist) .Include(a => a.Tracks) .FirstOrDefaultAsync(); if (album == null) { return(NotFound()); } return(Ok(AlbumConverter.Convert(album))); } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(StatusCode(500, ex)); } }
public async Task <List <AlbumDto> > GetAllAsync() { return(AlbumConverter.Convert( await _context.Albums.ToListAsync())); }
public async Task <AlbumDto> GetById(Guid id) { return(AlbumConverter.Convert(await _context.Albums.FindAsync(id))); }
public async Task <List <TrackDto> > GetTracksByAlbum(Guid id) //Поиск трэков по альбому { var album = AlbumConverter.Convert(await _context.Albums.FindAsync(id)); return(album.Tracks); }
public async Task <AlbumDto> GetBySearch(string artistname) { var albums = AlbumConverter.Convert(await _context.Albums.FindAsync(artistname)); return(albums); }