public JsonResult ActiveLoyaltyCards()
        {
            try
            {
                var loyaltyCards = new List<LoyaltyCard>();
                var userResponse = this.AccountManager.GetUser(Context.User.Name);
                var result = new LoyaltyCardsJsonResult(userResponse.ServiceProviderResult);
                if (userResponse.ServiceProviderResult.Success && userResponse.Result != null)
                {
                    loyaltyCards = this.AllCards(result).Take(5).ToList();
                }

                result.Initialize(loyaltyCards);
                return Json(result, JsonRequestBehavior.AllowGet);
            }
            catch (Exception e)
            {
                CommerceLog.Current.Error("ActiveLoyaltyCards", this, e);
                return Json(new BaseJsonResult("ActiveLoyaltyCards", e), JsonRequestBehavior.AllowGet);
            }
        }
        public JsonResult GetLoyaltyCards()
        {
            try
            {
                var loyaltyCards = new List<LoyaltyCard>();
                var userResponse = this.AccountManager.GetUser(Context.User.Name);
                var result = new LoyaltyCardsJsonResult(userResponse.ServiceProviderResult);
                if (userResponse.ServiceProviderResult.Success && userResponse.Result != null)
                {
                    loyaltyCards = this.AllCards(result);
                    if (result.Success)
                    {
                        foreach (var card in loyaltyCards)
                        {
                            foreach (var loyaltyRewardPoint in card.RewardPoints)
                            {
                                var point = (LoyaltyRewardPoint)loyaltyRewardPoint;
                                var transactionResponse = this.LoyaltyProgramManager.GetLoyaltyCardTransactions(card.ExternalId, point.RewardPointId, 50);
                                if (transactionResponse.ServiceProviderResult.Success && transactionResponse.Result != null)
                                {
                                    point.SetPropertyValue("Transactions", transactionResponse.Result.ToList());
                                }

                                result.SetErrors(transactionResponse.ServiceProviderResult);
                            }
                        }
                    }
                }

                result.Initialize(loyaltyCards);
                return Json(result, JsonRequestBehavior.AllowGet);
            }
            catch (Exception e)
            {
                CommerceLog.Current.Error("GetLoyaltyCards", this, e);
                return Json(new BaseJsonResult("GetLoyaltyCards", e), JsonRequestBehavior.AllowGet);
            }
        }
        public JsonResult ActivateAccount()
        {
            try
            {
                var loyaltyCards = new List<LoyaltyCard>();
                var userResponse = this.AccountManager.GetUser(Context.User.Name);
                var result = new LoyaltyCardsJsonResult(userResponse.ServiceProviderResult);
                if (userResponse.ServiceProviderResult.Success && userResponse.Result != null)
                {
                    var response = this.LoyaltyProgramManager.ActivateAccount(this.CurrentStorefront, this.CurrentVisitorContext);
                    result.SetErrors(response.ServiceProviderResult);

                    if (response.ServiceProviderResult.Success && response.Result != null && !string.IsNullOrEmpty(response.Result.CardNumber))
                    {
                        loyaltyCards = this.AllCards(result);
                    }
                }

                result.Initialize(loyaltyCards);
                return Json(result, JsonRequestBehavior.AllowGet);
            }
            catch (Exception e)
            {
                CommerceLog.Current.Error("ActivateAccount", this, e);
                return Json(new BaseJsonResult("ActivateAccount", e), JsonRequestBehavior.AllowGet);
            }
        }