public CustomerInfoModel() { this.AvailableTimeZones = new List <SelectListItem>(); this.AvailableCountries = new List <SelectListItem>(); this.AvailableStates = new List <SelectListItem>(); this.AssociatedExternalAuthRecords = new List <AssociatedExternalAuthModel>(); this.CustomerAttributes = new List <CustomerAttributeModel>(); CustomerReward = new CustomerRewardPointsModel(); ChangePassword = new ChangePasswordModel(); }
public ActionResult RewardPoints() { if (!IsCurrentUserRegistered()) return new HttpUnauthorizedResult(); if (!_rewardPointsSettings.Enabled) return RedirectToRoute("CustomerInfo"); var customer = _workContext.CurrentCustomer; var model = new CustomerRewardPointsModel(); model.NavigationModel = GetCustomerNavigationModel(customer); model.NavigationModel.SelectedTab = CustomerNavigationEnum.RewardPoints; foreach (var rph in customer.RewardPointsHistory.OrderByDescending(rph => rph.CreatedOnUtc).ThenByDescending(rph => rph.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 = customer.GetRewardPointsBalance(); 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); }