public async Task <IActionResult> GetCitiesAsync([FromQuery] SearchContract searchContract) { if (searchContract == null) { return(Error("Invalid Input")); } else if (searchContract.PageNumber < 1) { return(Error("Invalid Page Number")); } else if (searchContract.PageSize < 1) { return(Error("Invalid Page Size")); } _logger.LogInformation("GetCitiesAsync Called."); var query = new GetCityListQuery { SearchContract = searchContract }; var list = await _messages.Dispatch(query).ConfigureAwait(false); return(Ok(list)); }
public async Task <IEnumerable <CityDto> > Handle(GetCityListQuery request, CancellationToken cancellationToken) { var cities = await context.Cities.ToListAsync(); return(mapper.Map <List <City>, List <CityDto> >(cities)); }