当前位置: 首页>>代码示例>>C#>>正文


C# List.AsEnumerable方法代码示例

本文整理汇总了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;
        }
开发者ID:winmissupport,项目名称:FeatureUpate,代码行数:56,代码来源:Orders.cs


注:本文中的Common.List.AsEnumerable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。