//public ActionResult Create(FormCollection collection) public ActionResult Create(Album album) { try { // TODO: Add insert logic here storeDB.AddToAlbums(album); storeDB.SaveChanges(); //return RedirectToAction("Index"); return RedirectToAction("/"); } catch { // Invalid - ReDisplay with Errors var viewModel = new StoreManagerViewModel { Album = album, Artists = storeDB.Artists.ToList(), Genres = storeDB.Genres.ToList() }; return View(); } }
/// <summary> /// Create a new Album object. /// </summary> /// <param name="albumId">Initial value of the AlbumId property.</param> /// <param name="genreId">Initial value of the GenreId property.</param> /// <param name="artistId">Initial value of the ArtistId property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="price">Initial value of the Price property.</param> public static Album CreateAlbum(global::System.Int32 albumId, global::System.Int32 genreId, global::System.Int32 artistId, global::System.String title, global::System.Decimal price) { Album album = new Album(); album.AlbumId = albumId; album.GenreId = genreId; album.ArtistId = artistId; album.Title = title; album.Price = price; return album; }
// // GET: /Store/Detail/5 /* public string Detail(string name, int value) { return "detail: name = " + name + " & value = " + value; } // */ public ActionResult Detail(int id) { var album = new Album { Title = "Sample Album" }; return View(album); }
/// <summary> /// Deprecated Method for adding a new object to the Albums EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToAlbums(Album album) { base.AddObject("Albums", album); }