示例#1
0
 public void PopulateDeliveryPlans(ref BasketModel basket, string requestSource)
 {
     // MA : discussed with Sir, to update the delivery plans only from basket index page and checkout page and only when delivery plan is updated
     requestSource = string.IsNullOrEmpty(requestSource) ? "" : requestSource.ToLower();
     if (basket != null && !string.IsNullOrEmpty(basket.ShippingMethodId) && (requestSource == "index" || requestSource == "opc" || requestSource == "basket"))
     {
         var shippingId     = basket.ShippingMethodId;
         var shippingMethod = basket.ShippingMethods?.FirstOrDefault(sp => sp.Id.ToString() == shippingId);
         ShippingPlanRequest shippingPlanRequest = new ShippingPlanRequest()
         {
             BasketId = Guid.Parse(basket.Id),
             PostCode = basket.PostCode,
             AllowPartialOrderDelivery = true,
             AllowPartialLineDelivery  = true,
             ShippingMethodId          = Guid.Parse(basket.ShippingMethodId),
             ShippingMethodName        = shippingMethod?.DisplayName,
             ShippingMethodCode        = shippingMethod?.ShippingCode,
             ShippingMethodType        = (shippingMethod == null) ? ShippingMethodTypes.Standard : shippingMethod.Type,
             DeliveryItems             = (from ol in basket.LineItems
                                          select new DeliveryItemLine()
             {
                 BasketLineId = Convert.ToInt64(ol.Id),
                 ProductId = Guid.Parse(ol.ProductId),
                 ParentProductId = Guid.Parse(ol.ParentProductId),
                 StockCode = ol.StockCode,
                 Qty = ol.Qty
             }
                                          ).ToList()
         };
         var _shippingApi     = DependencyResolver.Current.GetService <IShippingApi>();
         var shipmentResponse = _shippingApi.GetShippingPlans(shippingPlanRequest);
         if (shipmentResponse != null && shipmentResponse.Result != null)
         {
             var shipmentPlans = shipmentResponse.Result;
             foreach (ShippingPlan plan in shipmentPlans)
             {
                 plan.LineItems = basket.LineItems.Where(li => plan.Items.Any(pi => li.StockCode == pi.StockCode)).ToList();
             }
             basket.DeliveryPlans = shipmentPlans;
             var updateResponse = CallApi <BoolResponse>(string.Format(ApiUrls.UpdateBasketDeliveryPlans, basket.Id), JsonConvert.SerializeObject(shipmentPlans), Method.POST);
         }
     }
     ResetSessionBasket(); // reset the session basket  so as to get the latest info from api.
 }
        public ActionResult GetClickAndCollectOptions(string basketId, string postCode)
        {
            var basket  = _basketApi.GetBasketData(basketId);
            var request = new ShippingPlanRequest {
                PostCode = postCode, DeliveryItems = new List <DeliveryItemLine>()
            };
            int lineId = 1;

            foreach (var item in basket.Result.LineItems)
            {
                var line = new DeliveryItemLine {
                    StockCode = item.StockCode, Qty = item.Qty
                };
                request.DeliveryItems.Add(line);
                lineId++;
            }
            var stores = _shippingApi.GetClickAndCollectStores(request);

            return(JsonSuccess(stores.Result, JsonRequestBehavior.AllowGet));
        }
示例#3
0
 public ResponseModel <List <StoreModel> > GetClickAndCollectStores(ShippingPlanRequest shippingPlanRequest)
 {
     return(CallApi <List <StoreModel> >(string.Format(ApiUrls.ClickAndCollectStores, shippingPlanRequest.PostCode), JsonConvert.SerializeObject(shippingPlanRequest), Method.POST, apiBaseUrl: ConfigKeys.OmsApiBaseUrl, isAuthenticationEnabled: true));
 }
示例#4
0
 public ResponseModel <List <ShippingPlan> > GetShippingPlans(ShippingPlanRequest shippingPlanRequest)
 {
     return(CallApi <List <ShippingPlan> >(ApiUrls.ShippingPlans, JsonConvert.SerializeObject(shippingPlanRequest), Method.POST, apiBaseUrl: ConfigKeys.OmsApiBaseUrl, isAuthenticationEnabled: true));
 }