public VisualizationSystemContext(DbContextOptions <VisualizationSystemContext> options) : base(options) { Database.EnsureCreated(); if (!Teams.Any()) { var team1 = new Teams() { Id = Guid.NewGuid().ToString(), Name = "営業1課", Department = 1, }; Teams.Add(team1); Users.Add(new Users() { Id = Guid.NewGuid().ToString(), Name = "Test User", AccountName = "testuser", Password = "******", Rank = 1, Department = team1.Department, TeamId = team1.Id, Theme = 0, Obsolete = false, }); SaveChanges(); } }
public override bool Validate(Mobile viewer, List <string> errors, bool pop = true) { if (!base.Validate(viewer, errors, pop) && pop) { return(false); } if (CapsToWin < 1) { errors.Add("CapsToWin value must be equal to or greater than 1."); errors.Add("[Options] -> [Edit Options]"); } if (Teams.Any(t => !(t is CTFTeam))) { errors.Add("One or more teams are not of the CTFTeam type."); errors.Add("[Options] -> [View Teams]"); if (pop) { return(false); } } return(true); }
public int PointsFor(TeamName teamName) { if (!Teams.Any(teamName.Matches)) { throw new ArgumentException("£"); } return(teamName.Matches(Winner) ? (Date.Year < 1981) ? 2 : 3 : teamName.Matches(Loser) ? 0 : 1); }
public double SquaredDistanceTo(IGeographical other) { if (!Teams.Any()) { return(0.0); } return((Latitude - other.Latitude) * (Latitude - other.Latitude) + (Longitude - other.Longitude) * (Longitude - other.Longitude)); }
public static void AddTeam(Team team) { if (Teams.Any(t => t.Name.Equals(team.Name))) { throw new Exception("Team " + team.Name + " already exists"); } teams.Add(team); Console.WriteLine("Successfully added Team {0}", team.Name); }
public void UpdateNotify() { if (IsUpdateNotify == false || Teams == null) { return; } IsUpdateNotify = false; IsNotify = Teams.Any(t => t.IsNotify); }
public void DeleteTeam(Guid teamId) { if (Teams.Any(team => team.Id != teamId && team.State != State.Active)) { throw new Exception(); } Teams .First(team => team.Id == teamId) .Delete(); }
public bool IsOver() { var multipleTypes = Teams.Any(team => team.IsDouble) && Teams.Any(team => !team.IsDouble); var result = Winner.Any(); if (multipleTypes && Winner.Count != 2) { result = false; } return(result); }
public DomainResult AddTeam(TeamReadModel teamId) { if (SeasonIsStarted) { return(DomainResult.Error(new SeasonAllreadyStarted())); } if (Teams.Any(t => t == teamId.TeamId)) { return(DomainResult.Error(new CanNotAddTeamTwice(teamId.TeamId))); } return(DomainResult.Ok(new TeamAddedToSeason(SeasonId, teamId.TeamId))); }
public TeamListing ToTeamListing() { return(new TeamListing { TeamListingId = ClubId, ClubOrTeamName = ClubName, ClubOrTeamRoute = ClubRoute, Active = Teams.Any(x => !x.UntilYear.HasValue), PlayerTypes = Teams.Select(x => x.PlayerType).Distinct().ToList(), MatchLocations = Teams.SelectMany(x => x.MatchLocations).Distinct(new MatchLocationEqualityComparer()).ToList() }); }
public bool UpdateTeamName(Guid teamId, string name) { if (Teams.Any(team => team.Id != teamId)) { throw new Exception(); } Teams .First(team => team.Id == teamId) .UpdateName(name); return(true); }
public bool UpdateTeamDescription(Guid teamId, string description) { if (Teams.Any(team => team.Id != teamId)) { throw new Exception(); } Teams .First(team => team.Id == teamId) .UpdateDescription(description); return(true); }
public bool UpdateTeamPoints(Guid teamId, int points) { if (Teams.Any(team => team.Id != teamId)) { throw new Exception(); } Teams .First(team => team.Id == teamId) .UpdatePoints(points); return(true); }
public Team GetTeamByNameOrCreate(string teamName) { if (Teams.Any(team => team.Name == teamName)) { return(Teams.Where(team => team.Name == teamName).FirstOrDefault()); } Team team = new Team(); team.Name = teamName; Teams.Add(team); return(team); }
public bool UpdateTeamOwner(Guid teamId, Guid teamOwnerId) { if (Teams.Any(team => team.Id != teamId)) { throw new Exception(); } Teams .First(team => team.Id == teamId) .UpdateTeamOwner(teamOwnerId); return(true); }
public void AddTeam(string teamName, Guid teamOwnerId, string description) { if (Teams.Any(team => team.Name == teamName)) { throw new Exception(); } var team = TeamFactory.Create(teamName, teamOwnerId, Id, description); Teams.Add(team); }
public Match PlayMatch(Team home, Team away, int gameWeek) { if (!(Teams.Any(x => x.Name == home.Name) && Teams.Any(x => x.Name == away.Name))) { throw new TeamNotInLeagueException(); } var match = new Match(home, away, gameWeek); AddMatch(match, gameWeek); return(match); }
public async Task OnGet() { var members = (await _repository.GetAllAsync <TeamMember>()) .OrderBy(m => m.TeamName); AllTeams = members.Select(m => m.TeamName) .Distinct(); if (Teams == null || !Teams.Any()) { Teams = Enumerable.Empty <string>(); TeamMembers = members; } else { TeamMembers = members.Where(m => Teams.Contains(m.TeamName)); } }
public override bool Validate(Mobile viewer, List <string> errors, bool pop = true) { if (!base.Validate(viewer, errors, pop) && pop) { return(false); } if (Teams.Any(t => !(t is UOF_PvPTeam))) { errors.Add("One or more teams are not of the UOF_PvPTeam type."); errors.Add("[Options] -> [View Teams]"); if (pop) { return(false); } } return(true); }
public override int[] GetBestTeams() { if (!Teams.Any()) { return(new int[] { 0, 0 }); } var orderedQueueTeams = new Queue <ITeam>(Teams.OrderByDescending(x => x.TeamScore)); var maxScore = orderedQueueTeams.First().TeamScore; int bestTeamsCount = 0; while (orderedQueueTeams.First().TeamScore == maxScore) { orderedQueueTeams.Dequeue(); bestTeamsCount++; } return(new int[] { maxScore, bestTeamsCount }); }
public virtual bool Validate(Mobile viewer, List <string> errors, bool pop = true) { if (Deleted) { errors.Add("This battle has been deleted."); return(false); } if (String.IsNullOrWhiteSpace(Name)) { errors.Add("Select a valid Name."); errors.Add("[Options] -> [Edit Options]"); if (pop) { return(false); } } if (String.IsNullOrWhiteSpace(Description)) { errors.Add("Select a valid Description."); errors.Add("[Options] -> [Edit Options]"); if (pop) { return(false); } } if (SpectateAllowed) { if (SpectateRegion == null) { errors.Add("Select a valid Spectate Region."); errors.Add("[Options] -> [Edit Spectage Region]"); if (pop) { return(false); } } else if (Options.Locations.SpectateBounds.Count == 0) { errors.Add("The Spectate Region has no zones."); errors.Add("[Options] -> [Edit Spectage Region]"); if (pop) { return(false); } } } if (BattleRegion == null) { errors.Add("Select a valid Battle Region."); errors.Add("[Options] -> [Edit Battle Region]"); if (pop) { return(false); } } else if (Options.Locations.BattleBounds.Count == 0) { errors.Add("The Battle Region has no zones."); errors.Add("[Options] -> [Edit Battle Region]"); if (pop) { return(false); } } if (Options.Locations.Map == Map.Internal) { errors.Add("The Battle Map must not be Internal."); errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]"); if (pop) { return(false); } } if (Options.Locations.Eject.Internal) { errors.Add("The Eject Map must not be Internal."); errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]"); if (pop) { return(false); } } if (Options.Locations.Eject == Point3D.Zero) { errors.Add("Select a valid Eject Location."); errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]"); if (pop) { return(false); } } else if (BattleRegion != null && BattleRegion.Contains(Options.Locations.Eject.Location, Options.Locations.Eject.Map)) { errors.Add("Eject Location must be outside the Battle Region."); errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]"); if (pop) { return(false); } } if (SpectateAllowed) { if (Options.Locations.SpectateJoin == Point3D.Zero) { errors.Add("Select a valid Spectator Join location."); errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]"); if (pop) { return(false); } } else if (SpectateRegion != null && !SpectateRegion.Contains(Options.Locations.SpectateJoin)) { errors.Add("Spectate Join Location must be within the Spectate Region."); errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]"); if (pop) { return(false); } } } if (Schedule == null) { errors.Add("No Schedule has been set for this battle."); errors.Add("[Options] -> [View Schedule]"); if (pop) { return(false); } } else if (Schedule.Enabled && Schedule.NextGlobalTick == null) { errors.Add("The Schedule has no more future dates."); errors.Add("[Options] -> [View Schedule]"); if (pop) { return(false); } } if (IdleKick && IdleThreshold.TotalSeconds < 10.0) { errors.Add("The Idle Threshold must be greater than, or equal to 10 seconds."); errors.Add("[Options] -> [Edit Options]"); if (pop) { return(false); } } if (Teams.Count == 0) { errors.Add("There are no teams available for this Battle."); errors.Add("[Options] -> [View Teams]"); if (pop) { return(false); } } else if (Teams.Any(team => !team.Validate(viewer))) { errors.Add("One or more teams did not pass validation."); errors.Add("[Options] -> [View Teams]"); if (pop) { return(false); } } return(errors.Count == 0); }
public bool HasTeams() { return(Teams != null && Teams.Any() && Teams.All(t => t.Team != null)); }