public ActionResult Create([Bind(Include = "GenreId,GenreName")] Genre genre)
        {
            if (ModelState.IsValid)
            {
                db.Genres.Add(genre);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(genre));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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();
            }
        }