public UpdateObjectResponse UpdateObject(UpdateObjectRequest request) { IAsyncResult asyncResult; asyncResult = invokeUpdateObject <UpdateObjectResponse>(request, null, null, true); return(EndUpdateObject(asyncResult)); }
public async Task <ObjectDto> PostObject(UpdateObjectRequest objectRequest) { Random rnd = new Random(); var newObject = new Object { Id = rnd.Next(1, 6666), City = objectRequest.City, House = objectRequest.House, Name = objectRequest.Name, Street = objectRequest.Street, MapCoordinates = objectRequest.MapCoordinates, Info = objectRequest.Info }; // // _db.Objects.Update(newObject); // _db.Save(); _context.Objects.Add(newObject); await _context.SaveChangesAsync(); var zalupa = _mapper.Map <ObjectDto>(newObject); return(zalupa); }
public IActionResult UpdateUser(UpdateObjectRequest updateObjectRequest) { string methodName = System.Reflection.MethodInfo.GetCurrentMethod().Name; logger.LogInformation($@"{methodName} process is begining."); userService.Update(updateObjectRequest); logger.LogInformation($@"{methodName} process is ended."); return(Ok()); }
public UpdateObjectResponse UpdateObject(UpdateObjectRequest request) { EnsureAbsoluteUri(request); var command = new UpdateObject(_userId, _secret, _builder, _authenticator) { Parameters = request }; return((UpdateObjectResponse)((ICommandExecutor)this).Execute(command)); }
static void Main(string[] args) { var client = CreateClient(); // create a bucket to contain an object string bucketName = Guid.NewGuid().ToString("N"); var putBucketRequest = new PutBucketRequest() { BucketName = bucketName }; client.PutBucket(putBucketRequest).Dispose(); Console.WriteLine("Created a bucket named {0}.", putBucketRequest.BucketName); // create an object in the bucket var putObjectRequest = new PutObjectRequest() { BucketName = bucketName, Key = "MyObject.txt", ContentBody = "Hello World!" }; client.PutObject(putObjectRequest).Dispose(); Console.WriteLine("Created an object named {0}.", putObjectRequest.Key); // update the object in the bucket var updateObjectRequest = new UpdateObjectRequest() { BucketName = bucketName, Key = "MyObject.txt", ContentBody = "Again", }; updateObjectRequest.UpdateRange = new Amazon.S3.Model.Tuple <long, long?>(6, null); client.UpdateObject(updateObjectRequest); Console.WriteLine("Updated the object's content."); // get the object content var getObjectRequest = new GetObjectRequest() { BucketName = bucketName, Key = "MyObject.txt" }; using (var getObjectResponse = client.GetObject(getObjectRequest)) { string contentBody = getObjectResponse.GetResponseContentBody(); Console.WriteLine("The object content is: {0}.", contentBody); } // delete the bucket client.DeleteBucketRecursive(bucketName); Console.WriteLine("Deleted the bucket."); }
protected override async Task <Entity> UpdateAsync(IDictionary <string, object> propertyUpdates, IDictionary <string, string> attributeUpdates, IEnumerable <string> addedTags, IEnumerable <string> removedTags, int specificRevision, ApiOptions options, bool forceUpdate) { var request = new UpdateObjectRequest { Id = this.Id, Type = this.Type }; ApiOptions.Apply(request, options); request.Revision = specificRevision; if (propertyUpdates != null && propertyUpdates.Count > 0) { propertyUpdates.For(x => request.PropertyUpdates[x.Key] = x.Value); } if (attributeUpdates != null && attributeUpdates.Count > 0) { attributeUpdates.For(x => request.AttributeUpdates[x.Key] = x.Value); } if (addedTags != null) { request.AddedTags.AddRange(addedTags); } if (removedTags != null) { request.RemovedTags.AddRange(removedTags); } // Check if acls are to be added request.AllowClaims.AddRange(this.Acl.Allowed); request.DenyClaims.AddRange(this.Acl.Denied); request.ResetClaims.AddRange(this.Acl.Reset); // Check if an update is needed. if (request.PropertyUpdates.Count == 0 && request.AttributeUpdates.Count == 0 && request.AddedTags.Count == 0 && request.RemovedTags.Count == 0 && request.AllowClaims.Count == 0 && request.DenyClaims.Count == 0 && request.ResetClaims.Count == 0 && forceUpdate == false) { return(null); } var response = await request.ExecuteAsync(); if (response.Status.IsSuccessful == false) { throw response.Status.ToFault(); } // 3. Update the last known state based on the differences Debug.Assert(response.Object != null, "If status is successful, then updated object should not be null."); return(response.Object); }
public async Task UpdateObjectAsyncTest() { // Create an apObject var now = DateTime.Now; dynamic obj = new APObject("object"); obj.intfield = 1; obj.decimalfield = 10.0m; obj.datefield = "2012-12-20"; obj.stringfield = "initial"; obj.Tags.Add("initial"); var createdResponse = await(new CreateObjectRequest() { Object = obj }).ExecuteAsync(); Assert.IsNotNull(createdResponse, "Object creation failed."); Assert.IsNotNull(createdResponse.Status, "Status is null."); Assert.IsTrue(createdResponse.Status.IsSuccessful, createdResponse.Status.Message ?? "Create apObject failed."); var created = createdResponse.Object; // Update the apObject var updateRequest = new UpdateObjectRequest() { Id = created.Id, Type = created.Type }; updateRequest.PropertyUpdates["intfield"] = "2"; updateRequest.PropertyUpdates["decimalfield"] = 20.0m.ToString(); updateRequest.PropertyUpdates["stringfield"] = null; updateRequest.PropertyUpdates["datefield"] = "2013-11-20"; updateRequest.AddedTags.AddRange(new[] { "tag1", "tag2" }); updateRequest.RemovedTags.AddRange(new[] { "initial" }); var updatedResponse = await updateRequest.ExecuteAsync(); Assert.IsNotNull(updatedResponse, "Update apObject response is null."); Assert.IsNotNull(updatedResponse.Status, "Update apObject response status is null."); Assert.IsNotNull(updatedResponse.Object, "Updated apObject is null."); var updated = updatedResponse.Object; Assert.IsTrue(updated.Get <string>("intfield") == "2"); Assert.IsTrue(updated.Get <decimal>("decimalfield") == 20.0m); Assert.IsTrue(updated.Get <string>("stringfield") == null); Assert.IsTrue(updated.Get <string>("datefield") == "2013-11-20"); Assert.IsTrue(updated.Tags.Count() == 2); Assert.IsTrue(updated.Tags.Intersect(new[] { "tag1", "tag2" }).Count() == 2); }
IAsyncResult invokeUpdateObject <T>(UpdateObjectRequest request, AsyncCallback callback, object state, bool synchronized) where T : UpdateObjectResponse, new() { //WebHeaderCollection webHeaders = request.Headers; //webHeaders[HttpRequestHeader.Range] = "bytes=" + request.UpdateRange; var parameters = request.parameters; parameters[S3QueryParameter.Range] = String.Concat( request.UpdateRange.First, ":", request.UpdateRange.Second ); return(invokePutObject <T>(request, callback, state, synchronized)); }
public async Task BugId14Test() { // Ref: https://github.com/appacitive/Gossamer/issues/14 // Updating a null property with a null value fails // Create an apObject var now = DateTime.Now; dynamic obj = new APObject("object"); obj.intfield = 1; obj.decimalfield = 10.0m; obj.stringfield = null; var createdResponse = await(new CreateObjectRequest() { Object = obj }).ExecuteAsync(); Assert.IsNotNull(createdResponse, "Object creation failed."); Assert.IsNotNull(createdResponse.Status, "Status is null."); Assert.IsTrue(createdResponse.Status.IsSuccessful, createdResponse.Status.Message ?? "Create apObject failed."); var created = createdResponse.Object; // Update the apObject twice for (int i = 0; i < 2; i++) { var updateRequest = new UpdateObjectRequest() { Id = created.Id, Type = created.Type }; updateRequest.PropertyUpdates["stringfield"] = null; var updatedResponse = await updateRequest.ExecuteAsync(); Assert.IsNotNull(updatedResponse, "Update apObject response is null."); Assert.IsNotNull(updatedResponse.Status, "Update apObject response status is null."); Assert.IsTrue(updatedResponse.Status.IsSuccessful, updatedResponse.Status.Message ?? "NULL"); Assert.IsNotNull(updatedResponse.Object, "Updated apObject is null."); var updated = updatedResponse.Object; Assert.IsTrue(updated["stringfield"] is NullValue); } }
protected override async Task<Entity> UpdateAsync(IDictionary<string, object> propertyUpdates, IDictionary<string, string> attributeUpdates, IEnumerable<string> addedTags, IEnumerable<string> removedTags, int specificRevision, ApiOptions options, bool forceUpdate) { var request = new UpdateObjectRequest {Id = this.Id, Type = this.Type}; ApiOptions.Apply(request, options); request.Revision = specificRevision; if (propertyUpdates != null && propertyUpdates.Count > 0) propertyUpdates.For(x => request.PropertyUpdates[x.Key] = x.Value); if (attributeUpdates != null && attributeUpdates.Count > 0) attributeUpdates.For(x => request.AttributeUpdates[x.Key] = x.Value); if (addedTags != null) request.AddedTags.AddRange(addedTags); if (removedTags != null) request.RemovedTags.AddRange(removedTags); // Check if acls are to be added request.AllowClaims.AddRange(this.Acl.Allowed); request.DenyClaims.AddRange(this.Acl.Denied); request.ResetClaims.AddRange(this.Acl.Reset); // Check if an update is needed. if (request.PropertyUpdates.Count == 0 && request.AttributeUpdates.Count == 0 && request.AddedTags.Count == 0 && request.RemovedTags.Count == 0 && request.AllowClaims.Count == 0 && request.DenyClaims.Count == 0 && request.ResetClaims.Count == 0 && forceUpdate == false ) return null; var response = await request.ExecuteAsync(); if (response.Status.IsSuccessful == false) throw response.Status.ToFault(); // 3. Update the last known state based on the differences Debug.Assert(response.Object != null, "If status is successful, then updated object should not be null."); return response.Object; }
public async Task <ObjectDto> PostInfo([FromBody] UpdateObjectRequest objectRequest) { return(await _objectService.PostObject(objectRequest)); }
public async Task BugId14Test() { // Ref: https://github.com/appacitive/Gossamer/issues/14 // Updating a null property with a null value fails // Create an apObject var now = DateTime.Now; dynamic obj = new APObject("object"); obj.intfield = 1; obj.decimalfield = 10.0m; obj.stringfield = null; var createdResponse = await (new CreateObjectRequest() { Object = obj }).ExecuteAsync(); Assert.IsNotNull(createdResponse, "Object creation failed."); Assert.IsNotNull(createdResponse.Status, "Status is null."); Assert.IsTrue(createdResponse.Status.IsSuccessful, createdResponse.Status.Message ?? "Create apObject failed."); var created = createdResponse.Object; // Update the apObject twice for (int i = 0; i < 2; i++) { var updateRequest = new UpdateObjectRequest() { Id = created.Id, Type = created.Type }; updateRequest.PropertyUpdates["stringfield"] = null; var updatedResponse = await updateRequest.ExecuteAsync(); Assert.IsNotNull(updatedResponse, "Update apObject response is null."); Assert.IsNotNull(updatedResponse.Status, "Update apObject response status is null."); Assert.IsTrue(updatedResponse.Status.IsSuccessful, updatedResponse.Status.Message ?? "NULL"); Assert.IsNotNull(updatedResponse.Object, "Updated apObject is null."); var updated = updatedResponse.Object; Assert.IsTrue(updated["stringfield"] is NullValue); } }
public async Task UpdateObjectAsyncTest() { // Create an apObject var now = DateTime.Now; dynamic obj = new APObject("object"); obj.intfield = 1; obj.decimalfield = 10.0m; obj.datefield = "2012-12-20"; obj.stringfield = "initial"; obj.Tags.Add("initial"); var createdResponse = await (new CreateObjectRequest() { Object = obj }).ExecuteAsync(); Assert.IsNotNull(createdResponse, "Object creation failed."); Assert.IsNotNull(createdResponse.Status, "Status is null."); Assert.IsTrue(createdResponse.Status.IsSuccessful, createdResponse.Status.Message ?? "Create apObject failed."); var created = createdResponse.Object; // Update the apObject var updateRequest = new UpdateObjectRequest() { Id = created.Id, Type = created.Type }; updateRequest.PropertyUpdates["intfield"] = "2"; updateRequest.PropertyUpdates["decimalfield"] = 20.0m.ToString(); updateRequest.PropertyUpdates["stringfield"] = null; updateRequest.PropertyUpdates["datefield"] = "2013-11-20"; updateRequest.AddedTags.AddRange(new[] {"tag1", "tag2"}); updateRequest.RemovedTags.AddRange(new[] {"initial"}); var updatedResponse = await updateRequest.ExecuteAsync(); Assert.IsNotNull(updatedResponse, "Update apObject response is null."); Assert.IsNotNull(updatedResponse.Status, "Update apObject response status is null."); Assert.IsNotNull(updatedResponse.Object, "Updated apObject is null."); var updated = updatedResponse.Object; Assert.IsTrue(updated.Get<string>("intfield") == "2"); Assert.IsTrue(updated.Get<decimal>("decimalfield") == 20.0m); Assert.IsTrue(updated.Get<string>("stringfield") == null); Assert.IsTrue(updated.Get<string>("datefield") == "2013-11-20"); Assert.IsTrue(updated.Tags.Count() == 2); Assert.IsTrue(updated.Tags.Intersect(new[] {"tag1", "tag2"}).Count() == 2); }
public IAsyncResult BeginUpdateObject(UpdateObjectRequest request, AsyncCallback callback, object state) { return(invokeUpdateObject <UpdateObjectResponse>(request, callback, state, false)); }
private UpdateObjectRequest CreateUpdateRequest(EntityChanges changes, int specificRevision, ApiOptions options) { var request = new UpdateObjectRequest { Id = this.Id, Type = this.Type }; ApiOptions.Apply(request, options); request.Revision = specificRevision; if (changes.PropertyUpdates != null && changes.PropertyUpdates.Count > 0) changes.PropertyUpdates.For(x => request.PropertyUpdates[x.Key] = x.Value); if (changes.AttributeUpdates != null && changes.AttributeUpdates.Count > 0) changes.AttributeUpdates.For(x => request.AttributeUpdates[x.Key] = x.Value); if (changes.AddedTags != null) request.AddedTags.AddRange(changes.AddedTags); if (changes.RemovedTags != null) request.RemovedTags.AddRange(changes.RemovedTags); // Check if acls are to be added request.AllowClaims.AddRange(this.Acl.Allowed); request.DenyClaims.AddRange(this.Acl.Denied); request.ResetClaims.AddRange(this.Acl.Reset); return request; }