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); }
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); }
/// <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 = "a6feb446-c7f2-4b48-9b3a-0f87744a5047"; /// AttributeValue rangeKeyValue = new AttributeValue().withS(rangeKey); /// UpdatePointRequest updatePointRequest = new UpdatePointRequest(geoPoint, rangeKeyValue); /// AttributeValue titleValue = new AttributeValue().withS("Updated title."); /// AttributeValueUpdate titleValueUpdate = new AttributeValueUpdate().withAction(AttributeAction.PUT) /// .withValue(titleValue); /// updatePointRequest.getUpdateItemRequest().getAttributeUpdates().put("title", 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)); }
public async Task <IActionResult> UpdatePoint([FromBody] UpdatePointRequest updatePointRequest) { var point = await _pointsService.UpdatePoint(updatePointRequest); return(Ok(PointDto.Map(point))); }
public IActionResult Update([FromBody] UpdatePointRequest request) { _updatePointCommand.Execute(request); return(NoContent()); }