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)); }
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); }
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)); }
// GET: Actor public async Task <ActionResult> Index() { return(View(await repository.GetAsync())); }
public async Task <Actor> GetById(int id) { return(await repository.GetAsync(id)); }