Пример #1
0
        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));
        }
Пример #2
0
        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));
        }
Пример #3
0
        public async Task <IActionResult> AddPoint([FromBody] InsertDetectionPointDto input)
        {
            var result = await _manager.AddDetectionPointAsync(input);

            return(Ok(result));
        }