コード例 #1
0
 public ActionResult Create(MovieEditPageViewModel viewModel)
 {
     try
     {
         var movie = new MovieRecord();
         movie.MovieTitle   = viewModel.MovieViewModel.MovieTitle;
         movie.Rating       = viewModel.MovieViewModel.Rating;
         movie.YearReleased = viewModel.MovieViewModel.YearReleased;
         _movieRecordRepository.Add(movie);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
コード例 #2
0
        public ActionResult Edit(MovieEditPageViewModel viewModel)
        {
            try
            {
                var movieModel = this._movieRecordRepository.Find(item => item.Id == viewModel.MovieViewModel.Id);
                movieModel.MovieTitle   = viewModel.MovieViewModel.MovieTitle;
                movieModel.Rating       = viewModel.MovieViewModel.Rating;
                movieModel.YearReleased = viewModel.MovieViewModel.YearReleased;
                this._movieRecordRepository.Update(movieModel);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
コード例 #3
0
        // GET: Movie/Create
        public ActionResult Create()
        {
            var viewModel = new MovieEditPageViewModel(new MovieRecord());

            return(View(viewModel));
        }