// PUT api/music/5 public void Put(int id, [FromBody]ASPNET_HW.Models.Artist value) { using (var db = new MusicDBEntities()) { foreach (var art in db.Artists) { data.Add(new ASPNET_HW.Models.Artist() { Name = art.ArtistName, Country = art.Country, DateOfBirth = art.DateOfBirth }); } data[id] = value; } }
// GET api/music/5 public ASPNET_HW.Models.Artist Get(int id) { using (var db = new MusicDBEntities()) { foreach (var art in db.Artists) { data.Add(new ASPNET_HW.Models.Artist() { Name = art.ArtistName, Country = art.Country, DateOfBirth = art.DateOfBirth }); } return data[id]; } }
// DELETE api/music/5 public void Delete(int id) { using (var db = new MusicDBEntities()) { foreach (var artist in db.Artists) { if (artist.Id == id) { db.Artists.Remove(artist); } } } }