Example #1
0
 public ActionResult Create()
 {
     var album = new Album();
     ViewBag.ArtistId = new SelectList(ctx.Artists.ToList(), "ArtistId", "Name");
     ViewBag.StudentName = "Sriram";
     return View(album);
 }
Example #2
0
        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");
        }
Example #3
0
 public ActionResult Edit(Album album)
 {
     Album result = ctx.Albums.Single(t => t.AlbumId == album.AlbumId);
     result.Title = album.Title;
     ctx.SaveChanges();
     return RedirectToAction("Index");
 }
Example #4
0
 public ActionResult UpdateAlbum(Album album)
 {
     return Content("Updated");
 }