public static LeagueBillingHistory GetReceiptsForLeague(Guid leagueId)
 {
     LeagueBillingHistory history = new LeagueBillingHistory();
     history.LeagueId = leagueId;
     var league = League.LeagueFactory.GetLeague(leagueId);
     history.LeagueName = league.Name;
     try
     {
         PaymentGateway pg = new PaymentGateway();
         var invoices = pg.GetAllInvoiceSubscriptionsForLeague(leagueId);
         foreach (var invoice in invoices)
         {
             LeagueReceipt re = new LeagueReceipt();
             re.InvoiceId = invoice.InvoiceId;
             re.LeagueId = invoice.Subscription.InternalObject;
             re.Expires = invoice.Subscription.ValidUntil;
             re.AmountPaid = invoice.Subscription.Price;
             re.EmailForReceipt = league.Email;
             re.Status = invoice.InvoiceStatus;
             history.Receipts.Add(re);
         }
     }
     catch (Exception exception)
     {
         ErrorDatabaseManager.AddException(exception, exception.GetType());
     }
     return history;
 }
        public ActionResult LeagueBillingHistory(string leagueId)
        {
            var memId = RDN.Library.Classes.Account.User.GetMemberId();
            if (!MemberCache.IsManagerOrBetterOfLeague(memId) && !MemberCache.IsAdministrator(memId))
                return Redirect("~/");

            RDN.Library.Classes.Billing.Classes.LeagueBillingHistory history = new LeagueBillingHistory();
            try
            {
                history = RDN.Library.Classes.Billing.Classes.LeagueBillingHistory.GetReceiptsForLeague(new Guid(leagueId));
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return View(history);
        }