public ListResultDto <StateListDto> GetStates(GetStateInput input)
        {
            var countries = _stateRepository
                            .GetAll()
                            .WhereIf(
                !input.Filter.IsNullOrEmpty(),
                p => p.Name.Contains(input.Filter)
                )
                            .OrderBy(p => p.Name)
                            .ToList();

            return(new ListResultDto <StateListDto>(ObjectMapper.Map <List <StateListDto> >(countries)));
        }
Beispiel #2
0
        public async Task <ListResultDto <StateListDto> > GetStates(GetStateInput input)
        {
            var items = await _stateManager.States
                        .Where(x => (!input.Keyword.IsNullOrWhiteSpace())?x.StateName.Contains(input.Keyword) : true)
                        .Select(x => new StateListDto
            {
                Id        = x.Id,
                StateName = x.StateName,
                Cities    = x.Cities.Select(y => new CityDto
                {
                    CityName = y.CityName
                }).ToList()
            })
                        .OrderBy(x => x.StateName)
                        .ToListAsync();

            return(new ListResultDto <StateListDto>(items));
        }