Ejemplo n.º 1
0
 public IActionResult Create(AddMovieView addMovieView)
 {
     if (ModelState.IsValid)
     {
         _movieService.Add(addMovieView.ToMovie(CurrentUserId));
         return RedirectToAction("Index");
     }
     return View(addMovieView);
 }
Ejemplo n.º 2
0
        public Movie AddMovie()
        {
            addMovieView                    = new AddMovieView();
            addMovieViewModel               = App.Container.Resolve <IAddMovieViewModel>();
            addMovieViewModel.Model         = new Movie();
            addMovieViewModel.OkCommand     = new RelayCommand(ExecuteOkCommand);
            addMovieViewModel.CancelCommand = new RelayCommand(ExecuteCancelCommand);

            addMovieView.DataContext = addMovieViewModel;
            return(addMovieView.ShowDialog() == true ? addMovieViewModel.Model : null);
        }
Ejemplo n.º 3
0
 public static Movie ToMovie(this AddMovieView addMovieView, int userId)
 {
     var movie = new Movie
     {
         Title = addMovieView.Title,
         Description = addMovieView.Description,
         PostedByUserId = userId,
         PublishedDate = DateTime.Now
     };
     return movie;
 }
        private AddMovieView getGenreDirectorView()
        {
            List <Genre>  genres    = _repository.getAllGenres();
            List <Person> directors = _repository.getAllPeople();

            AddMovieView result = new AddMovieView {
                Genres    = genres,
                Directors = directors
            };

            return(result);
        }
 public IActionResult Add(AddMovieView values)
 {
     if (ModelState.IsValid)
     {
         Movie buffer = new Movie {
             Title       = values.Title,
             Description = values.Description,
             Year        = values.Year,
             Stars       = values.Stars,
             DirectorID  = values.DirectorID,
             GenreID     = values.GenreID
         };
         _repository.addMovie(buffer);
         List <MovieView> result = GetAddList();
         return(View("Add", GetAddList()));
     }
     else
     {
         return(View("addMovie", getGenreDirectorView()));
     }
 }