Example #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            await _actorMovieService.Create(ActorMovieCreation);

            return(RedirectToPage("/Index"));
        }
Example #2
0
 public async Task Create(ActorMovieInputDto inputDto)
 {
     await ActorMovieService.Create(inputDto);
 }
Example #3
0
        public ActionResult Create(FeatureFilmViewModel viewModel, HttpPostedFileBase image,
                                   IEnumerable <string> actor, IEnumerable <string> director,
                                   IEnumerable <string> category, IEnumerable <string> producer,
                                   IEnumerable <string> resolution, IEnumerable <string> tag)
        {
            var filmViewModel  = viewModel.FilmViewModel;
            var movieViewModel = viewModel.MoviesViewModel;

            var film  = AutoMapper.Mapper.Map <Film>(filmViewModel);
            var movie = AutoMapper.Mapper.Map <Movie>(movieViewModel);

            movie.IsSeriesMovie = false;
            film.MovieId        = movie.Id;

            if (image != null &&
                image.FileName != null &&
                CheckImageUploadExtension.CheckImagePath(image.FileName) == true)
            {
                var path = Path.Combine(Server.MapPath("~/Images/Upload"), image.FileName);
                image.SaveAs(path);
                movie.Thumbnail = VariableUtils.UrlUpLoadImage + image.FileName;
            }

            _movieService.Create(movie);
            _filmService.Create(film);

            if (actor != null)
            {
                foreach (var item in actor)
                {
                    _actorMovieService.Create(new ActorMovie()
                    {
                        ActorId = Guid.Parse(item),
                        MovieId = movie.Id
                    });
                }
            }
            if (director != null)
            {
                foreach (var item in director)
                {
                    _directorMovieService.Create(new DirectorMovie()
                    {
                        DirectorId = Guid.Parse(item),
                        MovieId    = movie.Id
                    });
                }
            }
            if (category != null)
            {
                foreach (var item in category)
                {
                    _categoryMovieService.Create(new CategoryMovie()
                    {
                        CategoryId = Guid.Parse(item),
                        MovieId    = movie.Id
                    });
                }
            }
            if (producer != null)
            {
                foreach (var item in producer)
                {
                    _producerMovieService.Create(new ProducerMovie()
                    {
                        ProducerId = Guid.Parse(item),
                        MovieId    = movie.Id
                    });
                }
            }
            if (resolution != null)
            {
                foreach (var item in resolution)
                {
                    _resolutionMovieService.Create(new MovieResolution()
                    {
                        ResolutionId = Guid.Parse(item),
                        MovieId      = movie.Id
                    });
                }
            }
            if (tag != null)
            {
                foreach (var item in tag)
                {
                    _tagMovieService.Create(new TagMovie()
                    {
                        TagId   = Guid.Parse(item),
                        MovieId = movie.Id
                    });
                }
            }
            return(RedirectToAction("Index"));
        }