示例#1
0
 // GET api/values/5
 public Artist Get(string id)
 {
     using (DzalekaArtistEntities music = new DzalekaArtistEntities())
     {
         return(music.Artists.FirstOrDefault(e => e.ArtistId == id));
     }
 }
示例#2
0
 // GET api/values
 public IEnumerable <Artist> Get()
 {
     using (DzalekaArtistEntities accessor = new DzalekaArtistEntities())
     {
         return(accessor.Artists.ToList());
     }
 }
示例#3
0
 // DELETE api/values/5
 public void Delete(string id)
 {
     using (DzalekaArtistEntities m = new DzalekaArtistEntities())
     {
         m.Artists.Remove(m.Artists.FirstOrDefault(x => x.ArtistId == id));
         m.SaveChanges();
     }
 }
示例#4
0
        // PUT api/values/5
        public void Put(string id, [FromBody] Artist musician)
        {
            using (DzalekaArtistEntities art = new DzalekaArtistEntities())
            {
                Artist m = art.Artists.FirstOrDefault(e => e.ArtistId == id);

                art.Artists.Add(musician);
                art.SaveChanges();
            }
        }
示例#5
0
 // POST api/values
 public void Post([FromBody] Artist musician)
 {
     using (DzalekaArtistEntities art = new DzalekaArtistEntities())
     {
         //var a = art.Set<music>();
         //a.Add(musician);
         //musician.ID = Guid.NewGuid();
         art.Artists.Add(musician);
         art.SaveChanges();
     }
 }