public MovieAddDto AddGet() { return(new MovieAddDto() { Actors = _actorRepository.GetAll().Select(a => new SelectListItem { Text = a.FullName, Value = a.Id.ToString() }).ToList(), Categories = _categoryRepository.GetAll().Select(c => new SelectListItem { Text = c.Name, Value = c.Id.ToString() }).ToList() }); }
public IEnumerable <ActorViewModel> GetActors() { List <Actor> actors = _actorRepository.GetAll().ToList(); List <ActorViewModel> actorsVM = Mapper.Map <List <Actor>, List <ActorViewModel> >(actors); for (var i = 0; i < actors.Count(); i++) { var actingsCount = _context.Actings.Where(ac => ac.ActorID == actors[i].ID).Count(); actorsVM[i].MoviesCount = actingsCount; } return(actorsVM); }
public MovieDetailsDTO Get(int id) { Movie Movie = IMovieRepository.Get(id); MovieDetailsDTO MyMovie = new MovieDetailsDTO() { Title = Movie.Title, ReleaseDate = Movie.ReleaseDate, RunTime = Movie.RunTime, Vote = Movie.Vote }; IEnumerable <MovieActor> MyMovieActors = IMovieActorRepository.GetAll().Where(x => x.MovieId == Movie.Id); if (MyMovieActors != null) { List <string> MovieActorList = new List <string>(); foreach (MovieActor MyMovieActor in MyMovieActors) { Actor MyActor = IActorRepository.GetAll().SingleOrDefault(x => x.Id == MyMovieActor.ActorId); MovieActorList.Add(MyActor.Name); } MyMovie.ActorName = MovieActorList; } IEnumerable <MovieCompany> MyMovieCompanies = IMovieCompanyRepository.GetAll().Where(x => x.MovieId == Movie.Id); if (MyMovieCompanies != null) { List <string> MovieCompanyList = new List <string>(); foreach (MovieCompany MyMovieCompany in MyMovieCompanies) { Company MyCompany = ICompanyRepository.GetAll().SingleOrDefault(x => x.Id == MyMovieCompany.CompanyId); MovieCompanyList.Add(MyCompany.Name); } MyMovie.CompanyName = MovieCompanyList; } IEnumerable <MovieGenre> MyMovieGenres = IMovieGenreRepository.GetAll().Where(x => x.MovieId == Movie.Id); if (MyMovieGenres != null) { List <string> MovieGenreList = new List <string>(); foreach (MovieGenre MyMovieGenre in MyMovieGenres) { Genre MyGenre = IGenreRepository.GetAll().SingleOrDefault(x => x.Id == MyMovieGenre.GenreId); MovieGenreList.Add(MyGenre.Name); } MyMovie.GenreName = MovieGenreList; } return(MyMovie); }
public async Task <ActionResult <ActorDTO[]> > GetAllActors(int?page, int pagesize = 3, [FromQuery] string firstName = "", [FromQuery] string[] including = null) { try { var results = await _repository.GetAll(firstName, page, pagesize < 50?pagesize : 50, including); var links = CreateLinksForCollection(results); var toReturn = results.Select(x => ExpandSingleItem(x)); return(Ok(new { value = toReturn, links = links })); } catch (Exception e) { var result = new { Status = StatusCodes.Status500InternalServerError, Data = $"Failed to retrieve actors. Exception thrown when attempting to retrieve data from the database: {e.Message}" }; return(this.StatusCode(StatusCodes.Status500InternalServerError, result)); } }
public ActorIndexDto GetAllForIndex(GenderDto?gender, int yearMin, int yearMax, int gradeMin, int gradeMax, string[] countries, string sortOrder, int?pageNumber, int pageSize = 5) { ActorIndexDto actorsForIndex = new ActorIndexDto() { Actors = _actorRepository.GetAll().ProjectTo <ActorDto>(_mapper.ConfigurationProvider).AsEnumerable(), GradeMin = gradeMin, GradeMax = gradeMax == 0 ? 10 : gradeMax, YearMax = yearMax == 0 ? 2100 : yearMax, YearMin = yearMin == 0 ? yearMax : yearMin, Gender = gender, Countries = countries, SortOrder = sortOrder, PageNumber = pageNumber, PageSize = pageSize }; Filter(actorsForIndex); Sort(actorsForIndex); actorsForIndex.PaginatedActors = PaginatedList <ActorDto> .Create(actorsForIndex.Actors.AsQueryable(), pageNumber ?? 1, pageSize); return(actorsForIndex); }
public IEnumerable <Actor> GetAll() { return(_actorRepository.GetAll()); }
public IActionResult GetAll() { IEnumerable <ActorResponseModel> actorResponses = _mapper.Map <IEnumerable <ActorResponseModel> >(_actorRepository.GetAll()); return(Ok(actorResponses)); }
public async Task <List <Actor> > GetActors() { return(await _actorRepo.GetAll()); }
protected override void OnAppearing() { listview.ItemsSource = actorRepository.GetAll(); base.OnAppearing(); }