コード例 #1
0
        public async Task <UpdatePointResult> UpdatePointAsync(UpdatePointRequest updatePointRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (updatePointRequest == null)
            {
                throw new ArgumentNullException("updatePointRequest");
            }

            var geohash = S2Manager.GenerateGeohash(updatePointRequest.GeoPoint);
            var hashKey = S2Manager.GenerateHashKey(geohash, _config.HashKeyLength);

            var updateItemRequest = updatePointRequest.UpdateItemRequest;

            updateItemRequest.TableName = _config.TableName;

            var hashKeyValue = new AttributeValue
            {
                N = hashKey.ToString(CultureInfo.InvariantCulture)
            };

            updateItemRequest.Key[_config.HashKeyAttributeName]  = hashKeyValue;
            updateItemRequest.Key[_config.RangeKeyAttributeName] = updatePointRequest.RangeKeyValue;

            // Geohash and geoJson cannot be updated.
            updateItemRequest.AttributeUpdates.Remove(_config.GeohashAttributeName);
            updateItemRequest.AttributeUpdates.Remove(_config.GeoJsonAttributeName);

            UpdateItemResponse updateItemResult = await _config.DynamoDBClient.UpdateItemAsync(updateItemRequest, cancellationToken).ConfigureAwait(false);

            var updatePointResult = new UpdatePointResult(updateItemResult);

            return(updatePointResult);
        }
コード例 #2
0
        public async Task <Point> UpdatePoint(UpdatePointRequest updatePointRequest)
        {
            var existingPoint = await _MarketPlaceContext.Points.FindAsync(updatePointRequest.Id);

            if (existingPoint != null)
            {
                existingPoint.Description = updatePointRequest.Description;
                existingPoint.Name        = updatePointRequest.Name;
                existingPoint.ObjectType  = updatePointRequest.ObjectType;
                existingPoint.ObjectId    = updatePointRequest.ObjectId;
                existingPoint.AssetId     = updatePointRequest.AssetId;
                existingPoint.Archive     = updatePointRequest.Archive;
                existingPoint.LastUpdated = updatePointRequest.LastUpdated;
                existingPoint.AddedBy     = updatePointRequest.AddedBy;

                if (updatePointRequest.DeviceId != null)
                {
                    var device = await _MarketPlaceContext.Devices.FindAsync(updatePointRequest.DeviceId);

                    existingPoint.Device = device;
                }

                _MarketPlaceContext.Points.Update(existingPoint);
                await _MarketPlaceContext.SaveChangesAsync();
            }
            else
            {
                throw new KeyNotFoundException();
            }
            return(existingPoint);
        }
コード例 #3
0
 /// <summary>
 ///     <p>
 ///         Update a point data in Amazon DynamoDB table. You cannot update attributes specified in
 ///         GeoDataManagerConfiguration: hash key, range key, geohash and geoJson. If you want to update these columns, you
 ///         need to insert a new record and delete the old record.
 ///     </p>
 ///     <b>Sample usage:</b>
 ///     <pre>
 ///         GeoPoint geoPoint = new GeoPoint(47.5, -122.3);
 ///         String rangeKey = &quot;a6feb446-c7f2-4b48-9b3a-0f87744a5047&quot;;
 ///         AttributeValue rangeKeyValue = new AttributeValue().withS(rangeKey);
 ///         UpdatePointRequest updatePointRequest = new UpdatePointRequest(geoPoint, rangeKeyValue);
 ///         AttributeValue titleValue = new AttributeValue().withS(&quot;Updated title.&quot;);
 ///         AttributeValueUpdate titleValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.PUT)
 ///         .withValue(titleValue);
 ///         updatePointRequest.getUpdateItemRequest().getAttributeUpdates().put(&quot;title&quot;, titleValueUpdate);
 ///         UpdatePointResult updatePointResult = geoIndexManager.updatePoint(updatePointRequest);
 ///     </pre>
 /// </summary>
 /// <param name="updatePointRequest">Container for the necessary parameters to execute update point request.</param>
 /// <returns>Result of update point request.</returns>
 public Task <UpdatePointResult> UpdatePointAsync(UpdatePointRequest updatePointRequest, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(_dynamoDBManager.UpdatePointAsync(updatePointRequest, cancellationToken));
 }
コード例 #4
0
        public async Task <IActionResult> UpdatePoint([FromBody] UpdatePointRequest updatePointRequest)
        {
            var point = await _pointsService.UpdatePoint(updatePointRequest);

            return(Ok(PointDto.Map(point)));
        }
コード例 #5
0
        public IActionResult Update([FromBody] UpdatePointRequest request)
        {
            _updatePointCommand.Execute(request);

            return(NoContent());
        }