예제 #1
0
 // PUT: api/Song/5
 public bool UpdateSong(int id, SongInfo value)
 {
     using (var context = Context)
     {
         var existing = context.Songs.SingleOrDefault(d => d.Key == id);
         existing?.Update(value);
         context.SaveChanges();
         return existing != null;
     }
 }
예제 #2
0
 // POST: api/Song
 public int AddSong(SongInfo value)
 {
     using (var context = Context)
     {
         var song = new Song { Name = value.Name, Text = value.Line };
         context.Songs.Add(song);
         context.SaveChanges();
         return song.Key;
     }
 }