示例#1
0
        // 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;
            }
        }
示例#2
0
        // 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];
            }

        }
示例#3
0
 // 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);
             }
         }
     }
 }