public ActionResult Create(Album album) { // TODO: Add insert logic here try { // TODO: Add insert logic here storeDB.AddToAlbums(album); storeDB.SaveChanges(); //return RedirectToAction("Index"); return Redirect("/"); } catch { // Invalid - redisplay with errors var viewModel = new StoreManagerViewModel { Album = album, Genres = storeDB.Genres.ToList(), Artists = storeDB.Artists.ToList() }; return View(viewModel); } }
/// <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; }
/// <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); }