Пример #1
0
        public ActionResult PlayerDisplay(string playerId, int matchId)
        {
            using (var db = new PickupModel())
            {
                var match = db.Matches.FirstOrDefault(m => m.MatchID == matchId);

                int playerCount = 0;
                List <PlayerModel> curPlayers = new List <PlayerModel>();

                var player = db.Players.FirstOrDefault(p => p.PlayerID == playerId);
                if (player != null)
                {
                    curPlayers.Add(new PlayerModel
                    {
                        playerCurRole  = player.CurRole,
                        playerUsername = player.Username,
                        playerPicture  = player.Picture,
                        playerID       = player.PlayerID
                    });
                }
                MatchesModel matches = new MatchesModel
                {
                    matchID          = match.MatchID,
                    matchMap         = match.MatchMap,
                    matchHost        = match.MatchHost,
                    matchAdmin       = match.MatchAdmin,
                    matchPlayerCount = playerCount,
                    matchPlayers     = curPlayers
                };
                return(PartialView(matches));
            }
        }
Пример #2
0
        public ActionResult MatchInfo(int matchId)
        {
            using (var db = new PickupModel())
            {
                var match = db.Matches.FirstOrDefault(m => m.MatchID == matchId);

                int playerCount = 0;
                List <PlayerModel> curPlayers = new List <PlayerModel>();
                foreach (var player in db.Players.Where(n => n.CurMatch == match.MatchID))
                {
                    curPlayers.Add(new PlayerModel
                    {
                        playerID = player.PlayerID
                    });
                    playerCount++;
                }

                MatchesModel matches = new MatchesModel
                {
                    matchID          = match.MatchID,
                    matchMap         = match.MatchMap,
                    matchHost        = match.MatchHost,
                    matchAdmin       = match.MatchAdmin,
                    matchPlayerCount = playerCount,
                    matchPlayers     = curPlayers
                };
                return(PartialView(matches));
            }
        }
Пример #3
0
        public ActionResult Matches()
        {
            var         rep         = new UserRepository(context);
            var         user        = rep.GetUserByUsername(User.Identity.Name);
            List <User> matchesList = rep.GetAllMatches(user);
            var         matches     = new MatchesModel()
            {
                Matches = matchesList
            };

            return(View(matches));
        }
Пример #4
0
        /// <summary>
        /// Default method: Get all matches list
        /// </summary>
        /// <returns>View</returns>
        public ActionResult Index()
        {
            MatchesModel model = new MatchesModel();

            model.StartDate = null;
            model.EndDate   = null;

            MatchService service = new MatchService();

            service.ReadAllMatches();
            model.Matches = service.MatchList;

            return(View(model));
        }
Пример #5
0
        private async Task <bool> apiCall()
        {
            string[] matchPaths    = { "v2/competitions/CL/matches", "v2/competitions/PL/matches", "v2/competitions/PD/matches" };
            string[] teamPaths     = { "v2/competitions/CL/teams", "v2/competitions/PL/teams", "v2/competitions/PD/teams" };
            string[] standingPaths = { "v2/competitions/CL/standings", "v2/competitions/PL/standings", "v2/competitions/PD/standings" };
            string[] scorerPaths   = { "v2/competitions/CL/scorers", "v2/competitions/PL/scorers", "v2/competitions/PD/scorers" };

            IEnumerable <MatchesModel> matches = await ApiMatchModelAsync(matchPaths);

            IEnumerable <TeamsModel> teams = await ApiTeamModelAsync(teamPaths);

            IEnumerable <StandingsModel> standings = await ApiStandingModelAsync(standingPaths);

            IEnumerable <ScorerModel> scorers = await ApiScorerModelAsync(scorerPaths);

            clMatches = matches.Where(match => match.competition.id == 2001).FirstOrDefault();
            plMatches = matches.Where(match => match.competition.id == 2021).FirstOrDefault();
            pdMatches = matches.Where(match => match.competition.id == 2014).FirstOrDefault();

            allMatch.AddRange(clMatches.matches);
            allMatch.AddRange(plMatches.matches);
            allMatch.AddRange(pdMatches.matches);

            clTeams = teams.Where(team => team.competition.id == 2001).FirstOrDefault();
            plTeams = teams.Where(team => team.competition.id == 2021).FirstOrDefault();
            pdTeams = teams.Where(team => team.competition.id == 2014).FirstOrDefault();

            allTeams.AddRange(clTeams.teams);
            allTeams.AddRange(plTeams.teams);
            allTeams.AddRange(pdTeams.teams);

            clStanding = standings.Where(standing => standing.competition.id == 2001).FirstOrDefault();
            plStanding = standings.Where(standing => standing.competition.id == 2021).FirstOrDefault();
            pdStanding = standings.Where(standing => standing.competition.id == 2014).FirstOrDefault();

            clScorers = scorers.Where(scorer => scorer.competition.id == 2001).FirstOrDefault();
            plScorers = scorers.Where(scorer => scorer.competition.id == 2021).FirstOrDefault();
            pdScorers = scorers.Where(scorer => scorer.competition.id == 2014).FirstOrDefault();

            return(true);
        }
Пример #6
0
        public ActionResult Index(DateTime?startDate, DateTime?endDate)
        {
            MatchesModel model = new MatchesModel();

            model.StartDate = startDate;
            model.EndDate   = endDate;

            MatchService service = new MatchService();

            if (startDate.HasValue && endDate.HasValue)
            {
                service.MatchesByPeriod(startDate.Value, endDate.Value);
            }
            else
            {
                service.ReadAllMatches();
            }

            model.Matches = service.MatchList;

            return(View(model));
        }
Пример #7
0
        // GET: Match
        public ActionResult Matches()
        {
            var userName = User.Identity.Name;
            var model    = new MatchesModel() //En modell med samling usermatchmodel som inhåller user och dess matchvalue
            {
                UserMatchesModel = new List <UserMatchModel>()
            };

            using (var userRepository = new UserRepository())
            {
                var random          = new Random();
                var matchRepository = new MatchingRepository();
                var users           = userRepository.GetAllUsers(userName);
                foreach (var user in users)
                {
                    model.UserMatchesModel.Add(new UserMatchModel()
                    {
                        MatchValue = matchRepository.MatchUsers(userName, user.UserName, random),
                        User       = user
                    });
                }
            }

            //Sorterar listan efter matchvalue
            var ordered = model.UserMatchesModel.OrderByDescending(x => int.Parse(x.MatchValue)).ToList();

            model.UserMatchesModel = ordered;

            //Lägger til % för att fungera till vår css.
            foreach (var userMatchModel in model.UserMatchesModel)
            {
                userMatchModel.MatchValue += "%";
            }

            return(View(model));
        }