コード例 #1
0
        public async Task <IActionResult> OnGet(int id)
        {
            director = await _directorService.Get(id);

            if (director == null)
            {
                return(RedirectToPage("/NotFound"));
            }
            return(Page());
        }
コード例 #2
0
        public async Task <IActionResult> Update(int directorId)
        {
            var director = await _directorService.Get(directorId);

            if (director.ResultStatus == ResultStatus.Success)
            {
                return(PartialView("_DirectorEditPartial",
                                   _mapper.Map <DirectorUpdateDto>(director.Data)));
            }
            return(NotFound());
        }
コード例 #3
0
        public ActionResult Edit(int?id)
        {
            if (id == null || id == 0)
            {
                return(View("Select"));
            }
            else
            {
                var director = _directorService.Get((int)id);

                return(View(director));
            }
        }
コード例 #4
0
        public async Task<IActionResult> OnGetAsync(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

            var directorOutput = await _directorService.Get(id.Value);
            directorDetail = mapper.Map<DirectorOutputDto>(directorOutput);

            if (directorDetail == null)
            {
                return NotFound();
            }
            return Page();
        }
コード例 #5
0
 public async Task <DirectorOutputDto> Get(int id)
 {
     return(await DirectorService.Get(id));
 }
コード例 #6
0
 public Director Get(long id)
 {
     return(_directorService.Get(id));
 }
コード例 #7
0
        public IActionResult Edit(EditMovieViewModel model)
        {
            var movie = movieService.GetByIdQueryable(model.id)
                        .Include(a => a.MovieGenres).First();

            movie.Length       = model.Length;
            movie.Title        = model.Title;
            movie.EndDate      = model.EndDate;
            movie.PremiereDate = model.PremiereDate;
            movie.Poster       = model.Poster;
            movie.Description  = model.Description;
            var genres = Request.Form["genre"];

            foreach (var genre in genres)
            {
                var genreId = int.Parse(genre);
                if (movie.MovieGenres.Find(a => a.GenreId == genreId) == null)
                {
                    movie.MovieGenres.Add(new MovieGenre()
                    {
                        GenreId = genreId,
                        MovieId = movie.Id
                    });
                }
            }

            var director = directorService.Get().Where(m => m.DirectorName == model.DirectorName).FirstOrDefault();

            if (director != null)
            {
                movie.DirectorId = director.Id;
                movie.Director   = director;
            }
            else
            {
                director = directorService.Add(new Director()
                {
                    DirectorName = model.DirectorName
                });
                movie.DirectorId = director.Id;
                movie.Director   = director;
            }
            var countryOfOrigin = countryOfOriginService.Get().Where(m => m.Name == model.CountryOfOrigin).FirstOrDefault();

            if (countryOfOrigin != null)
            {
                movie.CountryOfOriginId = countryOfOrigin.Id;
                movie.CountryOfOrigin   = countryOfOrigin;
            }
            else
            {
                countryOfOrigin = countryOfOriginService.Add(new CountryOfOrigin()
                {
                    Name = model.CountryOfOrigin
                });
                movie.CountryOfOriginId = countryOfOrigin.Id;
                movie.CountryOfOrigin   = countryOfOrigin;
            }
            movieService.Update(movie);
            return(RedirectToAction("MovieTable"));
        }