示例#1
0
        public ActionResult Edit(Guid id)
        {
            var model = new MovieCreateEditViewModel()
            {
                Genres = this._genresSvc.GetGenres(),
                Movie  = this._moviesSvc.GetMovieById(id)
            };

            return(View(model));
        }
示例#2
0
        public ActionResult Edit(MovieCreateEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                this._moviesSvc.EditMovie(model.Movie);

                return(RedirectToAction("Index"));
            }

            model.Genres = this._genresSvc.GetGenres();

            return(View(model));
        }
示例#3
0
        public ActionResult Create(string movieName)
        {
            if (!string.IsNullOrEmpty(movieName))
            {
                ViewBag.MovieName = movieName;
            }

            var model = new MovieCreateEditViewModel()
            {
                Genres = this._genresSvc.GetGenres()
            };

            return(View(model));
        }
        public ActionResult Create(MovieCreateEditViewModel model, string submitCommand)
        {
            if (ModelState.IsValid)
            {
                this._moviesSvc.AddMovie(model.Movie);

                if (submitCommand.Equals("Save"))
                {
                    return(RedirectToAction("Index", new { movieName = model.Movie.Name }));
                }
                else
                {
                    return(RedirectToAction("Create", new { movieName = model.Movie.Name }));
                }
            }

            model.Genres = this._genresSvc.GetGenres();

            return(View(model));
        }
示例#5
0
        public ActionResult Create(MovieCreateEditViewModel model, string submitCommand)
        {
            //ModelState.AddModelError(string.Empty, "The movie already exists!");
            if (ModelState.IsValid)
            {
                model.Movie.Id = Guid.NewGuid();
                this._moviesSvc.AddMovie(model.Movie);

                if (submitCommand.Equals("Save"))
                {
                    return(RedirectToAction("Index", new { movieName = model.Movie.Name }));
                }
                else
                {
                    return(RedirectToAction("Create", new { movieName = model.Movie.Name }));
                }
            }

            model.Genres = this._genresSvc.GetGenres();

            return(View(model));
        }