Beispiel #1
0
        public async Task <GeofenceDataSingleResult> UpsertBoundary(string projectUid, [FromBody] BoundaryRequest request)
        {
            Log.LogInformation(
                $"{ToString()}.{nameof(UpsertBoundary)}: CustomerUID={CustomerUid} BoundaryRequest: {JsonConvert.SerializeObject(request)}");

            var requestFull = BoundaryRequestFull.Create(
                CustomerUid,
                IsApplication,
                await GetProject(projectUid),
                GetUserId,
                request);

            requestFull.Validate(ServiceExceptionHandler);
            requestFull.Request.BoundaryPolygonWKT = GeofenceValidation.MakeGoodWkt(requestFull.Request.BoundaryPolygonWKT);

            var getResult = await BoundaryHelper.GetProjectBoundaries(
                Log, ServiceExceptionHandler,
                projectUid, _projectRepository, _geofenceRepository).ConfigureAwait(false);

            if (getResult.GeofenceData.Any(g => request.Name.Equals(g.GeofenceName, StringComparison.OrdinalIgnoreCase)))
            {
                ServiceExceptionHandler.ThrowServiceException(HttpStatusCode.BadRequest, 62);
            }

            var executor = RequestExecutorContainer.Build <UpsertBoundaryExecutor>(ConfigStore, Logger,
                                                                                   ServiceExceptionHandler, _geofenceRepository, _projectRepository, ProjectProxy);
            var result = await executor.ProcessAsync(requestFull) as GeofenceDataSingleResult;

            Log.LogInformation(
                $"{ToString()}.UpsertBoundary Completed: resultCode: {result?.Code} result: {JsonConvert.SerializeObject(result)}");
            return(result);
        }
Beispiel #2
0
        public void ValidateGeofence_MakeValidWkt_FromWKT()
        {
            var wkt = GeofenceValidation.MakeGoodWkt(_invalidBoundary_NotClosed);

            Assert.Equal(_validBoundary, wkt);
        }
Beispiel #3
0
        public void BoundaryRequestValidation_Fix()
        {
            var wkt = GeofenceValidation.MakeGoodWkt(_invalidBoundary_NotClosed);

            Assert.Equal(_validBoundary, wkt);
        }