// GET: AlbumModels public ActionResult Index() { var album = db.Album.Include(a => a.Singer).ToList(); ICollection <AlbumModel> albumModels = new List <AlbumModel>(); AlbumBinder albumBinder = new AlbumBinder(); albumModels = albumBinder.Bind(album); return(View(albumModels)); }
// GET: AlbumModels public ActionResult GetAlbumsBySingerId(int singerId) { var album = db.Album.Where(s => s.Singer.Id == singerId).ToList(); ICollection <AlbumModel> albumModels = new List <AlbumModel>(); AlbumBinder albumBinder = new AlbumBinder(); albumModels = albumBinder.Bind(album); return(View("Index", albumModels)); }
public ActionResult Edit([Bind(Include = "Id,Name,UploadDate,SingerId")] AlbumModel albumModel) { if (ModelState.IsValid) { AlbumBinder albumBinder = new AlbumBinder(); Album album = albumBinder.Bind(albumModel); db.Entry(album).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SingerId = new SelectList(db.Singer, "Id", "Name", albumModel.SingerId); return(View(albumModel)); }