Exemple #1
0
 public ActionResult Delete(int id)
 {
     using (var ctx = new ChinookEntities())
     {
         var artist = ctx.Artists.Single(t => t.ArtistId == id);
         ctx.Artists.Remove(artist);
         ctx.SaveChanges();
         return RedirectToAction("Index");
     }
 }
Exemple #2
0
 public ActionResult Edit(Artist artist)
 {
     using (var ctx = new ChinookEntities())
     {
         var a = ctx.Artists.Single(t => t.ArtistId == artist.ArtistId);
         a.Name = artist.Name;
         ctx.SaveChanges();
         return RedirectToAction("Index");
     }
 }
Exemple #3
0
 public ActionResult Create(Artist artist)
 {
     using (var ctx = new ChinookEntities())
     {
         var id = ctx.Artists.OrderByDescending(t => t.ArtistId).First().ArtistId;
         artist.ArtistId = ++id;
         ctx.Artists.Add(artist);
         ctx.SaveChanges();
         return RedirectToAction("Index");
     }
 }