本文整理汇总了C#中Order.GetBrokenRules方法的典型用法代码示例。如果您正苦于以下问题:C# Order.GetBrokenRules方法的具体用法?C# Order.GetBrokenRules怎么用?C# Order.GetBrokenRules使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order.GetBrokenRules方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateOrder
/// <summary>
/// The update order.
/// </summary>
/// <param name="request">
/// The request.
/// </param>
/// <returns>
/// The TdService.Services.Messaging.Order.UpdateOrderResponse.
/// </returns>
public UpdateOrderResponse UpdateOrder(UpdateOrderRequest request)
{
OrderStatus orderStatus;
Enum.TryParse(request.Status, true, out orderStatus);
var order = new Order(orderStatus)
{
Id = request.Id,
CreatedDate = DateTime.UtcNow,
OrderNumber = request.OrderNumber,
TrackingNumber = request.TrackingNumber
};
var response = new UpdateOrderResponse { BrokenRules = order.GetBrokenRules().ToList() };
if (response.BrokenRules.Any())
{
response.MessageType = MessageType.Warning;
return response;
}
try
{
////var orderToUpdate = this.orderRepository.GetOrderById(order.Id);
order.Update(order.OrderNumber, order.TrackingNumber);
var updatedOrder = this.orderRepository.UpdateOrder(order);
response = updatedOrder.ConvertToUpdateOrderResponse();
response.Message = CommonResources.OrderUpdateSuccessMessage;
}
catch (Exception e)
{
response.MessageType = MessageType.Error;
response.ErrorCode = e.Message;
this.Logger.Error(CommonResources.OrderUpdateErrorMessage, e);
}
return response;
}
示例2: ThrowExceptionIfOrderIsInvalid
private static void ThrowExceptionIfOrderIsInvalid(Order order)
{
if (!order.GetBrokenRules().Any()) { return; }
var brokenRules = new StringBuilder();
brokenRules.AppendLine("There were problems saving the order:");
foreach (var businessRule in order.GetBrokenRules())
{
brokenRules.AppendLine(businessRule.Rule);
}
throw new ApplicationException(brokenRules.ToString());
}
示例3: AddOrder
/// <summary>
/// Add new order.
/// </summary>
/// <param name="request">
/// The add new order request.
/// </param>
/// <returns>
/// The add order response.
/// </returns>
public AddOrderResponse AddOrder(AddOrderRequest request)
{
var retailer = new Retailer(request.RetailerUrl);
var newOrder = new Order(OrderStatus.New) { CreatedDate = DateTime.UtcNow, Retailer = retailer };
var response = new AddOrderResponse { BrokenRules = retailer.GetBrokenRules().ToList() };
response.BrokenRules.AddRange(newOrder.GetBrokenRules().ToList());
if (response.BrokenRules.Any())
{
response.MessageType = MessageType.Warning;
return response;
}
try
{
var orderResult = this.orderRepository.AddOrder(request.IdentityToken, newOrder);
response = orderResult.ConvertToAddOrderResponse();
response.Message = CommonResources.OrderAddSuccessMessage;
}
catch (Exception ex)
{
response.MessageType = MessageType.Error;
response.ErrorCode = ex.Message;
this.Logger.Error(CommonResources.OrderAddErrorMessage, ex);
}
return response;
}