public virtual async Task <CustomerRewardPointsModel> PrepareCustomerRewardPoints(Customer customer)
        {
            var model = new CustomerRewardPointsModel();

            foreach (var rph in await _rewardPointsService.GetRewardPointsHistory(customer.Id))
            {
                model.RewardPoints.Add(new CustomerRewardPointsModel.RewardPointsHistoryModel
                {
                    Points        = rph.Points,
                    PointsBalance = rph.PointsBalance,
                    Message       = rph.Message,
                    CreatedOn     = _dateTimeHelper.ConvertToUserTime(rph.CreatedOnUtc, DateTimeKind.Utc)
                });
            }
            //current amount/balance
            int rewardPointsBalance = await _rewardPointsService.GetRewardPointsBalance(customer.Id, _storeContext.CurrentStore.Id);

            decimal rewardPointsAmountBase = await _orderTotalCalculationService.ConvertRewardPointsToAmount(rewardPointsBalance);

            decimal rewardPointsAmount = await _currencyService.ConvertFromPrimaryStoreCurrency(rewardPointsAmountBase, _workContext.WorkingCurrency);

            model.RewardPointsBalance = rewardPointsBalance;
            model.RewardPointsAmount  = _priceFormatter.FormatPrice(rewardPointsAmount, true, false);
            //minimum amount/balance
            int     minimumRewardPointsBalance    = _rewardPointsSettings.MinimumRewardPointsToUse;
            decimal minimumRewardPointsAmountBase = await _orderTotalCalculationService.ConvertRewardPointsToAmount(minimumRewardPointsBalance);

            decimal minimumRewardPointsAmount = await _currencyService.ConvertFromPrimaryStoreCurrency(minimumRewardPointsAmountBase, _workContext.WorkingCurrency);

            model.MinimumRewardPointsBalance = minimumRewardPointsBalance;
            model.MinimumRewardPointsAmount  = _priceFormatter.FormatPrice(minimumRewardPointsAmount, true, false);

            return(model);
        }
        public ActionResult CustomerRewardPoints()
        {
            if (!_workContext.CurrentCustomer.IsRegistered())
            {
                return(new HttpUnauthorizedResult());
            }

            if (!_rewardPointsSettings.Enabled)
            {
                return(RedirectToRoute("CustomerInfo"));
            }

            var customer = _workContext.CurrentCustomer;

            var model = new CustomerRewardPointsModel();

            foreach (var rph in _rewardPointsService.GetRewardPointsHistory(customer.Id))
            {
                model.RewardPoints.Add(new CustomerRewardPointsModel.RewardPointsHistoryModel
                {
                    Points        = rph.Points,
                    PointsBalance = rph.PointsBalance,
                    Message       = rph.Message,
                    CreatedOn     = _dateTimeHelper.ConvertToUserTime(rph.CreatedOnUtc, DateTimeKind.Utc)
                });
            }
            //current amount/balance
            int     rewardPointsBalance    = _rewardPointsService.GetRewardPointsBalance(customer.Id, _storeContext.CurrentStore.Id);
            decimal rewardPointsAmountBase = _orderTotalCalculationService.ConvertRewardPointsToAmount(rewardPointsBalance);
            decimal rewardPointsAmount     = _currencyService.ConvertFromPrimaryStoreCurrency(rewardPointsAmountBase, _workContext.WorkingCurrency);

            model.RewardPointsBalance = rewardPointsBalance;
            model.RewardPointsAmount  = _priceFormatter.FormatPrice(rewardPointsAmount, true, false);
            //minimum amount/balance
            int     minimumRewardPointsBalance    = _rewardPointsSettings.MinimumRewardPointsToUse;
            decimal minimumRewardPointsAmountBase = _orderTotalCalculationService.ConvertRewardPointsToAmount(minimumRewardPointsBalance);
            decimal minimumRewardPointsAmount     = _currencyService.ConvertFromPrimaryStoreCurrency(minimumRewardPointsAmountBase, _workContext.WorkingCurrency);

            model.MinimumRewardPointsBalance = minimumRewardPointsBalance;
            model.MinimumRewardPointsAmount  = _priceFormatter.FormatPrice(minimumRewardPointsAmount, true, false);
            return(View(model));
        }