public async Task <IActionResult> Post([FromBody] LocationModel location) { GeoLocation geoLocation = new GeoLocation { Latitude = location.Latitude, Longitude = location.Longitude }; _repository.Add(geoLocation); await _unitOfWork.CommitAsync(); return(Ok(location)); }
private GeoLocation saveGeoLocation(Endereco endereco, double latitude, double longitude) { GeoLocation geoLocation = null; if (endereco.GeoLocationId.HasValue) { geoLocation = _geoLocationRepository.GetById(endereco.GeoLocationId.Value); } if (geoLocation == null) { geoLocation = new GeoLocation(latitude, longitude); _geoLocationRepository.Add(geoLocation); } else { _geoLocationRepository.Update(geoLocation); } _geoLocationRepository.SaveChanges(); return(geoLocation); }