public async Task <bool> CreateAsync(CreateSongServiceModel model) { if (this.db.Songs.Any(s => s.Name == model.Name && s.Genre == model.Genre) || model == null) { return(false); } var song = new Song { Name = model.Name, Genre = model.Genre, UrlId = model.UrlId, AlbumId = model.AlbumId }; this.db.Songs.Add(song); await this.db.SaveChangesAsync(); return(true); }
public async Task <bool> EditAsync(int id, CreateSongServiceModel model) { if (model == null) { return(false); } var song = await this.db.Songs.SingleOrDefaultAsync(s => s.Id == id); if (song == null) { return(false); } song.Name = model.Name; song.AlbumId = model.AlbumId; song.Genre = model.Genre; song.UrlId = model.UrlId; this.db.Update(song); await this.db.SaveChangesAsync(); return(true); }