public ActionResult Create([Bind(Include = "GenreId,GenreName")] Genre genre) { if (ModelState.IsValid) { db.Genres.Add(genre); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(genre)); }
public ActionResult Create([Bind(Include = "SongId,SongTitle,AlbumRefId")] Song song) { if (ModelState.IsValid) { db.Songs.Add(song); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AlbumRefId = new SelectList(db.Albums, "AlbumId", "AlbumArtistName", song.AlbumRefId); return(View(song)); }
public ActionResult Create([Bind(Include = "AlbumId,AlbumArtistName,AlbumTitle,AlbumLogo,GenreRefId")] Album album) { if (ModelState.IsValid) { db.Albums.Add(album); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GenreRefId = new SelectList(db.Genres, "GenreId", "GenreName", album.GenreRefId); return(View(album)); }
static void Main(string[] args) { using (var db = new AlbumsContext()) { var albums = new Album { AlbumName = "Album nou" }; db.Albums.Add(albums); db.SaveChanges(); var query = from b in db.Albums orderby b.AlbumName select b; Console.WriteLine("All albums in database"); foreach (var item in query) { Console.WriteLine(item.AlbumName); } Console.WriteLine("Press any key to exit"); Console.ReadKey(); } }