Exemplo n.º 1
0
        public static string GetActionType(ActionType actionType, string methodName)
        {
            var value = ActionTypesLocalization.GetFormattedString(actionType.ToString(), methodName);

            if (string.IsNullOrEmpty(value))
            {
                value = ActionTypesLocalization.GetString(ActionType.Unknown.ToString());
            }
            return(value);
        }
Exemplo n.º 2
0
        public static string GetOrderShippingStatus(OrderShippingStatus shippingStatus, string culture = null)
        {
            var value = OrderShippingStatusesLocalization.GetFormattedString(shippingStatus.ToString(), culture);

            if (string.IsNullOrEmpty(value))
            {
                value = OrderShippingStatusesLocalization.GetString(OrderShippingStatus.Unknown.ToString(), culture);
            }
            return(value);
        }
Exemplo n.º 3
0
        public PerformanceInfoJson(PerformanceInfo performanceInfo, SalesPeriod period, ILocalizationHelper localization)
        {
            BouncedName   = localization.GetString("Bounced");
            AbandonedName = localization.GetString("Abandoned");
            PurchasedName = localization.GetString("Purchased");

            BouncedData   = performanceInfo.BouncedData;
            AbandonedData = performanceInfo.AbandonedData;
            PurchasedData = performanceInfo.PurchasedData;

            ChartLabels = performanceInfo.ChartLabels;
            Events      = performanceInfo.Events;

            Views      = performanceInfo.Views.ToString("N0");
            AddsToCart = performanceInfo.AddsToCart.ToString("N0");
            Purchases  = performanceInfo.Purchases.ToString("N0");

            var bouncesPercentageChange = 0D;

            if (performanceInfo.ViewsPrev != 0)
            {
                bouncesPercentageChange = Math.Abs(performanceInfo.Views - performanceInfo.ViewsPrev) /
                                          (double)performanceInfo.ViewsPrev;
            }
            else if (performanceInfo.Views != 0)
            {
                bouncesPercentageChange = 1;
            }
            bouncesPercentageChange = Math.Round(bouncesPercentageChange, 2);
            ViewsPercentageChange   = bouncesPercentageChange.ToString("p0");

            var abandomentsPercentageChange = 0D;

            if (performanceInfo.AddsToCartPrev != 0)
            {
                abandomentsPercentageChange = Math.Abs(performanceInfo.AddsToCart - performanceInfo.AddsToCartPrev) /
                                              (double)performanceInfo.AddsToCartPrev;
            }
            else if (performanceInfo.AddsToCart != 0)
            {
                abandomentsPercentageChange = 1;
            }
            abandomentsPercentageChange = Math.Round(abandomentsPercentageChange, 2);
            AddsToCartPercentageChange  = abandomentsPercentageChange.ToString("p0");

            var purchasesPercentageChange = 0D;

            if (performanceInfo.PurchasesPrev != 0)
            {
                purchasesPercentageChange = Math.Abs(performanceInfo.Purchases - performanceInfo.PurchasesPrev) /
                                            (double)performanceInfo.PurchasesPrev;
            }
            else if (performanceInfo.Purchases != 0)
            {
                purchasesPercentageChange = 1;
            }
            purchasesPercentageChange = Math.Round(purchasesPercentageChange, 2);
            PurchasesPercentageChange = purchasesPercentageChange.ToString("p0");

            var periodString = LocalizationUtils.GetSalesPeriodLower(period);
            var noChange     = localization.GetFormattedString("NoChangeSinceLast", periodString);
            var lessThan     = localization.GetFormattedString("LessSinceLast", periodString);
            var moreThan     = localization.GetFormattedString("MoreSinceLast", periodString);

            ViewsComparison = noChange;
            if (Math.Abs(bouncesPercentageChange) >= 0.01)
            {
                IsViewsGrowing  = performanceInfo.Views >= performanceInfo.ViewsPrev;
                ViewsComparison = IsViewsGrowing.Value ? moreThan : lessThan;
            }

            AddsToCartComparison = noChange;
            if (Math.Abs(abandomentsPercentageChange) >= 0.01)
            {
                IsAddsToCartGrowing  = performanceInfo.AddsToCart >= performanceInfo.AddsToCartPrev;
                AddsToCartComparison = IsAddsToCartGrowing.Value ? moreThan : lessThan;
            }

            PurchasesComparison = noChange;
            if (Math.Abs(purchasesPercentageChange) >= 0.01)
            {
                IsPurchasesGrowing  = performanceInfo.Purchases >= performanceInfo.PurchasesPrev;
                PurchasesComparison = IsPurchasesGrowing.Value ? moreThan : lessThan;
            }
        }
Exemplo n.º 4
0
 public static string GetSalesPeriod(SalesPeriod period)
 {
     return(SalesPeriodsLocalization.GetFormattedString(period.ToString()));
 }