public ActionResult UpdateTournament(Tournament tourny)
        {
            try
            {
                tourny.EndDate = Convert.ToDateTime(tourny.EndDateDisplay);
                tourny.StartDate = Convert.ToDateTime(tourny.StartDateDisplay);

                Tournament.UpdateTournament(tourny);
                WebClient client = new WebClient();
                client.DownloadStringAsync(new Uri(ServerConfig.WEBSITE_CLEAR_TOURNAMENT_CACHE));
                WebClient client1 = new WebClient();
                client1.DownloadStringAsync(new Uri(ServerConfig.WEBSITE_CLEAR_TOURNAMENT_CACHE_API));
                return Redirect(Url.Content("~/tournament/view/" + tourny.PrivateKey.ToString().Replace("-", "") + "/" + tourny.Id.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.s));
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));

        }
        public ActionResult UploadItemPictures(Tournament display)
        {
            try
            {
                foreach (string pictureFile in Request.Files)
                {
                    HttpPostedFileBase file = Request.Files[pictureFile];
                    if (file.ContentLength > 0)
                    {
                        Tournament.AddLogo(display.Id, file.InputStream, file.FileName);
                    }
                }
                return Redirect(Url.Content("~/tournament/view/" + display.PrivateKey.ToString().Replace("-", "") + "/" + display.Id.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.sup));
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/u=" + SiteMessagesEnum.sww));

        }
        public ActionResult TournamentOwners(Tournament tournament)
        {
            try
            {

                Guid memId = RDN.Library.Classes.Account.User.GetMemberId();
                var tourny = Tournament.GetTournamentToManage(tournament.Id, tournament.PrivateKey);

                for (int i = 0; i < tourny.Owners.Count + 10; i++)
                {
                    if (HttpContext.Request.Form["MemberOwner" + i + "hidden"] != null && !String.IsNullOrEmpty(HttpContext.Request.Form["MemberOwner" + i + "hidden"].ToString()))
                    {
                        MemberDisplayBasic mem = new MemberDisplayBasic();
                        mem.MemberId = new Guid(HttpContext.Request.Form["MemberOwner" + i + "hidden"].ToString());
                        tourny.Owners.Add(mem);
                    }

                }
                Tournament.UpdateTournamentOwners(tourny);
                return View(tourny);
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
        }
        public ActionResult MakePaywallPayment(Tournament tourny)
        {
            var memId = RDN.Library.Classes.Account.User.GetMemberId();
            var to = Tournament.GetPublicTournament(tourny.Id);
            try
            {
                string paymentProvider = Request.Form["PaymentType"].ToString();
                string stripeToken = "none";

                PaymentProvider provider = PaymentProvider.None;
                if (paymentProvider == PaymentProvider.Stripe.ToString())
                {
                    provider = PaymentProvider.Stripe;
                    stripeToken = Request.Form["stripeToken"].ToString();
                }
                else if (paymentProvider == PaymentProvider.Paypal.ToString())
                {
                    provider = PaymentProvider.Paypal;
                }
                string subType = Request.Form["PaymentCost"].ToString();
                PaywallPriceTypeEnum sub = (PaywallPriceTypeEnum)Enum.Parse(typeof(PaywallPriceTypeEnum), subType);
                decimal price = .99M;


                DateTime now = DateTime.UtcNow;
                DateTime validTill = DateTime.UtcNow.AddDays(1);

                if (sub == PaywallPriceTypeEnum.Daily_Payment)
                {
                    validTill = DateTime.UtcNow.AddDays(1);
                }
                else if (sub == PaywallPriceTypeEnum.Full_Payment)
                {
                    validTill = to.Paywall.EndDate.Value.AddDays(1);
                }

                PaymentGateway pg = new PaymentGateway();
                var f = pg.StartInvoiceWizard().Initalize(to.Paywall.MerchantId, "USD", provider, PaymentMode.Live, ChargeTypeEnum.Paywall)
                    .SetInvoiceId(Guid.NewGuid())
                    .SetPaywall(new InvoicePaywall
                    {
                        ValidUntil = validTill,
                        PaywallId = to.Paywall.PaywallId,

                        PriceType = sub,
                        Description = "Paid For " + to.Name + " with a " + RDN.Utilities.Enums.EnumExt.ToFreindlyName(sub) + " Pass",
                        Name = "Tournament Streaming Paid",
                        Price = price,
                        InternalObject = to.Id,
                        MemberPaidId = memId,
                        PaywallLocation = ServerConfig.WEBSITE_DEFAULT_LOCATION + "/roller-derby-tournament/" + to.Id.ToString().Replace("-", "") + "/" + RDN.Utilities.Strings.StringExt.ToSearchEngineFriendly(to.Name)
                    })
                    .SetInvoiceContactData(new InvoiceContactInfo
                    {
                        Email = tourny.Paywall.EmailAddress,
                        Phone = tourny.Paywall.PhoneNumber,
                    });

                if (provider == PaymentProvider.Stripe)
                    f.SetStripeTokenId(stripeToken);

                var response = f.FinalizeInvoice();

                //succesfully charged.
                if (response.Status == InvoiceStatus.Payment_Successful)
                    return Redirect(ServerConfig.PAYWALL_RECEIPT_URL + response.InvoiceId.ToString().Replace("-", ""));
                else if (response.Status == InvoiceStatus.Pending_Payment_From_Paypal)
                    return Redirect(response.RedirectLink);


            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/roller-derby-tournament/" + to.Id.ToString().Replace("-", "") + "/" + RDN.Utilities.Strings.StringExt.ToSearchEngineFriendly(to.Name) + "?u=" + SiteMessagesEnum.sww));
        }
        public ActionResult TournamentHome(Tournament tourny)
        {
            try
            {
                if (!String.IsNullOrEmpty(tourny.Paywall.PasswordForPaywall))
                    tourny.Paywall.PasswordForPaywall = tourny.Paywall.PasswordForPaywall.Trim();
                var tourn = Tournament.GetPublicTournament(tourny.Id);
                bool isPaid = Tournament.CheckTournamentPaywallIsPaid(tourny.Id, tourny.Paywall.PasswordForPaywall);
                tourn.Paywall.IsPaid = isPaid;

                bool isCurrentlyViewing = PaywallViewers.Instance.IsCurrentlyViewingPaywall(tourny.Paywall.PaywallId, tourny.Paywall.PasswordForPaywall);
                if (isCurrentlyViewing)
                {
                    tourn.Paywall.IsPaid = false;
                    SiteMessage message = new SiteMessage();
                    message.MessageType = SiteMessageType.Warning;
                    message.Message = "You are currently viewing this from another device. You can only view this from one device at a time.";
                    this.AddMessage(message);
                }


                tourny.StripeKey = "Stripe.setPublishableKey('" + ServerConfig.STRIPE_LIVE_KEY + "');";
                return View(tourn);
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww));
        }
Ejemplo n.º 6
0
        public static Game DisplayGame(DataModels.Game.Game game)
        {
            ManagementContext dc = new ManagementContext();
            Game tempGame = new Game();
            tempGame.IsThereVideoOfGame = (GameVideoTypeEnum)Enum.Parse(typeof(GameVideoTypeEnum), game.IsThereVideoOfGame.ToString());
            tempGame.StreamingUrlSilverlight = game.StreamingUrlOfVideo;
            tempGame.StreamingMobileUrlSilverlight = game.StreamingUrlOfVideoMobile;
            tempGame.EmbededVideoString = game.EmbededVideoHtml;
            if (game.Paywall != null)
                tempGame.SelectedPaywall = game.Paywall.PaywallId;
            tempGame.GameDate = game.GameDate;
            tempGame.GameId = game.GameId;
            tempGame.PrivateKeyForGame = game.IdForOnlineManagementUse;
            tempGame.GameName = game.GameName;
            if (game.SelectedShop != null)
                tempGame.SelectedShop = game.SelectedShop.MerchantId.ToString();
            var games = game.GameTeams.OrderByDescending(x => x.Created).Take(2);
            var team2 = games.OrderBy(x => x.TeamName).FirstOrDefault();
            var team1 = games.OrderByDescending(x => x.TeamName).FirstOrDefault();

            if (team1 != null)
                tempGame.Team1Name = team1.TeamName;
            else
                tempGame.Team1Name = "Home";
            if (team2 != null)
                tempGame.Team2Name = team2.TeamName;
            else
                tempGame.Team2Name = "Away";
            tempGame.HasGameStarted = game.HasGameStarted;
            tempGame.IsGameLive = game.IsGameLive;
            tempGame.IsGameOver = game.IsGameOver;
            tempGame.IsGamePublishedOnline = game.IsGamePublishedOnline;
            tempGame.IsGameScrimmage = game.IsGameScrimmage;
            tempGame.VersionNumber = game.VersionNumber;

            foreach (var team in game.GameTeams)
            {
                foreach (var mem in team.GameMembers)
                {
                    MemberDisplayGame member = new MemberDisplayGame();
                    member.DerbyName = mem.MemberName;
                    member.MemberId = mem.GameMemberId;
                    if (mem.MemberLinkId != new Guid())
                    {
                        var memDb = (from xx in dc.Members
                                     where xx.MemberId == mem.MemberLinkId
                                     select xx.DerbyName).FirstOrDefault();
                        if (!String.IsNullOrEmpty(memDb))
                        {
                            member.MemberLinkId = mem.MemberLinkId;
                            member.DerbyLinkName = memDb;
                        }
                    }
                    tempGame.MembersOfGame.Add(member);
                }
            }
            var endDate = DateTime.UtcNow.AddDays(5);
            var tournys = dc.GameTournaments.Where(x => x.StartDate < DateTime.UtcNow && x.EndDate < endDate).ToList();
            if (game.GameTournament != null)
            {
                tempGame.SelectedTournament = game.GameTournament.TournamentId.ToString();
                tempGame.PassCodeEnteredForTournament = game.GameTournament.TournamentPasscode;
                Tournament t = new Tournament();
                t.Name = game.GameTournament.TournamentName;
                t.EndDate = game.GameTournament.EndDate;
                t.Id = game.GameTournament.TournamentId;
                t.StartDate = game.GameTournament.StartDate;
                tempGame.AvailableTournaments.Add(t);
            }

            foreach (var owner in game.MemberOwners)
            {
                MemberDisplayBasic mem = new MemberDisplayBasic();
                mem.MemberId = owner.Member.MemberId;
                mem.DerbyName = owner.Member.DerbyName;
                tempGame.MemberOwners.Add(mem);
            }
            if (tempGame.MemberOwners.Count < 5)
            {
                MemberDisplayBasic mem = new MemberDisplayBasic();
                tempGame.MemberOwners.Add(mem);
                MemberDisplayBasic mem1 = new MemberDisplayBasic();
                tempGame.MemberOwners.Add(mem1);
                MemberDisplayBasic mem2 = new MemberDisplayBasic();
                tempGame.MemberOwners.Add(mem2);
                MemberDisplayBasic mem3 = new MemberDisplayBasic();
                tempGame.MemberOwners.Add(mem3);
            }

            foreach (var owner in game.LeagueOwners)
            {
                RDN.Portable.Classes.League.Classes.League mem = new RDN.Portable.Classes.League.Classes.League();
                mem.LeagueId = owner.League.LeagueId;
                mem.Name = owner.League.Name;
                tempGame.LeagueOwners.Add(mem);
            }
            if (tempGame.LeagueOwners.Count < 2)
            {
                RDN.Portable.Classes.League.Classes.League mem = new RDN.Portable.Classes.League.Classes.League();
                tempGame.LeagueOwners.Add(mem);
                RDN.Portable.Classes.League.Classes.League mem1 = new RDN.Portable.Classes.League.Classes.League();
                tempGame.LeagueOwners.Add(mem1);
            }
            foreach (var owner in game.FederationOwners)
            {
                FederationDisplay mem = new FederationDisplay();
                mem.FederationId = owner.Federation.FederationId;
                mem.FederationName = owner.Federation.Name;
                tempGame.FederationOwners.Add(mem);
            }
            if (tempGame.FederationOwners.Count == 0)
            {
                FederationDisplay mem = new FederationDisplay();
                tempGame.FederationOwners.Add(mem);
            }

            foreach (var tourn in tournys)
            {
                var gameT = tourn.Games.Where(x => x.GameId == tempGame.GameId).FirstOrDefault();
                if (gameT != null)
                {
                    tempGame.SelectedTournament = tourn.TournamentId.ToString();
                    tempGame.PassCodeEnteredForTournament = tourn.TournamentPasscode;
                }
                Tournament t = new Tournament();
                t.Name = tourn.TournamentName;
                t.EndDate = tourn.EndDate;
                t.Id = tourn.TournamentId;
                t.StartDate = tourn.StartDate;
                if (tempGame.AvailableTournaments.Where(x => x.Id == t.Id).FirstOrDefault() == null)
                    tempGame.AvailableTournaments.Add(t);
            }
            return tempGame;
        }