Exemplo n.º 1
0
        public OrderSummaryResponseViewModel GetOrderList(OrderSummaryRequestViewModel request)
        {
            #region validation

            if (request == null)
            {
                return(null);
            }

            if (string.IsNullOrWhiteSpace(request.Locale) || string.IsNullOrWhiteSpace(request.MemberId))
            {
                return(null);
            }

            #endregion

            var response = new OrderSummaryResponseViewModel
            {
                Pending   = null,
                Completed = null,
                Failed    = null
            };

            if (request.Limit == 0)
            {
                //Set default to 5
                request.Limit = 5;
            }
            var result = GetOrderList(request.MemberId, request.Locale, request.From, request.To);
            response = ModelConverter.ConvertMyHLSCListToOrderSummaryResponse(result, request.Limit, request.Locale);
            return(response);
        }
Exemplo n.º 2
0
            public static OrderSummaryResponseViewModel ConvertMyHLSCListToOrderSummaryResponse(
                List <MyHLShoppingCartView> request, int limit, string locale)
            {
                if (request != null)
                {
                    var response  = new OrderSummaryResponseViewModel();
                    var Pending   = new List <OrderViewModel>();
                    var Failed    = new List <OrderViewModel>();
                    var Completed = new List <OrderViewModel>();

                    foreach (var item in request)
                    {
                        switch (item.OrderStatus)
                        {
                        case "待付款":
                            Pending.Add(ConvertShoppingCartViewToOrderViewModel(item, locale));
                            break;

                        case "取消订单":
                        case "支付失败":
                            Failed.Add(ConvertShoppingCartViewToOrderViewModel(item, locale));
                            break;


                        case "完成":
                        case "支付成功":
                        case "待配送":
                        case "配货中":
                        case "已出库":
                            Completed.Add(ConvertShoppingCartViewToOrderViewModel(item, locale));
                            break;
                        }
                    }
                    response.Pending   = null != Pending && Pending.Any() ? Pending.Take(limit).ToList() : Pending;
                    response.Failed    = null != Failed && Failed.Any() ? Failed.Take(limit).ToList() : Failed;
                    response.Completed = null != Completed && Completed.Any()
                        ? Completed.Take(limit).ToList()
                        : Completed;
                    return(response);
                }

                return(null);
            }