public async Task <IActionResult> Edit(string id)
        {
            try
            {
                AuthorizeHelper.Authorize(this.HttpContext, "Editor", this.GetType().Name, "Edit", "actor");

                GetActorModel getActorModel = await _moviemindAPIService.GetModel <GetActorModel>(id, "Actors");

                List <GetMovieModel> getMovieModels = await _moviemindAPIService.GetModels <GetMovieModel>("movies");

                ViewBag.Movies = getMovieModels;

                PutActorModel putDirectorModel = new PutActorModel
                {
                    FirstName   = getActorModel.FirstName,
                    LastName    = getActorModel.LastName,
                    Birth       = getActorModel.Birth,
                    Description = getActorModel.Description,
                    Nationality = getActorModel.Nationality,
                    Movies      = getActorModel.Movies
                };

                return(View(putDirectorModel));
            }
            catch (MovieMindException e)
            {
                return(ErrorHelper.HandleError(e));
            }
        }
        [ValidateAntiForgeryToken] // Prevents XSRF/CSRF attacks
        public async Task <IActionResult> Create(PostActorModel postActorModel)
        {
            try
            {
                AuthorizeHelper.Authorize(this.HttpContext, "Editor", this.GetType().Name, "Create", "actor");

                if (ModelState.IsValid)
                {
                    GetActorModel getActorModel = await _moviemindAPIService.PostModel <PostActorModel, GetActorModel>(postActorModel, "Actors");

                    //put in new relationships
                    foreach (Guid movieId in postActorModel.MovieIds)
                    {
                        await _moviemindAPIService.PostModel <PostActorMovieModel, GetActorMovieModel>(new PostActorMovieModel
                        {
                            ActorId = getActorModel.Id,
                            MovieId = movieId
                        }, "ActorMovies");
                    }

                    return(Redirect("/Actors/Details/" + getActorModel.Id.ToString()));
                }

                return(View(postActorModel));
            }
            catch (MovieMindException e)
            {
                return(ErrorHelper.HandleError(e, this.View(postActorModel)));
            }
        }
        public async Task <GetActorModel> GetActor(string id)
        {
            GetActorModel actor = await _context.Actors
                                  .Select(x => new GetActorModel
            {
                Id          = x.Id,
                FirstName   = x.FirstName,
                LastName    = x.LastName,
                Birth       = x.Birth,
                Nationality = x.Nationality,
                Description = x.Description,
                Movies      = (from actorMovie in _context.ActorMovies
                               where actorMovie.ActorId == x.Id
                               select new GetMovieModel
                {
                    Id = actorMovie.MovieId,
                    Name = actorMovie.Movie.Name,
                    Description = actorMovie.Movie.Description,
                    Duration = actorMovie.Movie.Duration,
                    Year = actorMovie.Movie.Year,
                    OverallRating = actorMovie.Movie.OverallRating,
                    GenreId = actorMovie.Movie.GenreId,
                    DirectorId = actorMovie.Movie.DirectorId
                }).ToList()
            })
                                  .AsNoTracking()
                                  .FirstOrDefaultAsync(x => x.Id == Guid.Parse(id));

            if (actor == null)
            {
                throw new EntityException("Actor not found", this.GetType().Name, "GetActor", "404");
            }
            return(actor);
        }
        public async Task <ActionResult <GetActorModel> > PostActor(PostActorModel postActorModel)
        {
            try
            {
                GetActorModel actor = await _actorRepository.PostActor(postActorModel);

                return(CreatedAtAction(nameof(GetActor), new { id = actor.Id }, actor));
            }
            catch (DatabaseException e)
            {
                return(BadRequest(e.MovieMindError));
            }
        }
        [ValidateAntiForgeryToken] // Prevents XSRF/CSRF attacks
        public async Task <IActionResult> Delete(string id, GetActorModel getActorModel)
        {
            try
            {
                AuthorizeHelper.Authorize(this.HttpContext, "Editor", this.GetType().Name, "Delete", "actor");

                await _moviemindAPIService.DeleteModel(id, "Actors");

                return(RedirectToRoute(new { action = "Index", controller = "Actors" }));
            }
            catch (MovieMindException e)
            {
                return(ErrorHelper.HandleError(e, this.View(getActorModel)));
            }
        }
        public async Task <IActionResult> Delete(string id)
        {
            try
            {
                AuthorizeHelper.Authorize(this.HttpContext, "Editor", this.GetType().Name, "Delete", "actor");

                GetActorModel getActorModel = await _moviemindAPIService.GetModel <GetActorModel>(id, "Actors");

                return(View(getActorModel));
            }
            catch (MovieMindException e)
            {
                return(ErrorHelper.HandleError(e));
            }
        }
        public async Task <IActionResult> Details(string id)
        {
            try
            {
                AuthorizeHelper.Authorize(this.HttpContext, "Guest", this.GetType().Name, "Details", "actor");

                GetActorModel getActorModel = await _moviemindAPIService.GetModel <GetActorModel>(id, "Actors");

                foreach (GetMovieModel getMovieModel in getActorModel.Movies)
                {
                    getMovieModel.Director = await _moviemindAPIService.GetModel <GetDirectorModel>(getMovieModel.DirectorId.ToString(), "Directors");

                    getMovieModel.Genre = await _moviemindAPIService.GetModel <GetGenreModel>(getMovieModel.GenreId.ToString(), "Genres");
                }

                return(View(getActorModel));
            }
            catch (MovieMindException e)
            {
                return(ErrorHelper.HandleError(e));
            }
        }