示例#1
0
        public async Task <int> CreateAsync(AlbumDTO album)
        {
            var entity = new Album
            {
                Title    = album.Title,
                ArtistId = album.ArtistId,
                Year     = album.Year,
                Cover    = album.Cover
            };

            _context.Albums.Add(entity);

            return(await _context.SaveChangesAsync());
        }
示例#2
0
        public async Task <bool> UpdateAsync(AlbumDTO album)
        {
            var entity = await _context.Albums.FindAsync(album.Id);

            if (entity == null)
            {
                return(false);
            }

            entity.Title    = album.Title;
            entity.ArtistId = album.ArtistId;
            entity.Year     = album.Year;
            entity.Cover    = album.Cover;

            await _context.SaveChangesAsync();

            return(true);
        }