public async Task <IActionResult> Create(Contractor contractor) { string streetAddress = contractor.StreetAddress.Replace(' ', '+'); string city = contractor.City.Replace(' ', '+'); string url = "https://maps.googleapis.com/maps/api/geocode/json?address=" + streetAddress + ",+" + city + ",+" + contractor.State + "&key=" + ApiKeys.GetGeocodingKey(); Geocoding response = await _geocodingService.GetGeocoded(url); if (response.results.Length > 0) { contractor.Latitude = response.results[0].geometry.location.lat; contractor.Longitude = response.results[0].geometry.location.lng; } try { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); contractor.IdentityUserId = userId; _repo.Contractor.CreateContractor(contractor); await _repo.SaveAsync(); return(RedirectToAction(nameof(Index))); } catch (Exception e) { //_logger.LogError($"Error: {e.Message}"); return(View(e)); } }