Example #1
0
 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);
 }
Example #2
0
 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);
 }
Example #3
0
        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);
        }