public async Task <AddToFavoritesResponse> AddToFavoritesAsync(AddToFavoritesRequest request, AddToFavoritesResponse response) { try { // Map request var serviceRequest = _mapper.Map <Repository.Entities.Requests.AddToFavoritesRequest>(request); // Map response var serviceResponse = _mapper.Map <Repository.Entities.Responses.AddToFavoritesResponse>(response); // Call action serviceResponse = await _weatherWorkflow.AddToFavoritesAsync(serviceRequest, serviceResponse); // Merge response logs response.Marge(serviceResponse); // Handle response if (response.IsSuccess) { response.CityKey = serviceResponse.CityKey; response.CityName = serviceResponse.CityName; } else { response.Failed("WeatherConnector:AddToFavoritesAsync"); } } catch (Exception ex) { response.Failed(ex); } return(response); }
public async Task <AddToFavoritesResponse> AddToFavoritesAsync(AddToFavoritesRequest request, AddToFavoritesResponse response) { try { response = await _weatherDataLayer.AddToFavoritesAsync(request, response).ConfigureAwait(false); if (!response.IsSuccess) { response.Failed("WeatherWorkflow:AddToFavoritesAsync"); } } catch (Exception ex) { response.Failed(ex); } return(response); }
public async Task <AddToFavoritesResponse> AddToFavoritesAsync([FromBody] AddToFavoritesRequest request) { var response = new AddToFavoritesResponse(); try { response = await _weatherWorkflow.AddToFavoritesAsync(request, response).ConfigureAwait(false); if (response.IsSuccess) { response.Success("AddToFavoritesAsync"); } else { response.Failed("WeatherController:AddToFavoritesAsync"); } } catch (Exception ex) { response.Failed(ex); } return(response); }
public async Task <AddToFavoritesResponse> AddToFavoritesAsync(AddToFavoritesRequest request, AddToFavoritesResponse response) { try { var newFavorite = await _weatherRepository.AddPlaceToFavorites(request.CityKey).ConfigureAwait(false); if (newFavorite != null) { response.CityKey = newFavorite.PlaceID; response.CityName = newFavorite.PlaceName; response.Success("AddToFavoritesAsync"); } } catch (Exception ex) { response.Failed(ex); } return(response); }