public ActionResult CreateForm()
        {
            ViewData["H1"] = "New Magasin";

            var viewModel = new viewGenreModel
            {
                GenreList = _contextDb.GenreList.ToList(),
            };

            return(View(viewModel));
        }
        public ActionResult Edit(int id)
        {
            ViewData["H1"] = "Edit Magasin";

            var magasin = _contextDb.Magasins.SingleOrDefault(c => c.Id == id);

            if (magasin == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new viewGenreModel
            {
                magasin   = magasin,
                GenreList = _contextDb.GenreList.ToList()
            };

            return(View("CreateForm", viewModel));
        }
        public ActionResult Save(viewGenreModel NewMagasin)                            //---> Start here Complete the saving function and You are Done for Day:::
        {
            if (NewMagasin.magasin.Id == 0)
            {
                _contextDb.Magasins.Add(NewMagasin.magasin);
            }
            else
            {
                var magasinDb = _contextDb.Magasins.Single(c => c.Id == NewMagasin.magasin.Id);

                magasinDb.Name         = NewMagasin.magasin.Name;
                magasinDb.RealeaseDate = NewMagasin.magasin.RealeaseDate;
                magasinDb.DataAdd      = NewMagasin.magasin.DataAdd;
                magasinDb.InStock      = NewMagasin.magasin.InStock;
                magasinDb.GenreId      = NewMagasin.magasin.GenreId;
            }
            _contextDb.SaveChanges();

            return(RedirectToAction("Index", "Magasin"));
        }