Esempio n. 1
0
            private static List <DonationViewModel> PopulateDonation(MyHLShoppingCartView request)
            {
                List <DonationViewModel> result;

                if (request.DonationAmount > 0)
                {
                    result = new List <DonationViewModel>();
                    DonationViewModel donation;

                    if (request.OnBehalfDonationAmount > 0)
                    {
                        donation             = new DonationViewModel();
                        donation.Amount      = request.OnBehalfDonationAmount;
                        donation.Name        = request.OnBehalfDonationName;
                        donation.PhoneNumber = request.OnBehalfDonationContact;
                        donation.Type        = "OnBehalf";
                        result.Add(donation);
                    }

                    if (request.SelfDonationAmount > 0)
                    {
                        donation        = new DonationViewModel();
                        donation.Amount = request.SelfDonationAmount;
                        donation.Name   = request.SelfDonationMemberId;
                        donation.Type   = "Self";
                        result.Add(donation);
                    }

                    return(result);
                }
                return(null);
            }
Esempio n. 2
0
        private List <MyHLShoppingCartView> GetOrdersByOrderNumber(string memberId, string locale, string orderNumber,
                                                                   DateTime startDate, DateTime endDate)
        {
            var shoppingCartViews = new List <MyHLShoppingCartView>();

            if (!string.IsNullOrEmpty(orderNumber))
            {
                var customerProfileId =
                    DistributorOrderingProfileProvider.GetProfile(memberId, locale.Substring(3, 2)).CNCustomorProfileID;
                var shoppingCartView = new MyHLShoppingCartView();

                var proposedStartDate = DateTime.Now.AddMonths(-12);
                //DateTime startDate = new DateTime(proposedStartDate.Year, proposedStartDate.Month, proposedStartDate.Day); //ensure the time is the start of the day, which is 00:00:00
                //DateTime endDate = DateTime.Now;

                shoppingCartViews = shoppingCartView.GetOrdersWithDetail(memberId, customerProfileId, locale, startDate,
                                                                         endDate, OrderStatusFilterType.All, "", "", false, false, orderNumber);

                if (shoppingCartViews.Count > 0)
                {
                    return(shoppingCartViews.FindAll(oi => oi.OrderNumber == orderNumber));
                }
            }

            return(shoppingCartViews);
        }
Esempio n. 3
0
            public static OrderViewModel ConvertShoppingCartViewToOrderViewModel(MyHLShoppingCartView request,
                                                                                 string locale)
            {
                DateTime date;

                DateTime.TryParse(request.Date, out date);
                var countryCode = locale.Substring(3);

                var item = new OrderViewModel
                {
                    OrderItems      = ConvertToOrderItemViewModel(request.CartItems),
                    OrderMonth      = request.OrderMonth,
                    CategoryType    = string.Empty,
                    Shipping        = PopulateShipping(request, locale),
                    Donations       = PopulateDonation(request),
                    Quote           = PopulateQuote(request),
                    CreatedDate     = DateUtils.GetGMTDateTime(countryCode, request.DateTimeForOrder),
                    LastUpdatedDate = DateUtils.GetGMTDateTime(countryCode, request.DateTimeForOrder),
                    MemberId        = request.DistributorID,
                    CustomerId      = request.DistributorID,
                    Id                  = Guid.Empty,
                    Locale              = string.Empty,
                    Status              = TranslateStatus(request.OrderStatus),
                    StatusForDisplay    = request.OrderStatus,
                    OrderNumber         = request.OrderNumber,
                    CountryOfProcessing = countryCode,
                    CopyEnabled         = request.IsCopyEnabled
                };

                return(item);
            }
Esempio n. 4
0
            private static OrderTotalsViewModel PopulateQuote(MyHLShoppingCartView request)
            {
                var quote = new OrderTotalsViewModel
                {
                    AmountDue           = request.TotalAmountValue + request.FreightCharges,
                    VolumePoints        = request.VolumePointsValue,
                    ProductTaxTotal     = request.ProductTaxTotal,
                    ChargeFreightAmount = request.FreightCharges,
                    DiscountAmount      = request.DiscountAmount,
                    LineItems           = PopulateLineItems(request.CartItems)
                };

                return(quote);
            }
Esempio n. 5
0
        private List <MyHLShoppingCartView> GetOrderList(string memberId, string locale, DateTime?from, DateTime?to,
                                                         bool check3Months = false)
        {
            var shoppingCartView  = new MyHLShoppingCartView();
            var customerProfileId =
                DistributorOrderingProfileProvider.GetProfile(memberId, locale.Substring(3, 2)).CNCustomorProfileID;
            var filterExpressions = string.Empty;
            var sortExpressions   = string.Empty;
            var countryCode       = locale.Substring(3, 2);
            var localNow          = DateUtils.GetCurrentLocalTime(countryCode);

            if (check3Months)
            {
                from = localNow.AddMonths(-3);
                to   = localNow;
            }
            else
            {
                if (!from.HasValue)
                {
                    if (to.HasValue)
                    {
                        from = to.Value.AddMonths(-3);
                    }
                    else
                    {
                        from = localNow.AddMonths(-3);
                    }
                }

                if (!to.HasValue)
                {
                    if (from.HasValue)
                    {
                        to = from.Value.AddMonths(3);
                    }
                    else
                    {
                        to = localNow;
                    }
                }
            }

            var result = shoppingCartView.GetOrdersWithDetail(memberId, customerProfileId, locale, from.Value, to.Value,
                                                              OrderStatusFilterType.All, "", "");

            return(result);
        }
Esempio n. 6
0
        public static MyHlResultViewResult GetData(
            int startIndex,
            int maximumRows,
            string sortExpressions,
            string filterExpressions,
            bool copyOrderMode,
            int copyOrderIndex,
            int copyOrderMaxLength)
        {
            try
            {
                bool indexChanged = StaticCopyOrderIndex != copyOrderIndex;

                StaticCopyOrderIndex     = copyOrderIndex;
                StaticCopyOrderMaxLength = copyOrderMaxLength;

                // Getting saved carts or shopping carts history from the shopping cart provider.
                var myHlShoppingCarts = copyOrderMode
                                            ? ShoppingCartProvider.GetInternetShoppingCarts(StaticDistributorID,
                                                                                            StaticLocale,
                                                                                            StaticCopyOrderIndex,
                                                                                            StaticCopyOrderMaxLength,
                                                                                            indexChanged)
                                            : ShoppingCartProvider.GetCarts(StaticDistributorID, StaticLocale);

                var cartViewList = MyHLShoppingCartView.WrappToShoppingCartViewList(myHlShoppingCarts, StaticLocale,
                                                                                    filterExpressions, sortExpressions,
                                                                                    !copyOrderMode);

                // Getting the range.
                int totalRows = cartViewList.Count;
                var maxRows   = startIndex + maximumRows > cartViewList.Count
                                  ? cartViewList.Count - startIndex
                                  : maximumRows;
                cartViewList = cartViewList.GetRange(maxRows >= 0 ? startIndex : 0, maxRows >= 0 ? maxRows : 0);

                return(new MyHlShoppingCartViewResult(totalRows, cartViewList));
            }
            catch (Exception ex)
            {
                LoggerHelper.Error(ex.ToString());
                throw ex;
            }
        }
            public MyHLShoppingCartView GetTarget(List <OnlineOrder> orders)
            {
                var chinaOrderProxy = Substitute.For <IChinaInterface>();

                chinaOrderProxy.GetOrdersWithDetail(new GetOrdersWithDetailRequest(Arg.Any <GetOrdersRequest_V02>())).GetOrdersWithDetailResult
                .Returns(new GetOrdersResponse_V01()
                {
                    Status = ServiceProvider.OrderChinaSvc.ServiceResponseStatusType.Success,
                    Orders = orders
                });

                var catalogLoader = Substitute.For <ICatalogProviderLoader>();

                catalogLoader.GetCatalog("CN").Returns(GetChinaCatalog());

                var target = new MyHLShoppingCartView(chinaOrderProxy, catalogLoader);

                return(target);
            }
            public MyHLShoppingCartView GetTarget(List <OnlineOrder> orders)
            {
                var chinaOrderProxy = Substitute.For <IChinaInterface>();

                chinaOrderProxy.GetPreOrders(new GetPreOrdersRequest1(Arg.Any <GetPreOrdersRequest_V01>())).GetPreOrdersResult
                .Returns(new GetPreOrdersResponse_V01()
                {
                    Status = ServiceProvider.OrderChinaSvc.ServiceResponseStatusType.Success,
                    Orders = orders
                });

                var orderDetail = PreOrderDetail(orders.FirstOrDefault());

                var orderChinaProvider = Substitute.For <IOrderChinaProviderLoader>();

                orderChinaProvider.GetPreOrderDetail(Arg.Any <string>(), Arg.Any <int>()).Returns(orderDetail);

                var target = new MyHLShoppingCartView(chinaOrderProxy, null, orderChinaProvider);

                return(target);
            }
Esempio n. 9
0
            private static ShippingViewModel PopulateShipping(MyHLShoppingCartView request, string locale)
            {
                var shipping = new ShippingViewModel
                {
                    Address = new AddressViewModel
                    {
                        City = request.AddressValue.City,
                        StateProvinceTerritory = request.AddressValue.StateProvinceTerritory,
                        CountyDistrict         = request.AddressValue.CountyDistrict,
                        Line1      = request.AddressValue.Line1,
                        Line2      = request.AddressValue.Line2,
                        Line3      = request.AddressValue.Line3,
                        Line4      = request.AddressValue.Line4,
                        Country    = request.AddressValue.Country,
                        PostalCode = request.AddressValue.PostalCode
                    },
                    Recipient        = request.Recipient,
                    StoreName        = request.StoreInfo,
                    Phone            = request.Phone,
                    WarehouseCode    = request.WarehouseCode,
                    ShippingMethodId = request.ShippingMethodId
                };


                //Code to add Delivery Option

                var cartfromsql =
                    ShoppingCartProvider.GetShoppingCartFromV02(request.DistributorID, locale, int.Parse(request.ID)) as
                    ShoppingCart_V02;

                if (cartfromsql != null)
                {
                    shipping.DeliveryType     = cartfromsql.DeliveryOption.ToString();
                    shipping.DeliveryOptionId = cartfromsql.DeliveryOptionID;
                }

                return(shipping);
            }
Esempio n. 10
0
        public List <OrderViewModel> GetOrders(OrderSearchParameter request)
        {
            List <OrderViewModel> result = null;

            #region validation

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

            #endregion

            var countryCode = request.Locale.Substring(3, 2);
            var localNow    = DateUtils.GetCurrentLocalTime(countryCode);

            var defaultStartDate = localNow.AddMonths(-12);
            var defaultEndDate   = localNow;

            DateTime startDate = request.From ?? defaultStartDate;
            DateTime endDate   = request.To ?? defaultEndDate;

            if (!string.IsNullOrEmpty(request.OrderNumber))
            {
                var orderViewmodelsByOrderNumber = new List <OrderViewModel>();
                var orders = GetOrdersByOrderNumber(request.MemberId, request.Locale, request.OrderNumber, startDate,
                                                    endDate);
                var addressGuid = Guid.Empty;
                var country     = string.Empty;
                if (null != orders && orders.Any())
                {
                    if (orders.Count == 1)
                    {
                        var mobileQuoteHelper = new MobileQuoteHelper();
                        var shoppingCart      = mobileQuoteHelper.GetShoppingCart(request.OrderNumber, Guid.Empty);
                        if (null != shoppingCart && shoppingCart.DeliveryOption == DeliveryOptionType.Shipping)
                        {
                            var addressId = shoppingCart.ShippingAddressID;
                            if (addressId > 0)
                            {
                                var shippingProvider =
                                    ShippingProvider.GetShippingProvider(countryCode);
                                if (null != shippingProvider)
                                {
                                    var address = shippingProvider.GetShippingAddressFromAddressGuidOrId(Guid.Empty,
                                                                                                         addressId);
                                    addressGuid = null != address ? address.AddressId : Guid.Empty;
                                    country     = null != address && null != address.Address
                                        ? address.Address.Country
                                        : string.Empty;
                                }
                            }
                        }
                    }
                    orderViewmodelsByOrderNumber.AddRange(
                        orders.Select(
                            item => ModelConverter.ConvertShoppingCartViewToOrderViewModel(item, request.Locale)));
                    if (addressGuid != Guid.Empty && null != orderViewmodelsByOrderNumber &&
                        orderViewmodelsByOrderNumber.Any() && orderViewmodelsByOrderNumber.Count == 1 &&
                        null != orderViewmodelsByOrderNumber[0].Shipping &&
                        null != orderViewmodelsByOrderNumber[0].Shipping.Address)
                    {
                        orderViewmodelsByOrderNumber[0].Shipping.Address.CloudId = addressGuid;
                        orderViewmodelsByOrderNumber[0].Shipping.Address.Country = country;
                        if (request.Locale == "zh-CN")
                        {
                            orderViewmodelsByOrderNumber[0].Shipping.FreightVariant =
                                GetFreightVariant(orderViewmodelsByOrderNumber[0].Shipping.DeliveryType);
                        }
                    }
                }
                return(orderViewmodelsByOrderNumber);
            }
            List <MyHLShoppingCartView> orderList;
            var shoppingCartView  = new MyHLShoppingCartView();
            var customerProfileId =
                DistributorOrderingProfileProvider.GetProfile(request.MemberId, countryCode).CNCustomorProfileID;

            //var proposedStartDate = DateTime.Now.AddMonths(-6);
            //DateTime startDate = new DateTime(proposedStartDate.Year, proposedStartDate.Month, proposedStartDate.Day); //ensure the time is the start of the day, which is 00:00:00
            //DateTime endDate = DateTime.Now;

            orderList = shoppingCartView.GetOrdersWithDetail(request.MemberId, customerProfileId, request.Locale,
                                                             startDate, endDate, OrderStatusFilterType.All, "", "");

            if (orderList != null)
            {
                if (request.PageSize > 0 && orderList.Any())
                {
                    var paged = orderList.Skip((request.PageNumber) * request.PageSize).Take(request.PageSize);
                    if (null != paged && paged.Any())
                    {
                        orderList = paged.ToList();
                    }
                    else
                    {
                        orderList = new List <MyHLShoppingCartView>();
                    }
                }

                result = new List <OrderViewModel>();

                foreach (var itm in orderList)
                {
                    var newItem = ModelConverter.ConvertShoppingCartViewToOrderViewModel(itm, request.Locale);
                    result.Add(newItem);
                }
            }

            return(result);
        }