Exemplo n.º 1
0
 public ActionResult Edit(int Id)
 {
     using (var context = new MusicDatabaseContext())
     {
         var result = context.Albums.Where(a => a.ID == Id).FirstOrDefault();
         return View(result);
     }
 }
Exemplo n.º 2
0
        public ActionResult Delete(int id)
        {
            using (var context = new MusicDatabaseContext())
            {
                var record = context.Albums.Where(a => a.ID == id).FirstOrDefault();

                return View(record);
            }
        }
Exemplo n.º 3
0
        public ActionResult Create(Album album)
        {
            using (var context = new MusicDatabaseContext())
            {

                context.Albums.Add(album);
                context.SaveChanges();
                return RedirectToAction("Index");
            }
        }
Exemplo n.º 4
0
 public ActionResult Edit(Album album)
 {
     using (var context = new MusicDatabaseContext())
     {
         var record = context.Albums.Where(a => a.ID == album.ID).FirstOrDefault();
         if (record != null)
             record = album;
         context.SaveChanges();
         return RedirectToAction("Index");
     }
 }
Exemplo n.º 5
0
 //
 // GET: /Albums/
 public ActionResult Index()
 {
     using (var dbContext = new MusicDatabaseContext())
     {
         return View(dbContext.Albums.ToList());
     }
 }