Ejemplo n.º 1
0
        public ActionResult AddMovie(MovyEntity movy)
        {
            List <SelectListItem> genreList = GenreBL.ViewAllGenreBL().Select(n => new SelectListItem {
                Value = n.GenreId.ToString(), Text = n.GenreName
            }).ToList();;

            var genreTip = new SelectListItem()
            {
                Value = null,
                Text  = "--- select genre ---"
            };

            genreList.Insert(0, genreTip);
            ViewBag.generList = new SelectList(genreList, "Value", "Text");

            List <SelectListItem> languageList = LanguageBL.ViewAllLanguageBL().Select(n => new SelectListItem {
                Value = n.LanguageId.ToString(), Text = n.LanguageName
            }).ToList();;

            var languageTip = new SelectListItem()
            {
                Value = null,
                Text  = "--- select  Language ---"
            };

            languageList.Insert(0, languageTip);
            ViewBag.langList = new SelectList(languageList, "Value", "Text");
            bool isAdded = false;

            if (ModelState.IsValid)
            {
                isAdded = MovieBL.AddMovieBL(movy);
                if (isAdded)
                {
                    return(RedirectToAction("Index"));
                }
            }


            return(View(movy));
        }