public async Task <DetectionPoint> AddDetectionPointAsync(InsertDetectionPointDto input) { var district = await _districtService.GetByExpression(p => p.Code.Equals(input.DistrictCode)); if (district == null) { throw new MyAppException { ErrorCode = MyCustomErrorCodes.DISTRICT_NOT_FOUND }; } return(await _pointService.CreateAsync(input, district)); }
internal async Task <DetectionPoint> CreateAsync(InsertDetectionPointDto input, District district) { var newPoint = new DetectionPoint { Code = input.PointCode, District = district, DistrictId = district.Id }; if (input.latitudo.HasValue && input.longitudo.HasValue) { var geometryFactory = NtsGeometryServices.Instance.CreateGeometryFactory(srid: 4326); newPoint.GeoLocation = geometryFactory.CreatePoint( new Coordinate(input.longitudo.Value, input.latitudo.Value)); } return(await _repository.InsertAsync(newPoint)); }
public async Task <IActionResult> AddPoint([FromBody] InsertDetectionPointDto input) { var result = await _manager.AddDetectionPointAsync(input); return(Ok(result)); }