public ActionResult Add(int id) { AlbumDesc desc = new AlbumDesc() { Album = db.Albums.Find(id) }; ViewBag.Languages = db.Languages; return View(desc); }
// GET: /AlbumDesc/Create public ActionResult Create() { AlbumDesc desc = new AlbumDesc() { Album = new Album() { CreationDate = DateTime.Now, UID = Guid.NewGuid() } }; ViewBag.Languages = db.Languages; return View(desc); }
public ActionResult Add(AlbumDesc albumdesc) { try { albumdesc.Language = db.Languages.Find(albumdesc.Language.Id); albumdesc.Album = db.Albums.Find(albumdesc.Album.Id); db.AlbumDescs.Add(albumdesc); db.SaveChanges(); return RedirectToAction("Details", "Album", new { id = albumdesc.Album.Id }); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); ViewBag.Languages = db.Languages; return View(albumdesc); } }
public ActionResult Edit(AlbumDesc albumdesc) { if (ModelState.IsValid) { db.Entry(albumdesc).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return RedirectToAction("Details", "Album", new { id = albumdesc.Album.Id }); } return View(albumdesc); }