public ActionResult Create(Album album)
        {
            if (ModelState.IsValid)
            {
                db.Albums.Add(album);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId);
            ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId);
            return View(album);
        }
Ejemplo n.º 2
0
 public int CreateAlbum(Album album)
 {
     _context.Albums.Add(album);
     return(_context.SaveChanges());
 }
 public ActionResult Edit(Album album)
 {
     if (ModelState.IsValid)
     {
         db.Entry(album).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId);
     ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId);
     return View(album);
 }
Ejemplo n.º 4
0
 public ActionResult Details(int id)
 {
     var album = new Album { Title = "Album" + id };
     return View(album);
 }