示例#1
0
        public IEnumerable <IExposableTeam> GetTeamsOfSerie(Guid sereisId)
        {
            var series       = DomainService.FindSeriesById(sereisId);
            var teamsOfSerie = series.TeamIds;

            return(teamsOfSerie.Select(teamId => DomainService.FindTeamById(teamId)).ToList());
        }
示例#2
0
        public IEnumerable <TeamStats> GetLeagueTablePlacement(Guid seriesId)
        {
            var series         = this.FindById(seriesId);
            var teamIdsOfSerie = series.TeamIds;
            var teamsOfSerie   = teamIdsOfSerie.Select(teamId => DomainService.FindTeamById(teamId)).ToList();
            var teamStats      = new List <TeamStats>();

            foreach (var team in teamsOfSerie)
            {
                try
                {
                    teamStats.Add(team.AggregatedStats[seriesId]);
                }
                catch (SeriesMissingException)
                {
                }
            }

            var orderTeamStats = teamStats.OrderByDescending(x => x.Points)
                                 .ThenByDescending(x => x.GoalDifference)
                                 .ThenByDescending(x => x.GoalsFor).ToList();

            for (int i = 0; i < orderTeamStats.Count; i++)
            {
                var teamStat = orderTeamStats.ElementAt(i);
                teamStat.Ranking = i + 1;
            }
            return(orderTeamStats);
        }
示例#3
0
 public IEnumerable <Series> Search(string searchText, StringComparison comparison
                                    = StringComparison.InvariantCultureIgnoreCase)
 {
     return(this.GetAll().Where(x => x.TeamIds.Any
                                    (y => y != Guid.Empty && DomainService.FindTeamById(y).Name.ToString().Contains(searchText, comparison) ||
                                    x.SeriesName.ToString().Contains(searchText, comparison))));
 }
示例#4
0
        public void AssignPlayerToTeam(IExposablePlayer exposablePlayer, Guid teamId)
        {
            var player = (Player)exposablePlayer;
            var team   = DomainService.FindTeamById(teamId);

            player.UpdateTeamAffiliation(team);
            team.UpdatePlayerIds();
            this.repository.SaveData();
        }
示例#5
0
 public IEnumerable <Match> Search(string searchText, StringComparison comparison
                                   = StringComparison.InvariantCultureIgnoreCase)
 {
     return(this.GetAll().Where(x =>
                                x.Id != Guid.Empty && x.SeriesId != Guid.Empty &&
                                x.HomeTeamId != Guid.Empty && x.AwayTeamId != Guid.Empty
                                &&
                                (DomainService.FindSeriesById(x.SeriesId).SeriesName.ToString().Contains(searchText, comparison) ||
                                 DomainService.FindTeamById(x.HomeTeamId).Name.ToString().Contains(searchText, comparison) ||
                                 DomainService.FindTeamById(x.AwayTeamId).Name.ToString().Contains(searchText, comparison) ||
                                 x.Location.ToString().Contains(searchText, comparison) ||
                                 x.MatchDate.ToString().Contains(searchText, comparison))));
 }
示例#6
0
        public void RemoveTeamFromSeries(Guid seriesId, Guid teamId)
        {
            var series = DomainService.FindSeriesById(seriesId);

            if (series.TeamIds.Contains(teamId))
            {
                series.TeamIds.Remove(teamId);
            }
            else
            {
                throw new ArgumentException($"Can not remove team \"{DomainService.FindTeamById(teamId)}\"."
                                            + $" Team doesn't exist in series \"{DomainService.FindSeriesById(seriesId)}\".");
            }
        }
示例#7
0
        public void AddTeamToSeries(Guid seriesId, Guid teamId)
        {
            var series = this.FindById(seriesId);

            if (!(series.TeamIds.Contains(teamId)))
            {
                series.TeamIds.Add(teamId);
                var team = DomainService.FindTeamById(teamId);
                team.AddSeries(series);
                DomainService.AddSeriesToPlayers(series, team);
            }
            else
            {
                throw new ArgumentException($"Series already contains team {DomainService.FindTeamById(teamId)}");
            }
        }