public DisplayPaywall GetPaywalls(Guid ownerId)
 {
     DisplayPaywall dpw = new DisplayPaywall();
     try
     {
         ManagementContext dc = new ManagementContext();
         var merchant = dc.Merchants.Where(x => x.InternalReference == ownerId).FirstOrDefault();
         if (merchant != null)
         {
             dpw.InternalReference = ownerId;
             dpw.MerchantId = merchant.MerchantId;
             dpw.PrivateManagerId = merchant.PrivateManagerId;
             dpw.AcceptPaymentsViaPaypal = merchant.AcceptPaymentsViaPaypal;
             dpw.AcceptPaymentsViaStripe = merchant.AcceptPaymentsViaStripe;
             if (merchant.CurrencyRate == null)
             {
                 dpw.Currency = "USD";
                 dpw.CurrencyCost = 1;
             }
             else
             {
                 dpw.Currency = merchant.CurrencyRate.CurrencyAbbrName;
                 dpw.CurrencyCost = merchant.CurrencyRate.CurrencyExchangePerUSD;
             }
             dpw.IsPublished = merchant.IsPublished;
             dpw.OwnerName = merchant.OwnerName;
             dpw.PaypalEmail = merchant.PaypalEmail;
             dpw.OrderPayedNotificationEmail = merchant.OrderPayedNotificationEmail;
             dpw.ShopName = merchant.ShopName;
             dpw.StripeConnectKey = merchant.StripeConnectKey;
             dpw.StripeConnectToken = merchant.StripeConnectToken;
             dpw.StripePublishableKey = merchant.StripePublishableKey;
             dpw.StripeRefreshToken = merchant.StripeRefreshToken;
             dpw.StripeTokenType = merchant.StripeTokenType;
             dpw.StripeUserId = merchant.StripeUserId;
             dpw.WelcomeMessage = merchant.WelcomeMessage;
             foreach (var paywall in merchant.Paywalls)
             {
                 dpw.Paywalls.Add(DisplayPaywall(paywall));
             }
         }
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return dpw;
 }
        public ActionResult CreatePaywall(DisplayPaywall paywall)
        {
            try
            {
                var sg = new MerchantGateway();
                var merchant = sg.CreateMerchantAccount(paywall.InternalReference, MerchantInternalReference.Member);
                var id = RDN.Library.Classes.Account.User.GetMemberId();
                MemberCache.Clear(id);
                MemberCache.ClearApiCache(id);

                return Redirect(Url.Content("~/paywall/all"));
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
        }