Beispiel #1
0
        public async Task ShowPetsAsync(ShowPetsRequest request)
        {
            var getPeopleOperation = await _peopleService.GetPetOwnersAsync(new GetPetOwnersRequest(request.PetType));

            if (!getPeopleOperation.Status)
            {
                _logger.LogError("Error when getting the people");
                return;
            }

            foreach (var person in getPeopleOperation.Data.People)
            {
                var pets = person.Pets.OrderBy(x => x.Name);
                person.Pets = pets;
            }

            var viewModel = _mapper.Map(getPeopleOperation.Data);


            await _renderer.RenderAsync(viewModel);
        }
Beispiel #2
0
        public async Task ShowPetsAsync(ShowPetsRequest request)
        {
            var getPeopleOperation = await _peopleService.GetPetOwnersAsync(new GetPetOwnersRequest(request.PetType));

            if (!getPeopleOperation.Status)
            {
                _logger.LogError("Error when getting the people");
                return;
            }

            var viewModel = _mapper.Map(getPeopleOperation.Data);
            //
            // Depending on the requested parameters do the sorting
            //
            var sortedViewModel = new PetsByOwnerGenderViewModel();

            foreach (var item in viewModel.PetsMappedByOwnersGender)
            {
                sortedViewModel.PetsMappedByOwnersGender.Add(item.Key, item.Value.SortCollection(request.OrderBy, request.SortDirection));
            }

            await _renderer.RenderAsync(sortedViewModel);
        }