// Get the list of the teams associated to the country Id
        private async Task <IEnumerable <Team> > getTeamsAssociatedToTheCountry(int countryId)
        {
            TeamFilter teamFilter = new TeamFilter();

            teamFilter.CountryId = countryId;
            return(await this.teamRepository.GetAllWithFilter(teamFilter));
        }
Example #2
0
        // Token: 0x06002BF6 RID: 11254 RVA: 0x000B9BAC File Offset: 0x000B7DAC
        public override void OnEnter()
        {
            base.OnEnter();
            Transform parent = base.transform.parent;

            if (parent)
            {
                TeleporterInteraction component = parent.GetComponent <TeleporterInteraction>();
                if (component)
                {
                    this.radius = component.clearRadius;
                }
            }
            TeamFilter component2 = base.GetComponent <TeamFilter>();
            TeamIndex  teamIndex  = component2 ? component2.teamIndex : TeamIndex.None;

            if (NetworkServer.active)
            {
                this.healPulse = new TeleporterHealNovaPulse.HealPulse(base.transform.position, this.radius, 0.5f, TeleporterHealNovaPulse.duration, teamIndex);
            }
            this.effectTransform = base.transform.Find("PulseEffect");
            if (this.effectTransform)
            {
                this.effectTransform.gameObject.SetActive(true);
            }
        }
Example #3
0
        public IActionResult Index(TeamFilter filter)
        {
            ViewBag.ProjectId = filter?.ProjectId;
            var list = _service.Get(filter).ToList();

            return(View(list));
        }
Example #4
0
    public static Specification <Team> Build(TeamFilter filter)
    {
        var funcList = new List <Specification <Team> >();

        if (!string.IsNullOrEmpty(filter.City))
        {
            funcList.Add(new CitySpecification(filter.City));
        }

        if (filter.League != League.None)
        {
            funcList.Add(new LeagueSpecification(filter.League));
        }

        if (filter.FoundedMin.HasValue || filter.FoundedMax.HasValue)
        {
            funcList.Add(new FoundedRangeSpecification(filter.FoundedMin.Value, filter.FoundedMax.Value));
        }

        if (funcList.Count == 1)
        {
            return(funcList[0]);
        }

        return(funcList.Aggregate((left, right) => left.And(right)));
    }
    public static IEnumerable <Team> Filter(this IEnumerable <Team> teams, TeamFilter teamFilter)
    {
        if (teamFilter == null)
        {
            return(teams);
        }

        return(teams.Where(SpecificationBuilder.Build(teamFilter).IsSatisfiedBy));
    }
        private void On_ESDetonate(On.EntityStates.Engi.Mine.Detonate.orig_Explode orig, Detonate self)
        {
            if (self.outer.name != "FootMine(Clone)")
            {
                orig(self);
            }
            else if (NetworkServer.active)
            {
                List <TeamComponent> teamMembers = new List <TeamComponent>();
                TeamFilter           teamFilter  = self.GetComponent <TeamFilter>();
                float      blastRadius           = Detonate.blastRadius * 1.2f;
                float      sqrad = blastRadius * blastRadius;
                bool       isFF  = FriendlyFireManager.friendlyFireMode != FriendlyFireManager.FriendlyFireMode.Off;
                GameObject owner = self.projectileController.owner;
                int        icnt  = (int)self.GetComponent <ProjectileDamage>().damage; // this is actually the stack number

                if (isFF || teamFilter.teamIndex != TeamIndex.Monster)
                {
                    teamMembers.AddRange(TeamComponent.GetTeamMembers(TeamIndex.Monster));
                }
                if (isFF || teamFilter.teamIndex != TeamIndex.Neutral)
                {
                    teamMembers.AddRange(TeamComponent.GetTeamMembers(TeamIndex.Neutral));
                }
                if (isFF || teamFilter.teamIndex != TeamIndex.Player)
                {
                    teamMembers.AddRange(TeamComponent.GetTeamMembers(TeamIndex.Player));
                }
                if (owner)
                {
                    teamMembers.Remove(owner.GetComponent <TeamComponent>());
                }

                foreach (TeamComponent tcpt in teamMembers)
                {
                    if ((tcpt.transform.position - self.transform.position).sqrMagnitude <= sqrad)
                    {
                        if (tcpt.body && tcpt.body.mainHurtBox && tcpt.body.isActiveAndEnabled)
                        {
                            DotController.InflictDot(tcpt.gameObject, owner, poisonDot, baseTicks + stackTicks * (icnt - 1), baseDmg + stackDmg * (icnt - 1));
                        }
                    }
                }

                if (Detonate.explosionEffectPrefab)
                {
                    EffectManager.SpawnEffect(Detonate.explosionEffectPrefab, new EffectData
                    {
                        origin   = self.transform.position,
                        rotation = self.transform.rotation,
                        scale    = blastRadius
                    }, true);
                }
                EntityState.Destroy(self.gameObject);
            }
        }
Example #7
0
        // Token: 0x06001DEB RID: 7659 RVA: 0x0008CA74 File Offset: 0x0008AC74
        public void OnProjectileImpact(ProjectileImpactInfo impactInfo)
        {
            EffectManager.instance.SimpleImpactEffect(this.impactSpark, impactInfo.estimatedPointOfImpact, -base.transform.forward, true);
            if (this.hookState != HookProjectileImpact.HookState.Flying)
            {
                return;
            }
            HurtBox component = impactInfo.collider.GetComponent <HurtBox>();

            if (component)
            {
                HealthComponent healthComponent = component.healthComponent;
                if (healthComponent)
                {
                    TeamComponent component2 = healthComponent.GetComponent <TeamComponent>();
                    TeamFilter    component3 = base.GetComponent <TeamFilter>();
                    if (healthComponent.gameObject == this.projectileController.owner || component2.teamIndex == component3.teamIndex)
                    {
                        return;
                    }
                    this.Networkvictim        = healthComponent.gameObject;
                    this.victimSetStateOnHurt = this.victim.GetComponent <SetStateOnHurt>();
                    if (this.victimSetStateOnHurt)
                    {
                        this.victimSetStateOnHurt.SetPain();
                    }
                    DamageInfo damageInfo = new DamageInfo();
                    if (this.projectileDamage)
                    {
                        damageInfo.damage           = this.projectileDamage.damage;
                        damageInfo.crit             = this.projectileDamage.crit;
                        damageInfo.attacker         = (this.projectileController.owner ? this.projectileController.owner.gameObject : null);
                        damageInfo.inflictor        = base.gameObject;
                        damageInfo.position         = impactInfo.estimatedPointOfImpact;
                        damageInfo.force            = this.projectileDamage.force * base.transform.forward;
                        damageInfo.procChainMask    = this.projectileController.procChainMask;
                        damageInfo.procCoefficient  = this.projectileController.procCoefficient;
                        damageInfo.damageColorIndex = this.projectileDamage.damageColorIndex;
                    }
                    else
                    {
                        Debug.Log("No projectile damage component!");
                    }
                    Debug.Log(damageInfo.damage);
                    healthComponent.TakeDamage(damageInfo);
                    GlobalEventManager.instance.OnHitEnemy(damageInfo, healthComponent.gameObject);
                    this.NetworkhookState = HookProjectileImpact.HookState.HitDelay;
                    EffectManager.instance.SimpleImpactEffect(this.impactSuccess, impactInfo.estimatedPointOfImpact, -base.transform.forward, true);
                }
            }
            if (!this.victim)
            {
                this.NetworkhookState = HookProjectileImpact.HookState.ReelFail;
            }
        }
            private void Awake()
            {
#if DEBUG
                TurboEdition._logger.LogWarning("Waking up: " + this);
#endif
                stopwatch       = 0f;
                lifeStopwatch   = 0f;
                teamFilter      = GetComponent <TeamFilter>();
                sphereSearch    = GetComponent <SphereSearch>();
                novaRadiusCurve = EntityStates.TeleporterHealNovaController.TeleporterHealNovaPulse.novaRadiusCurve;
            }
        public async Task <AutocompleteResultSet> Autocomplete([FromUri] string query, [FromUri] string[] not, [FromUri] string[] teamType, [FromUri] bool includeClubTeams = true)
        {
            if (not is null)
            {
                throw new ArgumentNullException(nameof(not));
            }

            if (teamType is null)
            {
                throw new ArgumentNullException(nameof(teamType));
            }

            var teamQuery = new TeamFilter {
                Query = query
            };

            teamQuery.IncludeClubTeams = includeClubTeams;

            foreach (var guid in not)
            {
                if (guid == null)
                {
                    continue;
                }

                try
                {
                    teamQuery.ExcludeTeamIds.Add(new Guid(guid));
                }
                catch (FormatException)
                {
                    // ignore that one
                }
            }

            foreach (var unparsedType in teamType)
            {
                if (Enum.TryParse <TeamType>(unparsedType, out var parsedType))
                {
                    teamQuery.TeamTypes.Add(parsedType);
                }
            }

            var teams = await _teamDataSource.ReadTeams(teamQuery).ConfigureAwait(false);

            return(new AutocompleteResultSet
            {
                suggestions = teams.Select(x => new AutocompleteResult
                {
                    value = (x.UntilYear.HasValue ? x.TeamName + " (no longer active)" : x.TeamName),
                    data = x.TeamId.ToString()
                })
            });
        }
        public async Task Read_total_teams_supports_case_insensitive_filter_by_team_name()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();
            var teamDataSource  = new SqlServerTeamDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);
            var query           = new TeamFilter {
                Query = "DeTaIlS"
            };

            var result = await teamDataSource.ReadTotalTeams(query).ConfigureAwait(false);

            Assert.Equal(_databaseFixture.Teams.Count(x => x.TeamName.Contains(query.Query, StringComparison.OrdinalIgnoreCase)), result);
        }
Example #11
0
 // Token: 0x06001E0A RID: 7690 RVA: 0x000814FC File Offset: 0x0007F6FC
 private void Start()
 {
     if (NetworkServer.active)
     {
         TeamComponent component  = base.GetComponent <TeamComponent>();
         TeamFilter    component2 = base.GetComponent <TeamFilter>();
         if (component2 && component)
         {
             component.teamIndex = component2.teamIndex;
         }
     }
 }
        public async Task Read_total_teams_supports_filter_by_excluding_club_teams()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();
            var teamDataSource  = new SqlServerTeamDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);
            var query           = new TeamFilter {
                IncludeClubTeams = false
            };

            var result = await teamDataSource.ReadTotalTeams(query).ConfigureAwait(false);

            Assert.Equal(_databaseFixture.Teams.Count(x => x.Club == null), result);
        }
        public async Task Read_total_teams_supports_filter_by_inactive_teams()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();
            var teamDataSource  = new SqlServerTeamDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);
            var query           = new TeamFilter {
                ActiveTeams = false
            };

            var result = await teamDataSource.ReadTotalTeams(query).ConfigureAwait(false);

            Assert.Equal(_databaseFixture.Teams.Count(x => x.UntilYear.HasValue), result);
        }
        public async Task Read_total_teams_supports_case_insensitive_filter_by_administrative_area()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();
            var teamDataSource  = new SqlServerTeamDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);
            var query           = new TeamFilter {
                Query = "CoUnTy"
            };

            var result = await teamDataSource.ReadTotalTeams(query).ConfigureAwait(false);

            Assert.Equal(_databaseFixture.Teams.Count(x => x.MatchLocations.Any(ml => ml.AdministrativeArea.Contains(query.Query, StringComparison.OrdinalIgnoreCase))), result);
        }
        protected override SynchronizationEntry MapFromEManager(DataRow dataRow)
        {
            var release    = (string)dataRow[0];
            var leanStatus = (string)dataRow[1];
            var team       = (string)dataRow[2];
            var id         = (string)dataRow[3];
            var title      = (string)dataRow[4];
            var project    = (string)dataRow[5];
            var unid       = (string)dataRow[6];
            var status     = (string)dataRow[7];
            var ordinal    = ParseNumber((string)dataRow[8]);
            var person     = (string)dataRow[9];
            var timeStamp  = ParseDominoTimeStamp((string)dataRow[10]);

            if ((TeamFilter != null && !TeamFilter.Contains(team)) || (ReleaseFilter != null && !ReleaseFilter.Contains(release)))
            {
                return(null);
            }

            if (string.IsNullOrEmpty(id) || id == "0")
            {
                return(null);
            }

            var properties =
                new Dictionary <string, string>
            {
                { "name", id },
                { "unid", unid },
                { "title", title },
                { "team", team },
                { "release", release },
                { "project", project },
                { "leanstatus", leanStatus },
                { "priority", !ordinal.HasValue ? "undefined" : ordinal.ToString() },
            };

            if (!string.IsNullOrEmpty(person))
            {
                properties.Add("CurrentPerson", person);
            }

            if (!ordinal.HasValue)
            {
                ordinal = _maxOrdinal;
            }

            return(new SynchronizationEntry(id, status, properties)
            {
                Ordinal = ordinal, TimeStamp = timeStamp
            });
        }
Example #16
0
 // Use this for initialization
 void Start()
 {
     m_TeamFilter     = this.GetComponent <TeamFilter>();
     m_SpriteRenderer = this.GetComponent <SpriteRenderer>();
     if (m_TeamFilter.team == TeamFilter.Team.Blue)
     {
         m_SpriteRenderer.color = Constants.Instance.BlueTeamZoneColor;
     }
     else
     {
         m_SpriteRenderer.color = Constants.Instance.RedTeamZoneColor;
     }
 }
        public async Task Read_total_teams_supports_filter_by_competition()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();
            var teamDataSource  = new SqlServerTeamDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);
            var query           = new TeamFilter {
                CompetitionIds = new List <Guid> {
                    _databaseFixture.TeamWithFullDetails.Seasons[0].Season.Competition.CompetitionId.Value
                }
            };

            var result = await teamDataSource.ReadTotalTeams(query).ConfigureAwait(false);

            Assert.Equal(_databaseFixture.Teams.Count(x => x.Seasons.Any(s => s.Season.Competition?.CompetitionId == _databaseFixture.TeamWithFullDetails.Seasons[0].Season.Competition.CompetitionId.Value)), result);
        }
        // Token: 0x06002BFF RID: 11263 RVA: 0x000B9ED4 File Offset: 0x000B80D4
        public override void OnEnter()
        {
            base.OnEnter();
            Transform parent = base.transform.parent;

            if (parent)
            {
                this.teleporter            = parent.GetComponent <TeleporterInteraction>();
                this.previousPulseFraction = this.GetCurrentTeleporterChargeFraction();
            }
            TeamFilter component = base.GetComponent <TeamFilter>();

            this.teamIndex = (component ? component.teamIndex : TeamIndex.None);
        }
        public async Task Read_total_teams_supports_filter_by_team_type()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();
            var teamDataSource  = new SqlServerTeamDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);
            var query           = new TeamFilter {
                TeamTypes = new List <TeamType?> {
                    TeamType.Representative
                }
            };

            var result = await teamDataSource.ReadTotalTeams(query).ConfigureAwait(false);

            Assert.Equal(_databaseFixture.Teams.Count(x => x.TeamType == TeamType.Representative), result);
        }
        public async Task Read_total_teams_supports_filter_by_excluded_teams()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();
            var teamDataSource  = new SqlServerTeamDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);
            var query           = new TeamFilter {
                ExcludeTeamIds = new List <Guid> {
                    _databaseFixture.TeamWithFullDetails.TeamId.Value
                }
            };

            var result = await teamDataSource.ReadTotalTeams(query).ConfigureAwait(false);

            Assert.Equal(_databaseFixture.Teams.Count - 1, result);
        }
        // Token: 0x06001E6B RID: 7787 RVA: 0x0008F888 File Offset: 0x0008DA88
        private static void InitializeProjectile(ProjectileController projectileController, FireProjectileInfo fireProjectileInfo)
        {
            GameObject                 gameObject = projectileController.gameObject;
            ProjectileDamage           component  = gameObject.GetComponent <ProjectileDamage>();
            TeamFilter                 component2 = gameObject.GetComponent <TeamFilter>();
            ProjectileNetworkTransform component3 = gameObject.GetComponent <ProjectileNetworkTransform>();
            MissileController          component4 = gameObject.GetComponent <MissileController>();
            ProjectileSimple           component5 = gameObject.GetComponent <ProjectileSimple>();

            projectileController.Networkowner  = fireProjectileInfo.owner;
            projectileController.procChainMask = fireProjectileInfo.procChainMask;
            if (component2)
            {
                component2.teamIndex = TeamComponent.GetObjectTeam(fireProjectileInfo.owner);
            }
            if (component3)
            {
                component3.SetValuesFromTransform();
            }
            if (component4)
            {
                component4.target = (fireProjectileInfo.target ? fireProjectileInfo.target.transform : null);
            }
            if (fireProjectileInfo.useSpeedOverride && component5)
            {
                component5.velocity = fireProjectileInfo.speedOverride;
            }
            if (fireProjectileInfo.useFuseOverride)
            {
                ProjectileImpactExplosion component6 = gameObject.GetComponent <ProjectileImpactExplosion>();
                if (component6)
                {
                    component6.lifetime = fireProjectileInfo.fuseOverride;
                }
                ProjectileFuse component7 = gameObject.GetComponent <ProjectileFuse>();
                if (component7)
                {
                    component7.fuse = fireProjectileInfo.fuseOverride;
                }
            }
            if (component)
            {
                component.damage           = fireProjectileInfo.damage;
                component.force            = fireProjectileInfo.force;
                component.crit             = fireProjectileInfo.crit;
                component.damageColorIndex = fireProjectileInfo.damageColorIndex;
            }
        }
Example #22
0
        /// <summary>
        /// Gets the number of teams that match a query
        /// </summary>
        /// <returns></returns>
        public async Task <int> ReadTotalTeams(TeamFilter teamQuery)
        {
            using (var connection = _databaseConnectionFactory.CreateDatabaseConnection())
            {
                var sql = $@"SELECT COUNT(DISTINCT t.TeamId)
                        FROM {Tables.Team} AS t
                        INNER JOIN {Tables.TeamVersion} AS tv ON t.TeamId = tv.TeamId
                        <<JOIN>>
                        <<WHERE>>
                        AND tv.TeamVersionId = (SELECT TOP 1 TeamVersionId FROM {Tables.TeamVersion} WHERE TeamId = t.TeamId ORDER BY ISNULL(UntilDate, '{SqlDateTime.MaxValue.Value.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)}') DESC)";

                var(filteredSql, parameters) = ApplyTeamQuery(teamQuery, sql, Array.Empty <string>());

                return(await connection.ExecuteScalarAsync <int>(filteredSql, new DynamicParameters(parameters)).ConfigureAwait(false));
            }
        }
        public async Task Read_teams_supports_filter_by_inactive_teams()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();
            var teamDataSource  = new SqlServerTeamDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);
            var query           = new TeamFilter {
                ActiveTeams = false
            };

            var result = await teamDataSource.ReadTeams(query).ConfigureAwait(false);

            Assert.Equal(_databaseFixture.Teams.Count(x => x.UntilYear.HasValue), result.Count);
            foreach (var team in _databaseFixture.Teams.Where(x => x.UntilYear.HasValue))
            {
                Assert.NotNull(result.SingleOrDefault(x => x.TeamId == team.TeamId));
            }
        }
        public async Task Read_teams_supports_case_insensitive_filter_by_town()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();
            var teamDataSource  = new SqlServerTeamDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);
            var query           = new TeamFilter {
                Query = "ToWn"
            };

            var result = await teamDataSource.ReadTeams(query).ConfigureAwait(false);

            Assert.Equal(_databaseFixture.Teams.Count(x => x.MatchLocations.Any(ml => ml.Town.Contains(query.Query, StringComparison.OrdinalIgnoreCase))), result.Count);
            foreach (var team in _databaseFixture.Teams.Where(x => x.MatchLocations.Any(ml => ml.Town.Contains(query.Query, StringComparison.OrdinalIgnoreCase))))
            {
                Assert.NotNull(result.SingleOrDefault(x => x.TeamId == team.TeamId));
            }
        }
        // Token: 0x06001E0D RID: 7693 RVA: 0x000815A4 File Offset: 0x0007F7A4
        public void OnProjectileImpact(ProjectileImpactInfo impactInfo)
        {
            HurtBox component = impactInfo.collider.GetComponent <HurtBox>();

            if (component)
            {
                HealthComponent healthComponent = component.healthComponent;
                if (healthComponent)
                {
                    if (!this.canHitCharacters)
                    {
                        return;
                    }
                    TeamComponent component2 = healthComponent.GetComponent <TeamComponent>();
                    TeamFilter    component3 = base.GetComponent <TeamFilter>();
                    if (healthComponent.gameObject == this.projectileController.owner || component2.teamIndex == component3.teamIndex)
                    {
                        return;
                    }
                    GameObject gameObject = healthComponent.gameObject;
                    DamageInfo damageInfo = new DamageInfo();
                    if (this.projectileDamage)
                    {
                        damageInfo.damage           = this.projectileDamage.damage * this.damageCoefficient;
                        damageInfo.crit             = this.projectileDamage.crit;
                        damageInfo.attacker         = (this.projectileController.owner ? this.projectileController.owner.gameObject : null);
                        damageInfo.inflictor        = base.gameObject;
                        damageInfo.position         = impactInfo.estimatedPointOfImpact;
                        damageInfo.force            = this.projectileDamage.force * base.transform.forward;
                        damageInfo.procChainMask    = this.projectileController.procChainMask;
                        damageInfo.procCoefficient  = this.projectileController.procCoefficient;
                        damageInfo.damageColorIndex = this.projectileDamage.damageColorIndex;
                        damageInfo.damageType       = this.projectileDamage.damageType;
                    }
                    healthComponent.TakeDamage(damageInfo);
                    GlobalEventManager.instance.OnHitEnemy(damageInfo, healthComponent.gameObject);
                    this.NetworkboomerangState = BoomerangProjectile.BoomerangState.FlyBack;
                }
            }
            if (!this.canHitWorld)
            {
                return;
            }
            this.NetworkboomerangState = BoomerangProjectile.BoomerangState.FlyBack;
            EffectManager.SimpleImpactEffect(this.impactSpark, impactInfo.estimatedPointOfImpact, -base.transform.forward, true);
        }
        public async Task Read_teams_supports_filter_by_team_type()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();
            var teamDataSource  = new SqlServerTeamDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);
            var query           = new TeamFilter {
                TeamTypes = new List <TeamType?> {
                    TeamType.Representative
                }
            };

            var result = await teamDataSource.ReadTeams(query).ConfigureAwait(false);

            Assert.Equal(_databaseFixture.Teams.Count(x => x.TeamType == TeamType.Representative), result.Count);
            foreach (var team in _databaseFixture.Teams.Where(x => x.TeamType == TeamType.Representative))
            {
                Assert.NotNull(result.SingleOrDefault(x => x.TeamId == team.TeamId));
            }
        }
        public async Task Read_teams_supports_filter_by_excluded_teams()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();
            var teamDataSource  = new SqlServerTeamDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);
            var query           = new TeamFilter {
                ExcludeTeamIds = new List <Guid> {
                    _databaseFixture.TeamWithFullDetails.TeamId.Value
                }
            };

            var result = await teamDataSource.ReadTeams(query).ConfigureAwait(false);

            Assert.Equal(_databaseFixture.Teams.Count(x => x.TeamId != _databaseFixture.TeamWithFullDetails.TeamId.Value), result.Count);
            foreach (var team in _databaseFixture.Teams.Where(x => x.TeamId != _databaseFixture.TeamWithFullDetails.TeamId.Value))
            {
                Assert.NotNull(result.SingleOrDefault(x => x.TeamId == team.TeamId));
            }
        }
Example #28
0
        /// <summary>
        /// Gets a list of teams based on a query
        /// </summary>
        /// <returns>A list of <see cref="Team"/> objects. An empty list if no teams are found.</returns>
        public async Task <List <Team> > ReadTeams(TeamFilter teamQuery)
        {
            using (var connection = _databaseConnectionFactory.CreateDatabaseConnection())
            {
                var sql = $@"SELECT t.TeamId, tv.TeamName, t.TeamRoute, t.PlayerType, YEAR(tv.UntilDate) AS UntilYear, t.Website, t.Introduction, t.PlayingTimes, t.PublicContactDetails,
                            ml.MatchLocationId, ml.SecondaryAddressableObjectName, ml.PrimaryAddressableObjectName, ml.StreetDescription, ml.Locality, ml.Town, ml.AdministrativeArea, ml.Postcode, ml.Latitude, ml.Longitude
                            FROM {Tables.Team} AS t 
                            INNER JOIN {Tables.TeamVersion} AS tv ON t.TeamId = tv.TeamId
                            LEFT JOIN {Tables.TeamMatchLocation} AS tml ON tml.TeamId = t.TeamId AND tml.UntilDate IS NULL
                            LEFT JOIN {Tables.MatchLocation} AS ml ON ml.MatchLocationId = tml.MatchLocationId 
                            <<JOIN>>
                            <<WHERE>>
                            AND tv.TeamVersionId = (SELECT TOP 1 TeamVersionId FROM {Tables.TeamVersion} WHERE TeamId = t.TeamId ORDER BY ISNULL(UntilDate, '{SqlDateTime.MaxValue.Value.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)}') DESC)
                            ORDER BY CASE WHEN tv.UntilDate IS NULL THEN 0 
                                          WHEN tv.UntilDate IS NOT NULL THEN 1 END, tv.TeamName";

                var(filteredSql, parameters) = ApplyTeamQuery(teamQuery, sql, new[] { Tables.TeamMatchLocation, Tables.MatchLocation });

                var teams = await connection.QueryAsync <Team, MatchLocation, Team>(filteredSql,
                                                                                    (team, matchLocation) =>
                {
                    if (matchLocation != null)
                    {
                        team.MatchLocations.Add(matchLocation);
                    }
                    return(team);
                },
                                                                                    new DynamicParameters(parameters),
                                                                                    splitOn : "MatchLocationId").ConfigureAwait(false);

                var resolvedTeams = teams.GroupBy(team => team.TeamId).Select(copiesOfTeam =>
                {
                    var resolvedTeam            = copiesOfTeam.First();
                    resolvedTeam.MatchLocations = copiesOfTeam
                                                  .Select(team => team.MatchLocations.SingleOrDefault())
                                                  .OfType <MatchLocation>()
                                                  .Distinct(new MatchLocationEqualityComparer())
                                                  .ToList();
                    return(resolvedTeam);
                }).ToList();

                return(resolvedTeams);
            }
        }
Example #29
0
        public void GetByFilterTest()
        {
            //Arange
            Mock <IUnitOfWork>         unitOfWorkMock = new Mock <IUnitOfWork>();
            Mock <IRepository <Team> > repositoryMock = new Mock <IRepository <Team> >();

            repositoryMock.Setup(repo => repo.Get(It.IsAny <Expression <Func <Team, bool> > >())).Returns(_teams.AsQueryable);
            unitOfWorkMock.Setup(getRepo => getRepo.GetRepository <Team>()).Returns(repositoryMock.Object);
            TeamService teamService = new TeamService(unitOfWorkMock.Object);
            TeamFilter  teamFilter  = new TeamFilter();

            //Act
            IEnumerable <TeamDto> teamsDto = teamService.Get(teamFilter);

            //Assert
            Assert.NotNull(teamsDto);
            Assert.NotEmpty(teamsDto);
            Assert.Equal(3, teamsDto.Count());
        }
Example #30
0
        public ActionResult Catalog(String teamName, String driverSurname, TeamFilter teamFilter = null, bool restore = false, int page = 1)
        {
            //ViewBag.Message = "Catalog";
            //F1Context db = new F1Context();
            IQueryable <Team> teams = db.Teams;

            if (teamFilter == null)
            {
                teamFilter = new TeamFilter();
            }

            if (restore)
            {
                teamFilter = TeamFilter.GetTeamFilter(Session["TeamFilter"]);
            }

            if (teamName != "" && teamName != null)
            {
                teams = teams.Where(e => e.Name.Equals(teamName));
            }
            if (driverSurname != "" && driverSurname != null)
            {
                teams = teams.Where(e => e.Driver.Surname.Equals(driverSurname) || e.Driver1.Surname.Equals(driverSurname));
            }

            page_team = teams.ToList();
            int pageSize = 4;

            //IEnumerable<Team> teamsPerPages = page_team.Take(pageSize);
            IEnumerable <Team> teamsPerPages = page_team.Skip((page - 1) * pageSize).Take(pageSize);
            PageInfo           pgInfo        = new PageInfo {
                PageNumber = page, PageSize = pageSize, TotalItems = page_team.Count
            };
            IndexView ivm = new IndexView {
                pageInfo = pgInfo, Teams = teamsPerPages
            };

            Session["TeamFilter"] = teamFilter;
            ivm.teamFilter        = teamFilter;

            return(View(ivm));
        }
        /// <summary>
        ///     Handles the SelectionChanged event of the cmbDivConf control. Applies the new filter, forces all tabs to reload on first
        ///     request and reloads the current tab.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">
        ///     The <see cref="SelectionChangedEventArgs" /> instance containing the event data.
        /// </param>
        private void cmbDivConf_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (_changingTimeframe)
            {
                return;
            }

            if (cmbDivConf.SelectedIndex == -1)
            {
                return;
            }

            var cur = (ComboBoxItemWithIsEnabled) cmbDivConf.SelectedItem;
            var name = cur.Item;
            var parts = name.Split(new[] { ": " }, 2, StringSplitOptions.None);
            if (parts.Length == 1)
            {
                if (parts[0] == "Whole League")
                {
                    _filterType = TeamFilter.League;
                    _filterDescription = "";
                }
                else
                {
                    _filterType = TeamFilter.Conference;
                    _filterDescription = parts[0];
                }
            }
            else
            {
                _filterType = TeamFilter.Division;
                _filterDescription = parts[1];
            }

            _reload = true;
            _lastShownTeamSeason = 0;
            _lastShownPlayerSeason = 0;
            _lastShownShootingSeason = 0;
            _lastShownTeamShootingSeason = 0;
            _lastShownBoxSeason = 0;
            tbcLeagueOverview_SelectionChanged(null, null);
        }