Ejemplo n.º 1
0
        public async Task <IActionResult> GetActorsById([FromRoute] int actorId)
        {
            var actor = await _actorRepository.GetAsync(actorId);

            if (actor == null)
            {
                return(NotFound());
            }

            var movies = await _movieRepository.Query().ToListAsync();

            if (movies.FirstOrDefault(c => c.ActorId == actorId) == null)
            {
                return(NotFound());
            }

            var result = new MovieListModel
            {
                Movies = movies.Select(c => new MovieModel
                {
                    ActorId        = (int)c.ActorId,
                    Id             = c.Id,
                    Name           = c.Name,
                    YearOfReleased = c.YearOfReleased,
                    Plot           = c.Plot
                }).Where(a => a.ActorId == actorId)
            };

            return(Ok(result));
        }
Ejemplo n.º 2
0
        public async Task Get_CallsRepository()
        {
            var expected = new Actor();
            var id       = 3;

            Mock.Arrange(() => repo.GetAsync(id))
            .Returns(() => Task.FromResult(expected));
            var result = await target.GetById(id);

            Assert.Equal(expected, result);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Get(int id)
        {
            var actor = await _actorRepository.GetAsync(id);

            //var actorMovie = await _actorMovieRepository.GetAsync(;

            if (actor == null)
            {
                return(NotFound());
            }

            var result = new ActorModel
            {
                Id   = actor.Id,
                Name = actor.Name,
                Sex  = actor.Sex,
                DOB  = actor.DOB,
                BIO  = actor.BIO
            };

            return(Ok(result));
        }
Ejemplo n.º 4
0
 // GET: Actor
 public async Task <ActionResult> Index()
 {
     return(View(await repository.GetAsync()));
 }
Ejemplo n.º 5
0
 public async Task <Actor> GetById(int id)
 {
     return(await repository.GetAsync(id));
 }