public IActionResult Filter(int breedId) { var characters = charactersRepository.GetCharactersByBreed(breedId).Select(x => new AlbumCardViewModel() { Id = x.Id, DisplayName = x.Name + " " + x.Surname }).OrderBy(ch => ch.DisplayName).ToList(); var avatars = charactersRepository.GetAllAvatars(); foreach (var character in characters) { character.Avatar = Mapper.Map <ImageViewModel>(avatars.FirstOrDefault(i => i.CharacterId == character.Id)); } ViewData["Breeds"] = charactersRepository.GetAllBreeds().ToDictionary(b => b.Id, b => b.Name); return(View("~/Views/Home/Index.cshtml", characters)); }