public ListResultDto <CountryListDto> GetCountries(GetCountryInput input)
        {
            var countries = _countryRepository
                            .GetAll()
                            .WhereIf(
                !input.Filter.IsNullOrEmpty(),
                p => p.Name.Contains(input.Filter)
                )
                            .OrderBy(p => p.Name)
                            .ToList();

            return(new ListResultDto <CountryListDto>(ObjectMapper.Map <List <CountryListDto> >(countries)));
        }
Example #2
0
        public PagedResponse <GetCountryOutput> GetCountries(GetCountryInput input, PageRequest pageRequest)
        {
            var query = _countryRepository.GetAll()
                        .WhereIf(!string.IsNullOrWhiteSpace(input.EnglishName), c => c.EnglishName.Contains(input.EnglishName))
                        .WhereIf(!string.IsNullOrWhiteSpace(input.ChineseName), c => c.ChineseName.Contains(input.ChineseName));
            var amount = query.Count();

            query = query.Skip(pageRequest.PageIndex * pageRequest.ItemCount).Take(pageRequest.ItemCount);
            return(new PagedResponse <GetCountryOutput>()
            {
                PageIndex = pageRequest.PageIndex,
                TotalAmount = amount,
                ItemCount = pageRequest.ItemCount,
                Payload = _mapper.Map <IEnumerable <GetCountryOutput> >(query.ToList()),
            });
        }
 public PagedResponse <GetCountryOutput> GetCountries([FromQuery] GetCountryInput input, [FromQuery] PageRequest pageRequest)
 {
     return(_countryService.GetCountries(input, pageRequest));
 }
Example #4
0
 public CountryDto GetCountry(GetCountryInput input)
 {
     return(Mapper.Map <CountryDto>(_countryRepository.FirstOrDefault(c => c.Id == input.CountryId)));
 }