public ActionResult Create() { var album = new Album(); ViewBag.ArtistId = new SelectList(ctx.Artists.ToList(), "ArtistId", "Name"); ViewBag.StudentName = "Sriram"; return View(album); }
public ActionResult Create(Album album) { if (album.ArtistId == 0) { return View(); } ctx.Albums.Add(album); int id = ctx.Albums.OrderByDescending(t => t.AlbumId).First().AlbumId; album.AlbumId = id + 1; ctx.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult Edit(Album album) { Album result = ctx.Albums.Single(t => t.AlbumId == album.AlbumId); result.Title = album.Title; ctx.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult UpdateAlbum(Album album) { return Content("Updated"); }