//Get LeagueTeams, TeamUsers, and LeagueActivity into a list and returns to the page
        public async Task <IActionResult> OnGetAsync(int leagueId)
        {
            GetLeague = await Context.GetLeaguesAsync(leagueId);

            GetTeams = await Context.GetTeamsAsync(leagueId);

            CurrentUser = User.Identity.Name;

            if (GetLeague == null)
            {
                ViewData["ErrorMessage"] = $"League not found";
            }


            if (GetTeams == null)
            {
                ViewData["ErrorMessage"] = $"League teams not found";
            }

            //Defines the actions a user can take when claiming a team (T = Take, L = Leave, O = Owned)
            for (int i = 0; i < GetTeams.Count; i++)
            {
                if (string.IsNullOrEmpty(GetTeams[i].TeamOwnerID))
                {
                    GetTeams[i].TeamAction = 'T';
                }

                else if (CurrentUser == GetTeams[i].TeamOwnerID)
                {
                    GetTeams[i].TeamAction = 'L';
                }

                else
                {
                    GetTeams[i].TeamAction = 'O';
                }
            }

            //Sorts the teams so the current users team is always on top
            GetTeams = GetTeams.OrderBy(o => o.TeamAction).ToList();

            return(Page());
        }
Esempio n. 2
0
        public void GiveBackTeams_GivenGameId()
        {
            var result = GetTeams.GetTheTeamsOnExistingGame(11);

            result.Should().HaveCount(2);
        }
Esempio n. 3
0
        // Get Teams from collection
        public GetTeamsResponse Get(GetTeams request)
        {
            int page = request.Page ?? 1;

            var query = // Need to join this way to get ordering correct using a nested complex object (TeamTotals)
                Db.From<Team>()
                    .Join<Team, TeamTotals>()
                    .Where(t => t.Year == request.Year);

            if(!request.Name.IsNullOrEmpty())
                query.And(t => t.Name.Contains(request.Name));

            query.OrderByDescending<TeamTotals>(tt => tt.Hr)
                .ThenBy<TeamTotals>(tt => tt.Ab)
                .ThenBy<Team>(t => t.Name)
                .PageTo(page);

            return new GetTeamsResponse
            {
                Teams =
                    Db.LoadSelect(query)
                        .ToViewModel(),
                Meta =
                    new Meta(Request?.AbsoluteUri)
                    {
                        Page = page,
                        TotalCount = Db.Count(query)
                    }
            };
        }
Esempio n. 4
0
        public static void BatchTeamAction(this TeamServices svc, GetTeams request, Action<List<TeamListView>> process)
        {
            GetTeamsResponse response;
            int page = 0;

            do
            {
                page++;
                request.Page = page;
                response = svc.Get(request);

                if (response.Teams.Any())
                    process.Invoke(response.Teams);

            } while (response.Meta.Page < response.Meta.TotalPages);
        }
Esempio n. 5
0
 public GameRunner(int gameId)
 {
     _gameId = gameId;
     _teams  = GetTeams.GetTheTeamsOnExistingGame(_gameId);
 }
Esempio n. 6
0
 public List <ITeamModel> Any(GetTeams request)
 {
     return(workflow.Search(request));
 }
Esempio n. 7
0
 public override int GetHashCode()
 {
     return(GetTeams.GetHashCode() ^ GetScore.GetHashCode());
 }
Esempio n. 8
0
 public override bool Equals(object obj)
 {
     return((obj is MatchInfo other) && GetTeams.Equals(other.GetTeams) && GetScore.Equals(other.GetScore));
 }