本文整理汇总了C#中Common.List.AsEnumerable方法的典型用法代码示例。如果您正苦于以下问题:C# List.AsEnumerable方法的具体用法?C# List.AsEnumerable怎么用?C# List.AsEnumerable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common.List
的用法示例。
在下文中一共展示了List.AsEnumerable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateOrder
public static OrderCalculationResponse CalculateOrder(OrderCalculationRequest request, bool hasAutoOrder = false)
{
var result = new OrderCalculationResponse();
if (request.Items.Count() == 0) return result;
if (request.Address == null) request.Address = GlobalSettings.Company.Address;
if (request.ShipMethodID == 0) request.ShipMethodID = request.Configuration.DefaultShipMethodID;
var apirequest = new CalculateOrderRequest();
apirequest.WarehouseID = request.Configuration.WarehouseID;
apirequest.CurrencyCode = request.Configuration.CurrencyCode;
apirequest.PriceType = request.Configuration.PriceTypeID;
apirequest.ShipMethodID = request.ShipMethodID;
apirequest.ReturnShipMethods = request.ReturnShipMethods;
apirequest.City = request.Address.City;
apirequest.State = request.Address.State;
apirequest.Zip = request.Address.Zip;
apirequest.Country = request.Address.Country;
apirequest.Details = request.Items.Select(c => new OrderDetailRequest(c)).ToArray();
if(hasAutoOrder){
apirequest.OrderType = Common.Api.ExigoWebService.OrderType.AutoOrder;
}
var apiresponse = Exigo.WebService().CalculateOrder(apirequest);
result.Subtotal = apiresponse.SubTotal;
result.Shipping = apiresponse.ShippingTotal;
result.Tax = apiresponse.TaxTotal;
result.Discount = apiresponse.DiscountTotal;
result.Total = apiresponse.Total;
// Assemble the ship methods
var shipMethods = new List<ShipMethod>();
if (apiresponse.ShipMethods != null && apiresponse.ShipMethods.Length > 0)
{
foreach (var shipMethod in apiresponse.ShipMethods)
{
shipMethods.Add((ShipMethod)shipMethod);
}
// Ensure that at least one ship method is selected
var shipMethodID = (request.ShipMethodID != 0) ? request.ShipMethodID : request.Configuration.DefaultShipMethodID;
if (shipMethods.Any(c => c.ShipMethodID == (int)shipMethodID))
{
shipMethods.First(c => c.ShipMethodID == shipMethodID).Selected = true;
}
else
{
shipMethods.First().Selected = true;
}
}
result.ShipMethods = shipMethods.AsEnumerable();
return result;
}