public async Task <SearchResponse> SearchAsync(SearchRequest request, SearchResponse response) { try { response = await _weatherDataLayer.SearchAsync(request, response).ConfigureAwait(false); if (!response.IsSuccess) { response.Failed("WeatherWorkflow:SearchAsync"); } } catch (Exception ex) { response.Failed(ex); } return(response); }
public async Task <SearchResponse> SearchAsync(SearchRequest request, SearchResponse response) { try { // Map request var serviceRequest = _mapper.Map <Repository.Entities.Requests.SearchRequest>(request); // Map response var serviceResponse = _mapper.Map <Repository.Entities.Responses.SearchResponse>(response); // Call action serviceResponse = await _weatherWorkflow.SearchAsync(serviceRequest, serviceResponse); // Merge response logs response.Marge(serviceResponse); // Handle response if (response.IsSuccess) { response.Places = new List <APIEntities.AccuWeather.Models.PlaceData>(); foreach (var place in serviceResponse.Places) { response.Places.Add(new APIEntities.AccuWeather.Models.PlaceData { CityKey = place.CityKey, PlaceName = place.PlaceName }); } } else { response.Failed("WeatherConnector:SearchAsync"); } } catch (Exception ex) { response.Failed(ex); } return(response); }
public async Task <SearchResponse> SearchAsync([FromQuery] SearchRequest request) { var response = new SearchResponse(); try { response = await _weatherWorkflow.SearchAsync(request, response).ConfigureAwait(false); if (response.IsSuccess) { response.Success("SearchAsync"); } else { response.Failed("WeatherController:SearchAsync"); } } catch (Exception ex) { response.Failed(ex); } return(response); }
public async Task <SearchResponse> SearchAsync(SearchRequest request, SearchResponse response) { try { var placesAutoComplete = await _weatherRepository.AutoCompleteAsync(request.SearchParam).ConfigureAwait(false); if (placesAutoComplete?.Count > 0) { response.Places = new List <PlaceData>(); foreach (var place in placesAutoComplete) { response.Places.Add(new PlaceData { CityKey = place.Key, PlaceName = place.LocalizedName }); } response.Success("SearchAsync"); } } catch (Exception ex) { response.Failed(ex); } return(response); }