Esempio n. 1
0
        // GET: api/Leagues
        public IEnumerable <League> Get()
        {
            var           repo   = new LeaguesRepository();
            List <League> League = repo.GetLeagues();

            return(League);
        }
Esempio n. 2
0
        public void GetLeaguesTest()
        {
            // Arrange
            Context.Users.Add(User1);
            Context.League.Add(League1);
            Context.LeaguePlayers.Add(LeaguePlayer1);
            Context.Users.Add(User2);
            Context.League.Add(League2);
            Context.LeaguePlayers.Add(LeaguePlayer2);
            var league3 = new League
            {
                Id            = Guid.NewGuid(),
                CreatedByUser = User2
            };

            Context.League.Add(league3);
            Context.LeaguePlayers.Add(new LeaguePlayer
            {
                Id     = Guid.NewGuid(),
                User   = User1,
                League = league3
            });
            Context.SaveChanges();

            var leaguesRepository = new LeaguesRepository(Context);

            // Act
            var result = leaguesRepository.GetLeagues(User1).ToList();

            // Assert
            result.Should().Contain(League1);
            result.Should().Contain(league3);
            result.Should().HaveCount(2);
        }
Esempio n. 3
0
        public void GetLeaguesEmptyTest()
        {
            // Arrange
            var leaguesRepository = new LeaguesRepository(Context);

            // Act
            var result = leaguesRepository.GetLeagues(User1);

            // Assert
            result.Should().BeEmpty();
        }
Esempio n. 4
0
 public IEnumerable <LeagueModel> Post([FromBody] VenueModel venue)
 {
     try {
         Logger.LogDebug($"Getting Venues for {venue.Title}");
         var leagues = LeaguesRepository.GetLeagues(venue);
         return(leagues);
     }
     catch (Exception ex) {
         ex.CustomLog(Logger, $"Failed to retrieve Lagues for Venue");
         return(null);
     }
 }
Esempio n. 5
0
        public List <BestTeam> GetBestAttackTeams()
        {
            List <BestTeam>          bestTeams   = new List <BestTeam>();
            League                   league1     = _repository.GetLeagues(en1);
            League                   league2     = _repository.GetLeagues(en2);
            League                   league3     = _repository.GetLeagues(en3);
            Dictionary <string, int> league1Dict = GetBestAttackTeamDict(league1);
            Dictionary <string, int> league2Dict = GetBestAttackTeamDict(league2);
            Dictionary <string, int> league3Dict = GetBestAttackTeamDict(league3);
            var league1MaxValue = league1Dict.FirstOrDefault(x => x.Value == league1Dict.Values.Max());
            var league2MaxValue = league2Dict.FirstOrDefault(x => x.Value == league2Dict.Values.Max());
            var league3MaxValue = league3Dict.FirstOrDefault(x => x.Value == league3Dict.Values.Max());

            bestTeams.Add(new BestTeam {
                Team = league1MaxValue.Key, Score = league1MaxValue.Value
            });
            bestTeams.Add(new BestTeam {
                Team = league2MaxValue.Key, Score = league2MaxValue.Value
            });
            bestTeams.Add(new BestTeam {
                Team = league3MaxValue.Key, Score = league3MaxValue.Value
            });
            return(bestTeams);
        }