protected CustomerRewardPointsModel PrepareCustomerRewardPointsModel(CustomerRewardPointsPagingFilteringModel command) { if (command.SelectedAccountId <= 0) { return(new CustomerRewardPointsModel()); } var model = new CustomerRewardPointsModel(); var result = _accountService.GetPagedRewardPointHistory( accountId: command.SelectedAccountId, pageIndex: command.PageNumber - 1, pageSize: command.PageSize); for (int i = 0; i < result.Items.Count; i++) { var item = result.Items[i]; var itemModel = new RewardPointsHistoryModel { Id = item.Id, Points = item.Points, UsedPoints = item.UsedPoints, PointsBalance = item.PointsBalance, Message = item.Message, CreatedOn = item.CreatedOnDate }; model.RewardPoints.Add(itemModel); } model.PagingFilteringContext.LoadPagedList(result); model.PagingFilteringContext.SelectedAccountId = command.SelectedAccountId; return(model); }
public ActionResult RewardPoints(CustomerRewardPointsPagingFilteringModel command) { if (_workContext.CurrentProfile.IsAnonymous) { return(new HttpUnauthorizedResult()); } var accountId = _accountService.GetAccountIdByProfileId(_workContext.CurrentProfile.Id); command.SelectedAccountId = accountId; var model = PrepareCustomerRewardPointsModel(command); return(View(model)); }