public void Create(DalSong entity) { Song song = new Song() { Id = entity.Id, Name = entity.Name, AudioFile = entity.AudioFile, GenreId = entity.GenreId, Year = entity.Year }; _context.Set<Song>().Add(song); }
public void Delete(DalSong entity) { Song song = new Song() { Id = entity.Id, Name = entity.Name, AudioFile = entity.AudioFile, GenreId = entity.GenreId, Year = entity.Year }; song = _context.Set<Song>().Single(s => s.Id == song.Id); _context.Set<Song>().Remove(song); }
public void Update(DalSong entity) { Song song = new Song() { Id = entity.Id, Name = entity.Name, AudioFile = entity.AudioFile, GenreId = entity.GenreId, Year = entity.Year }; if (song.AudioFile == null) { song.AudioFile = _context.Set<Song>().First(s => s.Id == entity.Id).AudioFile; } _context.Set<Song>().AddOrUpdate(song); }