public static List<MemberDisplayBasic> GetRecipientsOfMessageGroup(long groupId) { List<MemberDisplayBasic> members = new List<MemberDisplayBasic>(); var dc = new ManagementContext(); var recipients = (from xx in dc.GroupMessages where xx.GroupId == groupId select xx.Recipients.Where(x => x.IsRemovedFromGroup == false)).FirstOrDefault(); if (recipients != null) { foreach (var mem in recipients) { MemberDisplayBasic user = new MemberDisplayBasic(); user.MemberId = mem.Recipient.MemberId; user.DerbyName = mem.Recipient.DerbyName; members.Add(user); } } return members; }
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 TournamentOwners(string pid, string id) { try { Guid memId = RDN.Library.Classes.Account.User.GetMemberId(); var tourny = Tournament.GetTournamentToManage(new Guid(id), new Guid(pid)); if (tourny.Owners.Count < 10) { MemberDisplayBasic mem = new MemberDisplayBasic(); tourny.Owners.Add(mem); MemberDisplayBasic mem1 = new MemberDisplayBasic(); tourny.Owners.Add(mem1); MemberDisplayBasic mem2 = new MemberDisplayBasic(); tourny.Owners.Add(mem2); MemberDisplayBasic mem3 = new MemberDisplayBasic(); tourny.Owners.Add(mem3); } return View(tourny); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww)); }
/// <summary> /// gets the connected members of the group message /// </summary> /// <param name="groupId"></param> /// <returns></returns> public static List<MemberDisplayBasic> GetConnectedMembersOfGroup(Guid groupId) { List<MemberDisplayBasic> members = new List<MemberDisplayBasic>(); List<MemberDisplayBasic> memsNew = new List<MemberDisplayBasic>(); List<Guid> leagues = new List<Guid>(); try { leagues.Add(groupId); var dc = new ManagementContext(); ///gets the federations owned and find the leagues within the federation, ///then adds them to the list of leagues. var membersOfFederations = (from xx in dc.Federations where xx.FederationId == groupId select xx.Members).ToList(); var membersOfLeagues = (from xx in dc.Federations where xx.FederationId == groupId select xx.Leagues.Select(x => x.League.LeagueId)).ToList(); foreach (var list in membersOfFederations) { foreach (var mem in list) { MemberDisplayBasic m = new MemberDisplayBasic(); m.MemberId = mem.Member.MemberId; m.DerbyName = mem.Member.DerbyName.Replace("'", "").Replace('"', ' '); m.Firstname = mem.Member.Firstname; m.LastName = mem.Member.Lastname; members.Add(m); } } foreach (var list in membersOfLeagues) { foreach (var mem in list) { leagues.Add(mem); } } leagues = leagues.Distinct().ToList(); if (leagues.Count > 0) { var membersOfLeag = (from xx in dc.Leagues where leagues.Contains(xx.LeagueId) select xx.Members).ToList(); foreach (var list in membersOfLeag) { foreach (var mem in list.Where(x => x.HasLeftLeague == false)) { MemberDisplayBasic m = new MemberDisplayBasic(); m.MemberId = mem.Member.MemberId; m.DerbyName = mem.Member.DerbyName.Replace("'", "").Replace('"', ' '); m.Firstname = mem.Member.Firstname; m.LastName = mem.Member.Lastname; members.Add(m); } } } foreach (var mem in members) { if (memsNew.Where(x => x.MemberId == mem.MemberId).FirstOrDefault() == null) memsNew.Add(mem); } memsNew = memsNew.OrderBy(x => x.DerbyName).ToList(); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return memsNew; }
public JsonResult Members(string mid, string uid) { List<MemberDisplayBasic> mems = new List<MemberDisplayBasic>(); try { var mem = MemberCache.GetMemberDisplay(new Guid(mid)); if (new Guid(uid) == mem.UserId) { var members = MemberCache.GetLeagueMembers(mem.MemberId, mem.CurrentLeagueId); for (int i = 0; i < members.Count; i++) { MemberDisplayBasic m = new MemberDisplayBasic(); if (members[i].Photos.FirstOrDefault() != null) m.ThumbUrl = members[i].Photos.FirstOrDefault().ImageThumbUrl; m.ThumbUrl = "http://images.rdnation.com/members/2014/2/23/Annie-roller-derby-130376147098933750_thumb.JPG"; m.DerbyName = members[i].DerbyName; m.Firstname = members[i].Firstname; m.LastName = members[i].LastName; m.MemberId = members[i].MemberId; mems.Add(m); } } } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return Json(mems, JsonRequestBehavior.AllowGet); }
public static List<MemberDisplayBasic> GetConnectedMembersOfMember(Guid memberId) { List<MemberDisplayBasic> members = new List<MemberDisplayBasic>(); var dc = new ManagementContext(); var leagues = MemberCache.GetAllOwnedLeagues(memberId).Select(x => x.LeagueId).ToList(); var federations = MemberCache.GetAllOwnedFederations(memberId).Select(x => x.Federation.FederationId).ToList(); var leagueId = MemberCache.GetLeagueIdOfMember(memberId); leagues.Add(leagueId); ///gets the federations owned and find the leagues within the federation, ///then adds them to the list of leagues. if (federations.Count > 0) { var membersOfFederations = (from xx in dc.Federations where federations.Contains(xx.FederationId) select xx.Members).ToList(); var membersOfLeagues = (from xx in dc.Federations where federations.Contains(xx.FederationId) select xx.Leagues.Select(x => x.League.LeagueId)).ToList(); foreach (var list in membersOfFederations) { foreach (var mem in list) { MemberDisplayBasic m = new MemberDisplayBasic(); m.MemberId = mem.Member.MemberId; m.DerbyName = mem.Member.DerbyName.Replace("'", "").Replace('"', ' '); m.Firstname = mem.Member.Firstname; m.LastName = mem.Member.Lastname; members.Add(m); } } foreach (var list in membersOfLeagues) { foreach (var mem in list) { leagues.Add(mem); } } } leagues = leagues.Distinct().ToList(); if (leagues.Count > 0) { var membersOfLeagues = (from xx in dc.Leagues where leagues.Contains(xx.LeagueId) select xx.Members).ToList(); foreach (var list in membersOfLeagues) { var mems = list.Where(x => x.HasLeftLeague == false); foreach (var mem in mems) { MemberDisplayBasic m = new MemberDisplayBasic(); m.MemberId = mem.Member.MemberId; if (!String.IsNullOrEmpty(mem.Member.DerbyName)) m.DerbyName = mem.Member.DerbyName.Replace("'", "").Replace('"', ' '); else m.DerbyName = "Not Entered"; m.Firstname = mem.Member.Firstname; m.LastName = mem.Member.Lastname; members.Add(m); } } } List<MemberDisplayBasic> memsNew = new List<MemberDisplayBasic>(); foreach (var mem in members) { if (memsNew.Where(x => x.MemberId == mem.MemberId).FirstOrDefault() == null) memsNew.Add(mem); } memsNew = memsNew.OrderBy(x => x.DerbyName).ToList(); return memsNew; }
private static void AddTotalWithstandingToMember(DuesPortableModel due, double feeToAdd, MemberDisplayBasic member) { var memberWhoOwes = due.Members.Where(x => x.MemberId == member.MemberId).FirstOrDefault(); if (memberWhoOwes != null) memberWhoOwes.TotalWithstanding += feeToAdd; else { due.Members.Add(new MemberDisplayDues { MemberId = member.MemberId, DerbyName = member.DerbyName, TotalWithstanding = feeToAdd, UserId = member.UserId }); } }
private static Tournament DisplayTournament(GameTournament tourny) { try { var memId = RDN.Library.Classes.Account.User.GetMemberId(); Tournament to = new Tournament(); to.TournamentClass = (TournamentClassEnum)tourny.TournamentClass; to.TournamentType = (TournamentTypeEnum)tourny.TournamentTypeEnum; to.EndDate = tourny.EndDate; if (tourny.SelectedShop != null) to.SelectedShop = tourny.SelectedShop.MerchantId.ToString(); to.EndDateDisplay = tourny.EndDate.ToShortDateString(); to.StartDateDisplay = tourny.StartDate.ToShortDateString(); to.StartDate = tourny.StartDate; to.Id = tourny.TournamentId; to.IsPublished = tourny.IsPublished; to.AreBracketsPublished = tourny.AreBracketsPublished; to.PrivateKey = tourny.PrivateTournamentId; to.Name = tourny.TournamentName; to.PassCodeForGames = tourny.TournamentPasscode; to.EmbedVideoString = tourny.EmbedVideoString; to.TournamentWebsite = tourny.TournamentWebsite; if (tourny.OwnerOfTournament != null) { MemberDisplayBasic m = new MemberDisplayBasic(); m.DerbyName = tourny.OwnerOfTournament.DerbyName; m.MemberId = tourny.OwnerOfTournament.MemberId; m.UserId = tourny.OwnerOfTournament.AspNetUserId; to.Owners.Add(m); } for (int i = 0; i < tourny.OwnersOfTournament.Count; i++) { try { if (to.Owners.Where(x => x.MemberId == tourny.OwnersOfTournament[i].Owner.MemberId).FirstOrDefault() == null) { MemberDisplayBasic m = new MemberDisplayBasic(); m.DerbyName = tourny.OwnersOfTournament[i].Owner.DerbyName; m.MemberId = tourny.OwnersOfTournament[i].Owner.MemberId; m.UserId = tourny.OwnersOfTournament[i].Owner.AspNetUserId; to.Owners.Add(m); } } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } } if (tourny.Logo != null) to.Photos.Add(new PhotoItem(tourny.Logo.ImageUrl, tourny.Logo.ImageUrlThumb, true, tourny.TournamentName)); #region contact if (tourny.ContactCard != null) { var add = tourny.ContactCard.Addresses.FirstOrDefault(); if (add != null) { to.Address = add.Address1; to.Address2 = add.Address2; to.City = add.CityRaw; if (add.Country != null) { to.Country = add.Country.Code; to.CountryId = add.Country.CountryId; } to.State = add.StateRaw; to.ZipCode = add.Zip; } } #endregion #region paywall if (tourny.Paywall != null) { to.Paywall.DailyPrice = tourny.Paywall.DailyPrice; to.Paywall.DescriptionOfPaywall = tourny.Paywall.DescriptionOfPaywall; to.Paywall.EndDate = tourny.Paywall.EndDate; if (tourny.Paywall.EndDate.HasValue) to.Paywall.EndDateDisplay = tourny.Paywall.EndDate.Value.ToShortDateString(); to.Paywall.IsEnabled = tourny.Paywall.IsEnabled; to.Paywall.IsRemoved = tourny.Paywall.IsRemoved; to.Paywall.PaywallId = tourny.Paywall.PaywallId; to.Paywall.StartDate = tourny.Paywall.StartDate; if (tourny.Paywall.StartDate.HasValue) to.Paywall.StartDateDisplay = tourny.Paywall.StartDate.Value.ToShortDateString(); to.Paywall.TimespanPrice = tourny.Paywall.TimespanPrice; to.PaywallId = tourny.Paywall.PaywallId; to.Paywall.AcceptPaypal = tourny.Paywall.Merchant.AcceptPaymentsViaPaypal; to.Paywall.AcceptStripe = tourny.Paywall.Merchant.AcceptPaymentsViaStripe; if (memId != new Guid()) { var isPaid = tourny.Paywall.PaywallInvoices.Where(x => x.MemberPaidId == memId).OrderByDescending(x => x.Created).FirstOrDefault(); if (isPaid != null) { if (isPaid.ValidUntil > DateTime.UtcNow && (isPaid.Invoice.InvoiceStatus == (byte)InvoiceStatus.Payment_Successful || isPaid.Invoice.InvoiceStatus == (byte)InvoiceStatus.Pending_Payment_From_Paypal)) { to.Paywall.IsPaid = true; } } else to.Paywall.IsPaid = false; } to.Paywall.MerchantId = tourny.Paywall.Merchant.MerchantId; } #endregion #region Games List<Game> games = new List<Game>(); foreach (var game in tourny.Games) { try { Game g = new Game(); g.GameId = game.GameId; g.GameName = game.GameName; g.GameDate = game.GameDate; var teams = game.GameTeams.OrderByDescending(x => x.Created).Take(2); var team1 = teams.OrderByDescending(x => x.TeamName).FirstOrDefault(); var team2 = teams.OrderBy(x => x.TeamName).FirstOrDefault(); g.Team1Name = team1.TeamName; g.Team1LinkId = team1.TeamIdLink; g.Team1Id = team1.TeamId; g.Team2Name = team2.TeamName; g.Team2LinkId = team2.TeamIdLink; g.Team2Id = team2.TeamId; g.Team1ScoreTotal = team1.GameScores.Select(x => x.Point).Sum(); g.Team2ScoreTotal = team2.GameScores.Select(x => x.Point).Sum(); foreach (var b in team1.GameMembers) { TeamMembersViewModel a = new TeamMembersViewModel(); a.SkaterId = b.GameMemberId; a.SkaterLinkId = b.MemberLinkId; a.SkaterName = b.MemberName; a.SkaterNumber = b.MemberNumber; if (to.AllSkaters.Where(x => x.SkaterLinkId == a.SkaterLinkId).FirstOrDefault() == null) to.AllSkaters.Add(a); } foreach (var b in team2.GameMembers) { TeamMembersViewModel a = new TeamMembersViewModel(); a.SkaterId = b.GameMemberId; a.SkaterLinkId = b.MemberLinkId; a.SkaterName = b.MemberName; a.SkaterNumber = b.MemberNumber; if (to.AllSkaters.Where(x => x.SkaterLinkId == a.SkaterLinkId).FirstOrDefault() == null) to.AllSkaters.Add(a); } foreach (var assist in game.GameMemberAssists) { AssistViewModel a = new AssistViewModel(); a.AssistId = assist.GameAssistId; a.PlayerWhoAssisted = new TeamMembersViewModel(); a.PlayerWhoAssisted.SkaterId = assist.MemberWhoAssisted.GameMemberId; a.PlayerWhoAssisted.SkaterName = assist.MemberWhoAssisted.MemberName; a.PlayerWhoAssisted.SkaterLinkId = assist.MemberWhoAssisted.MemberLinkId; to.AssistLeaders.Add(a); } foreach (var pen in game.GameMemberPenalties) { PenaltyViewModel a = new PenaltyViewModel(); a.PenaltyId = pen.GamePenaltyId; a.PenaltyAgainstMember = new TeamMembersViewModel(); a.PenaltyAgainstMember.SkaterId = pen.MemberWhoPenaltied.GameMemberId; a.PenaltyAgainstMember.SkaterName = pen.MemberWhoPenaltied.MemberName; a.PenaltyAgainstMember.SkaterLinkId = pen.MemberWhoPenaltied.MemberLinkId; a.PenaltyType = (PenaltiesEnum)Enum.Parse(typeof(PenaltiesEnum), pen.PenaltyType.ToString()); to.PenaltyLeaders.Add(a); } foreach (var blocks in game.GameMemberBlocks) { BlockViewModel a = new BlockViewModel(); a.BlockId = blocks.GameBlockId; a.PlayerWhoBlocked = new TeamMembersViewModel(); a.PlayerWhoBlocked.SkaterId = blocks.MemberWhoBlocked.GameMemberId; a.PlayerWhoBlocked.SkaterName = blocks.MemberWhoBlocked.MemberName; a.PlayerWhoBlocked.SkaterLinkId = blocks.MemberWhoBlocked.MemberLinkId; to.BlockLeaders.Add(a); } games.Add(g); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } } to.Games = games; #endregion var ts = tourny.Teams.Where(x => x.IsRemoved == false); foreach (var team in ts) { try { TeamViewModel t = new TeamViewModel(); t.PoolNumber = team.PoolNumber; t.LeagueName = team.LeageName; //t.TeamLinkId = team.TeamIdLink; t.TeamName = team.TeamName; t.TeamId = team.TeamId; t.SeedRating = team.SeedRating; to.TeamsForTournament.Add(t); TournamentApi.TournamentTeam tt = new TournamentApi.TournamentTeam(team.TeamId, team.SeedRating, team.PoolNumber); to.TeamsForTournamentApi.Add(tt); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } } #region seededbracketsForPerformance try { to.TouramentTypeForSeedingEnum = (TournamentTypeEnum)tourny.TournamentTypeEnumForSeedingRound; if (to.TouramentTypeForSeedingEnum != TournamentTypeEnum.None) { TournamentApi.IPairingsGenerator pg = null; switch (to.TouramentTypeForSeedingEnum) { case TournamentTypeEnum.Boil_Off: pg = new BoilOffPairingsGenerator(); break; case TournamentTypeEnum.Round_Robin: pg = new RoundRobinPairingsGenerator(); break; case TournamentTypeEnum.Double_Elimination: pg = new EliminationTournament(2); break; case TournamentTypeEnum.Single_Elimination: pg = new EliminationTournament(1); break; case TournamentTypeEnum.Round_Robin_Pool_Play: pg = new RoundRobinPairingsGenerator(true); break; } if (pg is TournamentApi.ITournamentVisualizer) { to.VisualizedBracketsSeeded = (TournamentApi.ITournamentVisualizer)pg; } foreach (var round in tourny.SeedingRounds) { try { TournamentRoundsClass r = new TournamentRoundsClass(); List<TournamentApi.TournamentPairing> ppList = new List<TournamentApi.TournamentPairing>(); r.RoundNumber = round.RoundNumber; foreach (var pair in round.Pairings) { List<TournamentApi.TournamentTeamScore> ttList = new List<TournamentApi.TournamentTeamScore>(); TournamentPairingClass p = new TournamentPairingClass(); p.Id = pair.PairingId; p.GroupId = pair.GroupId; p.TimeToStart = pair.StartTime.GetValueOrDefault(); if (pair.StartTime.HasValue) p.TimeToStartDisplay = p.TimeToStart.ToString("HH:mm"); p.TrackId = pair.TrackNumber; foreach (var team in pair.Teams) { TeamViewModel t = new TeamViewModel(); t.TeamId = team.Team.TeamId; t.TeamName = team.Team.TeamName; t.TeamLinkId = team.TeamIdInGame; if (t.TeamLinkId != new Guid() && p.GameId == new Guid()) { var g = to.Games.Where(x => x.Team1Id == t.TeamLinkId || x.Team2Id == t.TeamLinkId).FirstOrDefault(); if (g != null) p.GameId = g.GameId; } t.Score = team.Score; p.Teams.Add(t); TournamentApi.TournamentTeamScore tt = new TournamentApi.TournamentTeamScore(new TournamentApi.TournamentTeam(t.TeamId, team.Team.SeedRating), new TournamentApi.HighestPointsScore(team.Score)); ttList.Add(tt); } TournamentApi.TournamentPairing pp = new TournamentApi.TournamentPairing(ttList); pp.GroupId = p.GroupId; ppList.Add(pp); r.Pairings.Add(p); } TournamentApi.TournamentRound rr = new TournamentApi.TournamentRound(ppList); to.TournamentRoundsApiForSeeding.Add(rr); to.TournamentRoundsForSeedingGameplay.Add(r); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } } if (pg != null) { pg.LoadState(to.TeamsForTournamentApi, to.TournamentRoundsApiForSeeding); try { var nextRound = pg.CreateNextRound(null); to.HasSeedingFinishForTournament = (nextRound == null) && (tourny.SeedingRounds.Count() > 1); if (to.TournamentRoundsApiForSeeding.Any()) { var rankings = pg.GenerateRankings(); to.RankingsForSeededRounds = new List<TournamentApi.TournamentRanking>(from rk in rankings select new TournamentApi.TournamentRanking { TeamName = to.TeamsForTournament.Where(tm => tm.TeamId == rk.team.TeamId).Single().TeamName, rank = rk.rank, Loses = rk.Loses, PointSpread = rk.PointSpread, scoreDescription = rk.scoreDescription, team = rk.team, TotalPoints = rk.TotalPoints, Wins = rk.Wins }); } } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } } } } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } #endregion #region brackets try { to.TournamentType = (TournamentTypeEnum)tourny.TournamentTypeEnum; if (to.TournamentType != TournamentTypeEnum.None) { if (to.TouramentTypeForSeedingEnum != TournamentTypeEnum.None && to.HasSeedingFinishForTournament) { foreach (var ranking in to.RankingsForSeededRounds) { var team = to.TeamsForTournamentApi.Where(x => x.TeamId == ranking.team.TeamId).FirstOrDefault(); team.Rating = (int)ranking.rank; } } TournamentApi.IPairingsGenerator pg = null; switch (to.TournamentType) { case TournamentTypeEnum.Boil_Off: pg = new BoilOffPairingsGenerator(); break; case TournamentTypeEnum.Round_Robin: pg = new RoundRobinPairingsGenerator(); break; case TournamentTypeEnum.Round_Robin_Pool_Play: pg = new RoundRobinPairingsGenerator(true); break; case TournamentTypeEnum.Double_Elimination: pg = new EliminationTournament(2); break; case TournamentTypeEnum.Single_Elimination: pg = new EliminationTournament(1); break; } try { if (pg is TournamentApi.ITournamentVisualizer) { to.VisualizedBrackets = (TournamentApi.ITournamentVisualizer)pg; } } catch //(TournamentApi.InvalidTournamentStateException ex) { //Debug.WriteLine(ex); } foreach (var round in tourny.Rounds) { try { TournamentRoundsClass r = new TournamentRoundsClass(); List<TournamentApi.TournamentPairing> ppList = new List<TournamentApi.TournamentPairing>(); r.RoundNumber = round.RoundNumber; foreach (var pair in round.Pairings) { List<TournamentApi.TournamentTeamScore> ttList = new List<TournamentApi.TournamentTeamScore>(); TournamentPairingClass p = new TournamentPairingClass(); p.Id = pair.PairingId; p.GroupId = pair.GroupId; p.TimeToStart = pair.StartTime.GetValueOrDefault(); if (pair.StartTime.HasValue) p.TimeToStartDisplay = p.TimeToStart.ToString("HH:mm"); p.TrackId = pair.TrackNumber; foreach (var team in pair.Teams) { TeamViewModel t = new TeamViewModel(); t.TeamId = team.Team.TeamId; t.TeamName = team.Team.TeamName; t.TeamLinkId = team.TeamIdInGame; if (t.TeamLinkId != new Guid() && p.GameId == new Guid()) { var g = to.Games.Where(x => x.Team1Id == t.TeamLinkId || x.Team2Id == t.TeamLinkId).FirstOrDefault(); if (g != null) p.GameId = g.GameId; } t.Score = team.Score; p.Teams.Add(t); TournamentApi.TournamentTeamScore tt = new TournamentApi.TournamentTeamScore(new TournamentApi.TournamentTeam(t.TeamId, team.Team.SeedRating), new TournamentApi.HighestPointsScore(team.Score)); ttList.Add(tt); } TournamentApi.TournamentPairing pp = new TournamentApi.TournamentPairing(ttList); pp.GroupId = p.GroupId; ppList.Add(pp); r.Pairings.Add(p); } TournamentApi.TournamentRound rr = new TournamentApi.TournamentRound(ppList); to.TournamentRoundsApi.Add(rr); to.TournamentRounds.Add(r); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } } if (pg != null) { pg.LoadState(to.TeamsForTournamentApi, to.TournamentRoundsApi); try { var nextRound = pg.CreateNextRound(null); to.IsTournamentFinished = (nextRound == null) && (tourny.Rounds.Count() > 1); if (to.TournamentRoundsApi.Any()) { var rankings = pg.GenerateRankings(); to.Rankings = new List<TournamentApi.TournamentRanking>(from rk in rankings select new TournamentApi.TournamentRanking { TeamName = to.TeamsForTournament.Where(tm => tm.TeamId == rk.team.TeamId).Single().TeamName, rank = rk.rank, Loses = rk.Loses, PointSpread = rk.PointSpread, scoreDescription = rk.scoreDescription, team = rk.team, TotalPoints = rk.TotalPoints, Wins = rk.Wins }); } } catch (TournamentApi.InvalidTournamentStateException) { } } } } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } #endregion return to; } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return null; }
public DuesMemberItem() { Member = new MemberDisplayBasic(); DuesItem = new DuesItem(); }
/// <summary> /// searches for the derby name and see if its already entered in the DB by someone else. /// </summary> /// <param name="name"></param> /// <returns></returns> public static List<MemberDisplayBasic> SearchForDerbyName(string name) { List<MemberDisplayBasic> members = new List<MemberDisplayBasic>(); var dc = new ManagementContext(); var list = dc.Members.Where(x => x.DerbyName.ToLower().Contains(name.ToLower())).Where(x => x.AspNetUserId == new Guid()).ToList(); foreach (var mem in list) { MemberDisplayBasic basic = new MemberDisplayBasic(); basic.DerbyName = mem.DerbyName; basic.Firstname = mem.Firstname; basic.MemberId = mem.MemberId; basic.PlayerNumber = mem.PlayerNumber; members.Add(basic); } return members; }
public static List<MemberDisplayBasic> GetAllNonVerifiedUsers() { List<MemberDisplayBasic> members = new List<MemberDisplayBasic>(); var dc = new ManagementContext(); var emails = dc.EmailVerifications.ToList(); foreach (var user in emails) { MemberDisplayBasic mem = new MemberDisplayBasic(); mem.Email = user.EmailAddress; mem.UserId = user.VerificationId; mem.DerbyName = user.Member.DerbyName; members.Add(mem); } return members; }
public ActionResult ManagePost(Game game) { try { var gameDb = GameManager.GetGameForManagement(game.GameId, game.PrivateKeyForGame, RDN.Library.Classes.Account.User.GetMemberId()); if (game == null) return Redirect(Url.Content("~/")); gameDb.GameName = game.GameName; gameDb.GameDate = game.GameDate; for (int i = 0; i < gameDb.MembersOfGame.Count; i++) { string linkId = HttpContext.Request.Form[gameDb.MembersOfGame[i].MemberId.ToString().Replace("-", "") + "hidden"]; if (String.IsNullOrEmpty(linkId)) gameDb.MembersOfGame[i].MemberLinkId = new Guid(); else { if (new Guid(linkId) != gameDb.MembersOfGame[i].MemberLinkId) { gameDb.MembersOfGame[i].MemberLinkId = new Guid(linkId); } } } gameDb.SelectedShop = game.SelectedShop; gameDb.SelectedTournament = game.SelectedTournament; gameDb.PassCodeEnteredForTournament = game.PassCodeEnteredForTournament; for (int i = 0; i < gameDb.MemberOwners.Count + 5; 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()); gameDb.MemberOwners.Add(mem); } if (HttpContext.Request.Form["LeagueOwner" + i + "hidden"] != null && !String.IsNullOrEmpty(HttpContext.Request.Form["LeagueOwner" + i + "hidden"].ToString())) { RDN.Portable.Classes.League.Classes.League mem = new Portable.Classes.League.Classes.League(); mem.LeagueId = new Guid(HttpContext.Request.Form["LeagueOwner" + i + "hidden"].ToString()); gameDb.LeagueOwners.Add(mem); } if (HttpContext.Request.Form["FederationOwner" + i + "hidden"] != null && !String.IsNullOrEmpty(HttpContext.Request.Form["FederationOwner" + i + "hidden"].ToString())) { FederationDisplay mem = new FederationDisplay(); mem.FederationId = new Guid(HttpContext.Request.Form["FederationOwner" + i + "hidden"].ToString()); gameDb.FederationOwners.Add(mem); } } if (!String.IsNullOrEmpty(game.EmbededVideoString)) gameDb.IsThereVideoOfGame = GameVideoTypeEnum.EmbededVideo; else if (!String.IsNullOrEmpty(game.StreamingUrlSilverlight)) gameDb.IsThereVideoOfGame = GameVideoTypeEnum.SilverLightLive; gameDb.StreamingMobileUrlSilverlight = game.StreamingMobileUrlSilverlight; gameDb.StreamingUrlSilverlight = game.StreamingUrlSilverlight; gameDb.EmbededVideoString = game.EmbededVideoString; gameDb.SelectedPaywall = game.SelectedPaywall; GameManager.UpdateGameFromManagement(gameDb); try { //clears the live game once we complete the update. WebClient client = new WebClient(); client.DownloadString(ServerConfig.URL_TO_CLEAR_LIVE_GAME_CACHE + game.GameId.ToString()); } catch { } try { //clears the live game once we complete the update. WebClient client = new WebClient(); client.DownloadString(ServerConfig.WEBSITE_CLEAR_TOURNAMENT_CACHE_API); } catch { } return Redirect(Url.Content("~/game/manage/" + game.PrivateKeyForGame.ToString().Replace("-", "") + "/" + game.GameId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.s)); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, GetType()); } return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.na)); }
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; }