Exemplo n.º 1
0
        public ActionResult EditMovie(MovieAddEditModel model)
        {
            int movieId = model.MovieId;

            MovieDO     _movie     = MovieBL.GetMovie(movieId);
            MovieNameDO _movieName = MovieNameBL.GetAllDOByMovieID(movieId).SingleOrDefault(q => q.IsDefault == true);

            //MovieArchiveDO _movieArchive = MovieArchiveBL.GetAllDOByMovieID(movieId).SingleOrDefault();
            //if (_movieArchive == null) _movieArchive = new MovieArchiveDO() { MovieID = movieId };

            _movieName.LanguageID = ParseHelper.ToInt32(model.NameLanguageID);
            _movieName.Name       = model.MovieName.Name;

            //_movieArchive.ArchiveID = Parse.ToInt32(model.ArchiveID);
            //_movieArchive.Resolution = model.ArchiveResolution;
            //_movieArchive.FileExtension = model.ArchiveFileExtension;
            //_movieArchive.Path = model.MovieArchive.Path;

            //if imdbid is changed, we need to reset imdb things first.
            string previousImdbId = _movie.ImdbID;

            if (string.IsNullOrEmpty(previousImdbId) == false && model.Movie.ImdbID != previousImdbId)
            {
                MovieBL.ResetImdbInformation(model.MovieId);
                _movie        = MovieBL.GetMovie(movieId);
                _movie.ImdbID = model.Movie.ImdbID;
            }

            //save movie
            MovieBL.Save(_movie, UserID);
            //save the name
            MovieNameBL.Save(_movieName, UserID);
            //if (model.ArchiveExists == true)
            //{
            //    //save the archive
            //    MovieArchiveBL.Save(_movieArchive, UserID);
            //}

            switch (model.Submit)
            {
            case "SubmitAndNavigateToMovie":
                return(RedirectToAction("DetailView", "Movie", new { id = movieId }));

            case "SubmitAndClearForm":
            default:
                return(RedirectToAction("AddMovie"));
            }
        }