public Outcome Execute() { MapWebAPIComm network = new MapWebAPIComm(); var requestDTO = new NetworkLocationDTO() { Location = RequestedLocation }; // Waits for the request to finish // TODO: I need to fix this Task.Run issue var test = Task.Run(async() => { return(await network.Request(requestDTO)); }).Result; // Converts the data from the web api MapDataAdapter dataMapper = new MapDataAdapter(); var mappedData = dataMapper.Convert(test.Response); ValidatedLocation = mappedData; // Validating County based on the scope if (ValidatedLocation.County != null && (ValidatedLocation.County.Equals("Los Angeles County") || ValidatedLocation.County.Equals("Orange County"))) { ValidatedLocation.IsValid = true; } else { ValidatedLocation.IsValid = false; } return(new Outcome() { Result = ValidatedLocation }); }
/// <summary> /// Checks if the address is in the scope of Whatfits by sending a request to Google Maps Web API /// </summary> /// <param name="address"> location based on users input </param> /// <returns> status of the validation of the location </returns> public bool CheckAddress(string address) { var location = address.Replace(' ', '+'); MapWebAPIComm network = new MapWebAPIComm(); var requestDTO = new NetworkLocationDTO() { Location = location }; // Waits for the request to finish var test = Task.Run(async() => { return(await network.Request(requestDTO)); }).Result; // Converts the data from the web api MapDataAdapter dataMapper = new MapDataAdapter(); var mappedData = dataMapper.Convert(test.Response); // Validating County based on the scope if (mappedData.County != null && (mappedData.County.Equals("Los Angeles County") || mappedData.County.Equals("Orange County"))) { ValidatedLocation = mappedData; return(true); } return(false); }