示例#1
0
 public ActionResult Create()
 {
     var album = new Album();
     ViewBag.ArtistId = new SelectList(ctx.Artists.ToList(), "ArtistId", "Name");
     ViewBag.StudentName = "Sriram";
     return View(album);
 }
示例#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");
        }
示例#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");
 }
示例#4
0
 public ActionResult UpdateAlbum(Album album)
 {
     return Content("Updated");
 }