public async Task <Entity> UpdateAsync(Entity entity) { var updateRequest = new updateRequest(_autotaskIntegrations, new[] { entity }); var updateResponse = await _autoTaskClient.updateAsync(updateRequest).ConfigureAwait(false); var errorCount = updateResponse.updateResult.Errors.Length; if (errorCount > 0) { _logger.LogError($"There was an error updating the entity. {errorCount} errors occurred."); for (var errorNum = 0; errorNum < errorCount; errorNum++) { _logger.LogError($"Error {errorNum + 1}: {updateResponse.updateResult.Errors[errorNum].Message}"); } _logger.LogError("Entity: " + JsonConvert.SerializeObject(entity)); throw new AutoTaskApiException(BuildExceptionMessage($"Errors occurred during update of the AutoTask entity: {string.Join(";", updateResponse.updateResult.Errors.Select(e => e.Message))}")); } var updatedEntity = updateResponse?.updateResult?.EntityResults?.FirstOrDefault(); _logger.LogDebug($"Successfully updated entity with Id: {updatedEntity?.id.ToString() ?? "UNKNOWN!"}"); if (updatedEntity == null) { throw new AutoTaskApiException(BuildExceptionMessage("Did not get a result back after updating the AutoTask entity.")); } return(updatedEntity); }
public async Task <Entity[]> UpdateAsync(Entity[] entityArray, CancellationToken cancellationToken = default) { var updateRequest = new updateRequest(_autotaskIntegrations, entityArray); var updateResponse = await(await GetATWSSoapClientAsync(cancellationToken).ConfigureAwait(false)) .updateAsync(updateRequest) .WithCancellation(cancellationToken) .ConfigureAwait(false); var errorCount = updateResponse.updateResult.Errors.Length; if (errorCount > 0) { _logger.LogError($"There was an error updating the entity. {errorCount} errors occurred."); for (var errorNum = 0; errorNum < errorCount; errorNum++) { _logger.LogError($"Error {errorNum + 1}: {updateResponse.updateResult.Errors[errorNum].Message}"); } _logger.LogError("Entity: " + JsonConvert.SerializeObject(entityArray)); throw new AutoTaskApiException(BuildExceptionMessage($"Errors occurred during update of the AutoTask entity: {string.Join(";", updateResponse.updateResult.Errors.Select(e => e.Message))}")); } var updatedEntities = updateResponse?.updateResult?.EntityResults; if (updatedEntities is null) { throw new AutoTaskApiException(BuildExceptionMessage("Did not get a result back after updating the AutoTask entities.")); } if (entityArray.Length != updatedEntities.Length) { throw new AutoTaskApiException(BuildExceptionMessage($"Did not receive the expected update entity count (expected {entityArray.Length}, received {updatedEntities.Length}).")); } _logger.LogDebug($"Updated {updatedEntities.Length} {(updatedEntities.Length == 1 ? "entity" : "entities")}: ({string.Join(", ", updatedEntities.Select(e => e.id.ToString() ?? "?"))})"); return(updatedEntities); }
public virtual async System.Threading.Tasks.Task <WriteResponse> updateAsync(Record record) { var request = new updateRequest() { passport = passport, tokenPassport = tokenPassport, applicationInfo = applicationInfo, partnerInfo = partnerInfo, preferences = preferences, record = record, }; var response = await((NetSuitePortType)this).updateAsync(request); return(response.writeResponse); }
public IActionResult updateOrder(updateRequest request, int v) { User user = context.User.Where(s => s.UserId == v).FirstOrDefault(); if (user == null) { return(new BadRequestResult()); } Order order = context.Order.Where(s => s.OrderId == request.orderID && s.UserId == v).FirstOrDefault(); if (order == null) { return(new BadRequestResult()); } order.OrderTotal = request.OrderTotal; order.Status = request.Status; context.Order.Add(order); context.SaveChanges(); foreach (var item in request.orderDetail) { OrderDetail detail = context.OrderDetail.Where(s => s.ProductId == item.ProductId).FirstOrDefault(); if (detail != null) { detail.Quantity = item.Quantity; detail.TotalPrice = item.TotalPrice; context.SaveChanges(); } else { detail = new OrderDetail(); detail.OrderId = order.OrderId; detail.ProductId = item.ProductId; detail.TotalPrice = item.TotalPrice; detail.Quantity = item.Quantity; context.OrderDetail.Add(detail); context.SaveChanges(); } } return(new OkObjectResult(order)); }