Beispiel #1
0
 /// <summary>
 /// returns Shipping total
 /// </summary>
 /// <param name="inventoryType"></param>
 /// <returns></returns>
 public static BaseResponseDto <EstimateDeliveryPricePayloadDto> GetOrderShippingTotal(ShoppingCartInfo cart)
 {
     try
     {
         EstimateDeliveryPriceRequestDto estimationdto = GetEstimationDTO(cart);
         return(CallEstimationService(estimationdto));
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("ShoppingCartHelper", "GetOrderTotal", ex.Message);
         return(null);
     }
 }
 /// <summary>
 /// gets Shipping cost response
 /// </summary>
 /// <returns></returns>
 private BaseResponseDto<EstimateDeliveryPricePayloadDto> GetShippingResponse()
 {
     try
     {
         EstimateDeliveryPriceRequestDto estimationdto = ShoppingCartHelper.GetEstimationDTO(Cart);
         return ShoppingCartHelper.CallEstimationService(estimationdto);
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("Kadena_CMSWebParts_Kadena_Cart_DistributorCartDetails", "OnPreRender", ex.Message);
         return null;
     }
 }
Beispiel #3
0
 public static object GetCartTotalByInventoryType(EvaluationContext context, params object[] parameters)
 {
     try
     {
         int userID         = ValidationHelper.GetInteger(parameters[1], default(int));
         int inventoryType  = ValidationHelper.GetInteger(parameters[2], default(int));
         int openCampaignID = ValidationHelper.GetInteger(parameters[3], default(int));
         if (inventoryType == (Int32)ProductType.PreBuy)
         {
             var query = new DataQuery(SQLQueries.getShoppingCartTotal);
             QueryDataParameters queryParams = new QueryDataParameters();
             queryParams.Add("@ShoppingCartUserID", userID);
             queryParams.Add("@ShoppingCartInventoryType", inventoryType);
             queryParams.Add("@ShoppingCartCampaignID", openCampaignID);
             var cartTotal = ConnectionHelper.ExecuteScalar(query.QueryText, queryParams, QueryTypeEnum.SQLQuery, true);
             return(ValidationHelper.GetDecimal(cartTotal, default(decimal)));
         }
         else
         {
             var     loggedInUSerCartIDs = ShoppingCartHelper.GetCartsByUserID(userID, ProductType.GeneralInventory, openCampaignID);
             decimal cartTotal           = 0;
             loggedInUSerCartIDs.ForEach(cartID =>
             {
                 var Cart = ShoppingCartInfoProvider.GetShoppingCartInfo(cartID);
                 if (Cart.ShippingOption != null && Cart.ShippingOption.ShippingOptionCarrierServiceName.ToLower() != ShippingOption.Ground)
                 {
                     EstimateDeliveryPriceRequestDto estimationdto = ShoppingCartHelper.GetEstimationDTO(Cart);
                     var estimation = ShoppingCartHelper.CallEstimationService(estimationdto);
                     cartTotal     += ValidationHelper.GetDecimal(estimation?.Payload?.Cost, default(decimal));
                 }
             });
             return(ValidationHelper.GetDecimal(cartTotal, default(decimal)));
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogInformation("Kadena Macro methods", "BindPrograms", ex.Message);
         return(default(double));
     }
 }
Beispiel #4
0
        protected BaseResponseDto <EstimateDeliveryPricePayloadDto> CallEstimationService(EstimateDeliveryPriceRequestDto requestBody)
        {
            var response = microserviceClient.EstimateShippingCost(requestBody).Result;

            if (!response.Success || response.Payload == null)
            {
                EventLogProvider.LogInformation("DeliveryPriceEstimationClient", "ERROR", $"Call from '{CarrierProviderName}' provider to service URL '{ServiceUrl}' resulted with error {response.Error?.Message ?? string.Empty}");
            }

            return(response);
        }
        public async Task <BaseResponseDto <EstimateDeliveryPricePayloadDto> > EstimateShippingCost(EstimateDeliveryPriceRequestDto requestBody)
        {
            var url = _properties.GetServiceUrl(_serviceUrlSettingKey);

            url = $"{url}/api/shippingcosts";
            return(await Post <EstimateDeliveryPricePayloadDto>(url, requestBody).ConfigureAwait(false));
        }
 public string GetRequestString(EstimateDeliveryPriceRequestDto request)
 {
     return(SerializeRequestContent(request));
 }
Beispiel #7
0
        /// <summary>
        /// Calling shipping estimation service
        /// </summary>
        /// <param name="requestBody"></param>
        /// <returns></returns>
        public static BaseResponseDto <EstimateDeliveryPricePayloadDto> CallEstimationService(EstimateDeliveryPriceRequestDto requestBody)
        {
            try
            {
                var microserviceClient = DIContainer.Resolve <IShippingCostServiceClient>();
                var response           = microserviceClient.EstimateShippingCost(requestBody).Result;

                if (!response.Success || response.Payload == null)
                {
                    EventLogProvider.LogInformation("DeliveryPriceEstimationClient", "ERROR", $"Call from '{Cart.ShippingOption.ShippingOptionName}' provider to service URL '{SettingsKeyInfoProvider.GetValue($"{SiteContext.CurrentSiteName}.{_serviceUrlShippingSettingKey}")}' resulted with error {response.Error?.Message ?? string.Empty}");
                }
                return(response);
            }
            catch (Exception ex)
            {
                EventLogProvider.LogInformation("ShoppingCartHelper", "CallEstimationService", ex.Message);
                return(null);
            }
        }