예제 #1
0
파일: UnitTest1.cs 프로젝트: box90/RCW2019
        public async System.Threading.Tasks.Task TestStartAsync()
        {
            MatchesRepository rep = new MatchesRepository();
            var match             = await rep.StartMatch(1);

            Assert.IsTrue(match);
        }
예제 #2
0
        public ActionResult Edit(MatchReport report)
        {
            List <SelectListItem> matchesList = new List <SelectListItem>();
            MatchesRepository     matchesRep  = new MatchesRepository();
            var myMatches = matchesRep.GetAllMatches().OrderBy(k => k.TimeStamp);

            if (myMatches.Count() > 0)
            {
                foreach (Match m in myMatches)
                {
                    SelectListItem sli = new SelectListItem();
                    sli.Value = m.Id.ToString();
                    sli.Text  = m.HomeTeamName + "  ( " + m.HomeGoals + "-" + m.AwayGoals + " )  " + m.AwayTeamName;
                    matchesList.Add(sli);
                }
                ViewData["Matches"] = matchesList;
                if (ModelState.IsValid)
                {
                    MatchReport model = db.MatchReports.Where(l => l.Id == report.Id).FirstOrDefault();

                    model.Contents = report.Contents;
                    db.SubmitChanges();
                    return(RedirectToAction("Index"));
                }
            }

            return(View(report));
        }
예제 #3
0
        public ActionResult Add(MatchReport report)
        {
            List <SelectListItem> matchesList = new List <SelectListItem>();
            MatchesRepository     matchesRep  = new MatchesRepository();
            var myMatches = matchesRep.GetAllMatches().OrderBy(k => k.TimeStamp);

            if (myMatches.Count() > 0)
            {
                foreach (Match m in myMatches)
                {
                    SelectListItem sli = new SelectListItem();
                    sli.Value = m.Id.ToString();
                    sli.Text  = m.HomeTeamName + "  ( " + m.HomeGoals + "-" + m.AwayGoals + " )  " + m.AwayTeamName;
                    matchesList.Add(sli);
                }
                ViewData["Matches"] = matchesList;
                if (ModelState.IsValid)
                {
                    MatchReportsRepository matchreportrep = new MatchReportsRepository();

                    matchreportrep.Add(report);
                    matchreportrep.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }

            return(View(report));
        }
        public ActionResult Guests(int ID)
        {
            List <SelectListItem> tlist       = new List <SelectListItem>();
            List <SelectListItem> matcheslist = new List <SelectListItem>();
            MatchesRepository     matchrep    = new MatchesRepository();
            var mymatches = matchrep.GetAllMatches();

            foreach (Match m in mymatches.Where(i => i.GuestTeamId == ID && i.Date.Date == DateTime.Today.Date))
            {
                SelectListItem sli = new SelectListItem();
                sli.Value = m.MatchId.ToString();
                sli.Text  = m.HomeTeam.Name + " " + m.HomeGoals + "-" + m.AwayGoals + " " + m.GuestTeam.Name;
                SelectListItem sli2 = new SelectListItem();
                sli2.Value = m.GuestTeamId.ToString();
                sli2.Text  = m.GuestTeam.Name;
                tlist.Add(sli2);
                matcheslist.Add(sli);
            }
            var pl = db.player.Where(i => i.TeamId == ID).Select(s => new SelectListItem
            {
                Value = s.ID.ToString(),
                Text  = s.Name + " " + s.LastName + " " + s.Number
            });

            ViewData["Matches"]    = matcheslist;
            ViewData["GuestTeams"] = tlist;
            ViewBag.MatchId        = new SelectList(db.matches, "MatchId", "MatchId");
            ViewBag.ID             = new SelectList(pl, "Value", "Text");
            ViewBag.StatisticId    = new SelectList(db.statistic, "StatisticId", "PName");
            ViewBag.GuestTeamId    = new SelectList(db.team.Where(i => i.TeamId == ID), "TeamId", "Name");
            return(View());
        }
예제 #5
0
파일: UnitTest1.cs 프로젝트: box90/RCW2019
        public async System.Threading.Tasks.Task TestResultsAsync()
        {
            MatchesRepository rep = new MatchesRepository();
            var matches           = await rep.GetResults();

            Assert.IsTrue(matches.Any());
        }
예제 #6
0
        public ActionResult Add(Report report)
        {
            List <SelectListItem> matchlist = new List <SelectListItem>();
            MatchesRepository     matchrep  = new MatchesRepository();
            var mymatches = matchrep.GetAllMatches().OrderByDescending(k => k.Fixture.TimeStamp);

            if (mymatches.Count() > 0)
            {
                foreach (Match m in mymatches)
                {
                    SelectListItem sli = new SelectListItem();
                    sli.Value = m.Id.ToString();
                    sli.Text  = m.Fixture.HomeTeamName + " (" + m.HomeTeamGoals + " - " + m.AwayTeamGoals + " ) " + m.Fixture.HomeTeamName;
                    matchlist.Add(sli);
                }
            }
            ViewData["MyReports"] = matchlist;

            if (!String.IsNullOrEmpty(report.Comment))
            {
                //Continue
                ReportsRepository ReportRep = new ReportsRepository();
                ReportRep.Add(report);
                ReportRep.SaveChanges();

                return(Redirect("/reports"));
            }
            else
            {
                ModelState.AddModelError("Comment,", "Please make sure you have entered a match report");
            }
            return(View(report));
        }
예제 #7
0
        public ActionResult Matches(int?Id)
        {
            MatchesRepository db = new MatchesRepository();
            var matches          = db.GetAllMatches().Where(i => i.HomeTeamId == Id || i.GuestTeamId == Id).OrderBy(i => i.Date);

            ViewData["MyMatches"] = matches;
            return(View());
        }
예제 #8
0
파일: UnitTest1.cs 프로젝트: box90/RCW2019
        public async System.Threading.Tasks.Task TestMatchDetailAsync()
        {
            MatchesRepository rep = new MatchesRepository();
            var match             = await rep.GetMatch(1, false);

            var events = match.Events.ToList();

            Assert.IsTrue(match.Id == 1);
        }
예제 #9
0
        public ActionResult Mentor(MentorFormModel mentor)
        {
            if (ModelState.IsValid)
            {
                using (var db = new Mentor_MatchineEntities())
                {
                    var mlr      = new MenteeLanguagesRepository(db);
                    var mentorlr = new MentorLanguagesRepository(db);
                    var mpr      = new MentorPreferencesRepository(db);
                    var matchesR = new MatchesRepository(db);
                    var mr       = new MenteeRepository(db);
                    var mentorR  = new MentorRepository(db);

                    var manager = new Director();
                    var builder = new SimpleMatcherBuilder();
                    manager.Construct(builder, mlr, mr, matchesR);
                    var matcher = builder.GetResult();

                    var MentorFactory = new MentorFactory(mentorlr, mpr, matcher);
                    var email         = new EmailSender();

                    MentorManager mentorManager = new MentorManager(db, mentorR, mpr, mentorlr);
                    int           id            = mentorManager.AddMentorFromForm(mentor);

                    var mentorUser = MentorFactory.GetUser(mentorR.FindById(id));
                    mentorUser.Id = id;
                    var matches = mentorUser.Match();

                    var f      = mentorR.FindById(id).C_Mentees;
                    var emails = new List <String>();
                    foreach (int i in matches)
                    {
                        emails.Add(mr.FindById(i).Email);
                        f = f - 1;
                    }
                    mentorR.FindById(id).C_Mentees = f;
                    foreach (string e in emails)
                    {
                        email.SendEmail(e);
                    }
                    var languages = db.Lang.Select(l => new {
                        LangID   = l.LanguageID,
                        Language = l.SpokenLang
                    }).ToList();
                    var nationalities = db.Nationality.Select(l => new {
                        NatID       = l.NationalityID,
                        Nationality = l.Nationality1
                    }).ToList();
                    ViewBag.Languages     = new MultiSelectList(languages, "LangID", "Language");
                    ViewBag.Nationalities = new MultiSelectList(nationalities, "NatID", "Nationality");
                    return(View("Mentor"));
                }
            }

            return(View("~/Views/Home/Index.cshtml"));
        }
예제 #10
0
        public ActionResult Add(Match match)
        {
            List <SelectListItem> teamlist = new List <SelectListItem>();
            TeamsRepository       teamsrep = new TeamsRepository();
            var myteams = teamsrep.GetAllTeams().OrderBy(k => k.TeamName);

            if (myteams.Count() > 0)
            {
                foreach (Team t in myteams)
                {
                    SelectListItem sli = new SelectListItem();
                    sli.Value = t.Id.ToString();
                    sli.Text  = t.TeamName;
                    teamlist.Add(sli);
                }
            }
            ViewData["Teams"] = teamlist;


            if (match.HomeGoals != null)
            {
                if (match.AwayGoals != null)
                {
                    if (match.Timestamp != null)
                    {
                        if (match.HomeTeamId != match.AwayTeamId)
                        {
                            MatchesRepository matchesrep = new MatchesRepository();
                            matchesrep.Add(match);
                            matchesrep.SaveChanges();

                            return(Redirect("/matches"));
                        }
                        else
                        {
                            ModelState.AddModelError("HomeTeamId", "Please make sure that the teams are different for home and away sides");
                            ModelState.AddModelError("AwayTeamId", "Please make sure that the teams are different for home and away sides");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("Timestamp", "Please make sure you've entered a valid date for this match");
                    }
                }
                else
                {
                    ModelState.AddModelError("AwayGoals", "Please make sure you've entered the number of goals that the away team scored");
                }
            }
            else
            {
                ModelState.AddModelError("HomeGoals", "Please make sure you've entered the number of goals that the home team scored");
            }
            return(View());
        }
예제 #11
0
        // GET: Matches
        public ActionResult Index()
        {
            MatchesRepository matchesrep = new MatchesRepository();
            var mymatches = matchesrep.GetAllMatches();

            if (mymatches.Count() > 0)
            {
                ViewData["MyMatches"] = mymatches.OrderByDescending(k => k.Timestamp);
            }
            return(View());
        }
예제 #12
0
        public void MatchesTestInitialize()
        {
            MatchesRepository = new MatchesRepository();
            PlayersRepository = new PlayersRepository();

            Controller = new MatchesController(MatchesRepository, PlayersRepository)
            {
                Request       = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };
        }
예제 #13
0
        // GET: Matches
        public ActionResult Index()
        {
            MatchesRepository matchesrep = new MatchesRepository();

            var myMatches = matchesrep.GetAllMatches();

            if (myMatches.Count() > 0)
            {
                ViewData["MyMatches"] = myMatches.OrderByDescending(k => k.TimeStamp);
                //viewdata like a tag which contains all the information and put into view
            }

            return(View());
        }
예제 #14
0
        // GET: Match
        // [Authorize(Roles = "Admin")]
        public ActionResult Index(string team)
        {
            euroContext       db1   = new euroContext();
            MatchesRepository db    = new MatchesRepository();
            TeamRepository    teams = new TeamRepository();
            var matches             = db.GetAllMatches().OrderBy(i => i.Date);

            ViewBag.team1 = (from t in teams.GetAllTeams()
                             select t.Name);

            var model = from r in db.GetAllMatches()
                        where r.HomeTeam.Name == team || r.GuestTeam.Name == team
                        select r;

            ViewData["MyMatches"] = matches;

            return(View(model));
        }
        public ActionResult Add()
        {
            List <SelectListItem> matcheslist = new List <SelectListItem>();
            MatchesRepository     matchrep    = new MatchesRepository();
            var mymatches = matchrep.GetAllMatches();

            foreach (Match m in mymatches)
            {
                if (m.Date == DateTime.Now.Date)
                {
                    SelectListItem sli = new SelectListItem();
                    sli.Value = m.MatchId.ToString();
                    sli.Text  = m.HomeTeam.Name + " " + m.HomeGoals + "-" + m.AwayGoals + " " + m.GuestTeam.Name;
                    matcheslist.Add(sli);
                }
            }
            ViewData["Matches"] = matcheslist;
            return(View());
        }
예제 #16
0
        public ActionResult Add()
        {
            List <SelectListItem> matchlist = new List <SelectListItem>();
            MatchesRepository     matchrep  = new MatchesRepository();
            var mymatches = matchrep.GetAllMatches().OrderByDescending(k => k.Fixture.TimeStamp);

            if (mymatches.Count() > 0)
            {
                foreach (Match m in mymatches)
                {
                    SelectListItem sli = new SelectListItem();
                    sli.Value = m.Id.ToString();
                    sli.Text  = m.Fixture.HomeTeamName + " (" + m.HomeTeamGoals + " - " + m.AwayTeamGoals + ") " + m.Fixture.AwayTeamName;
                    matchlist.Add(sli);
                }
            }
            ViewData["MyReports"] = matchlist;
            return(View());
        }
예제 #17
0
        public ActionResult Add(Match match)
        {
            List <SelectListItem> fixturelist = new List <SelectListItem>();
            FixturesRepository    fixrep      = new FixturesRepository();
            var myfixtures = fixrep.GetAllFixtures().OrderByDescending(k => k.TimeStamp);

            if (myfixtures.Count() > 0)
            {
                foreach (Fixture f in myfixtures)
                {
                    SelectListItem sli = new SelectListItem();
                    sli.Value = f.Id.ToString();
                    sli.Text  = f.HomeTeamName + " vs " + f.AwayTeamName;
                    fixturelist.Add(sli);
                }
            }
            ViewData["MyMatches"] = fixturelist;

            MatchesRepository matchrep = new MatchesRepository();

            if (match.HomeTeamGoals != null)
            {
                if (match.AwayTeamGoals != null)
                {
                    matchrep.Add(match);
                    matchrep.SaveChanges();

                    return(Redirect("/matches"));
                }
                else
                {
                    ModelState.AddModelError("TeamAwayGoals", "Please make sure you've entered the number of goals that the away team scored");
                }
            }
            else
            {
                ModelState.AddModelError("TeamHomeGoals", "Please make sure you've entered the number of goals that the home team scored");
            }
            return(View(match));
        }
예제 #18
0
        public ActionResult Add(Match match)
        {
            List <SelectListItem> teamlist = new List <SelectListItem>();
            TeamsRepository       teamsrep = new TeamsRepository();
            var myTeams = teamsrep.GetAllTeams().OrderBy(k => k.TeamName);

            if (myTeams.Count() > 0)
            {
                foreach (Team t in myTeams)
                {
                    SelectListItem sli = new SelectListItem();
                    sli.Value = t.Id.ToString();
                    sli.Text  = t.TeamName;
                    teamlist.Add(sli);
                }
                ViewData["Teams"] = teamlist;
                //duplicating the dropdownlist if we make errors....


                if (match.HomeTeamId == match.AwayTeamId)
                {
                    ModelState.AddModelError("HomeTeamId", "Please select different teams");
                    //ModelState.AddModelError("HomeTeamId", "Please select different teams");
                }

                else if (ModelState.IsValid)
                {
                    MatchesRepository matchesrep = new MatchesRepository();
                    {
                        matchesrep.Add(match);
                        matchesrep.SaveChanges();

                        return(RedirectToAction("Index"));
                    }
                }
            }

            return(View(match));
        }
        public ActionResult Create([Bind(Include = "MatchDetailsId,Content,MatchId,ID,Name,LastName,StatisticId,HomeTeamId,Min")] MatchDetails matchDetails, int ID)
        {
            List <SelectListItem> matcheslist = new List <SelectListItem>();
            List <SelectListItem> tlist       = new List <SelectListItem>();
            MatchesRepository     matchrep    = new MatchesRepository();
            var mymatches = matchrep.GetAllMatches();

            if (ModelState.IsValid)
            {
                foreach (Match m in mymatches.Where(i => i.HomeTeamId == ID))
                {
                    SelectListItem sli1 = new SelectListItem();

                    SelectListItem sli = new SelectListItem();
                    sli.Value  = m.MatchId.ToString();
                    sli.Text   = m.HomeTeam.Name + " " + m.HomeGoals + "-" + m.AwayGoals + " " + m.GuestTeam.Name;
                    sli1.Value = m.HomeTeamId.ToString();
                    sli1.Text  = m.HomeTeam.Name;

                    matcheslist.Add(sli);
                    tlist.Add(sli1);
                }

                ViewData["Matches"] = matcheslist;
                ViewData["Teams"]   = tlist;
                // ViewData["GuestTeams"] = tlist;
                db.MatchDetails.Add(matchDetails);
                db.SaveChanges();
                return(RedirectToAction("Index", "Match"));
            }

            ViewBag.MatchId     = new SelectList(db.matches, "MatchId", "MatchId", matchDetails.MatchId);
            ViewBag.ID          = new SelectList(db.player.Where(i => i.TeamId == ID), "ID", "Name", "LastName", matchDetails.ID);
            ViewBag.StatisticId = new SelectList(db.statistic, "StatisticId", "PName", matchDetails.StatisticId);
            ViewBag.HomeTeamId  = new SelectList(db.team.Where(i => i.TeamId == ID), "TeamId", "Name", matchDetails.HomeTeamId);
            // ViewBag.GuestTeamId = new SelectList(db.team.Where(i => i.TeamId == ID), "TeamId", "Name", matchDetails.GuestTeamId);
            return(View());
        }
예제 #20
0
        public ActionResult Edit(int?Id)
        {
            List <SelectListItem> matchesList = new List <SelectListItem>();

            MatchesRepository matchesRep = new MatchesRepository();
            var myMatches = matchesRep.GetAllMatches().OrderBy(k => k.TimeStamp);

            if (myMatches.Count() > 0)
            {
                foreach (Match m in myMatches)
                {
                    SelectListItem sli = new SelectListItem();
                    sli.Value = m.Id.ToString();
                    sli.Text  = m.HomeTeamName + "  ( " + m.HomeGoals + "-" + m.AwayGoals + " )  " + m.AwayTeamName;
                    matchesList.Add(sli);
                }
            }

            ViewData["Matches"] = matchesList;

            MatchReport model = db.MatchReports.Where(l => l.Id == Id).FirstOrDefault();

            return(View(model));
        }
예제 #21
0
 protected void InitDataObjects()
 {
     eventsRepo = new EventsRepository();
     scoreMethodRepo = new ScoreMethodRepository();
     seriesRepo = new SeriesRepository();
     teamsRepo = new TeamsRepository();
     eventTeamsRepo = new EventTeamsRepository();
     playersRepo = new PlayersRepository();
     eventPlayersRepo = new EventPlayersRepository();
     matchRepo = new MatchesRepository();
     matchTeamsRepo = new MatchTeamsRepository();
     packsetRepo = new PacksetsRepository();
     matchPlayerRepo = new MatchPlayersRepository();
 }
        public ActionResult GetMatches()
        {
            MatchesRepository matchService = new MatchesRepository();

            return(PartialView("_MatchesList", matchService.GetAllMatches()));
        }
예제 #23
0
        // GET: Tables
        public ActionResult Index()

        {
            List <LeagueTableResult> results    = new List <LeagueTableResult>();
            MatchesRepository        matchesrep = new MatchesRepository();
            TeamsRepository          teamsrep   = new TeamsRepository();

            var allteams   = teamsrep.GetAllTeams();
            var allmatches = matchesrep.GetAllMatches();

            if (allteams.Count() > 0)
            {
                foreach (Team t in allteams)
                {
                    LeagueTableResult res = new LeagueTableResult();
                    res.TeamId   = t.Id;
                    res.TeamName = t.TeamName;

                    //calc number of wins for team
                    int wins         = 0;
                    int losses       = 0;
                    int draws        = 0;
                    int goalsfor     = 0;
                    int goalsagainst = 0;
                    int points       = 0;

                    var allteammatches     = allmatches.Where(l => l.HomeTeamId == t.Id || l.AwayTeamId == t.Id);
                    var allteamhomematches = allteammatches.Where(l => l.HomeTeamId == t.Id);
                    var allteamawaymatches = allteammatches.Where(l => l.AwayTeamId == t.Id);

                    foreach (Match m in allteamhomematches)
                    {
                        if (m.HomeGoals > m.AwayGoals)
                        {
                            wins++;
                            points += 3;
                        }
                        if (m.HomeGoals == m.AwayGoals)
                        {
                            draws++;
                            points += 1;
                        }

                        if (m.HomeGoals < m.AwayGoals)
                        {
                            losses++;
                        }

                        goalsfor     += (int)m.HomeGoals;
                        goalsagainst += (int)m.AwayGoals;
                    }

                    foreach (Match m in allteamawaymatches)
                    {
                        if (m.AwayGoals > m.HomeGoals)
                        {
                            wins++;
                            points += 3;
                        }
                        if (m.AwayGoals == m.HomeGoals)
                        {
                            draws++;
                            points += 1;
                        }
                        if (m.AwayGoals < m.HomeGoals)
                        {
                            losses++;
                        }

                        goalsfor     += (int)m.AwayGoals;
                        goalsagainst += (int)m.HomeGoals;
                    }
                    res.GoalsFor       = goalsfor;
                    res.GoalsAgainst   = goalsagainst;
                    res.GoalDifference = goalsfor - goalsagainst;
                    res.Wins           = wins;
                    res.Losses         = losses;
                    res.Draws          = draws;
                    res.Points         = points;

                    results.Add(res);
                }
            }

            ViewData["results"] = results.OrderByDescending(k => k.Points).ThenByDescending(k => k.GoalDifference);


            return(View());
        }
예제 #24
0
 public override void BuildMatchesR(MatchesRepository matches)
 {
     _SimpleMatcher.MatchesR = matches;
 }
예제 #25
0
 public abstract void BuildMatchesR(MatchesRepository matches);
예제 #26
0
 public MatchesController(ChessClubContext context)
 {
     _repository = new MatchesRepository(context);
 }
예제 #27
0
        public ActionResult Index()
        {
            List <Table>      table    = new List <Table>();
            MatchesRepository matchrep = new MatchesRepository();
            var            allMatches  = matchrep.GetAllMatches();
            TeamRepository teamsrep    = new TeamRepository();
            var            allTeams    = teamsrep.GetAllTeams();

            foreach (Team t in allTeams)
            {
                Table result = new Table();
                result.Id       = t.TeamId;
                result.TeamName = t.Name;
                int losses             = 0;
                int draws              = 0;
                int wins               = 0;
                int goalsfor           = 0;
                int goalsAgainst       = 0;
                int points             = 0;
                int Total              = 0;
                var allTeamMAtches     = allMatches.Where(k => k.HomeTeamId == t.TeamId || k.GuestTeamId == t.TeamId);
                var allTeamHomeMatches = allTeamMAtches.Where(k => k.HomeTeamId == t.TeamId);
                var allTeamAwayMatches = allTeamMAtches.Where(k => k.GuestTeamId == t.TeamId);

                foreach (Match m in allTeamHomeMatches.Where(i => i.Date <= DateTime.Now))
                {
                    if (m.HomeGoals > m.AwayGoals)
                    {
                        wins++;
                        points += 3;
                    }
                    if (m.HomeGoals < m.AwayGoals)
                    {
                        losses++;
                        points += 0;
                    }
                    if (m.HomeGoals == m.AwayGoals)
                    {
                        draws++;
                        points += 1;
                    }
                    Total         = wins + draws + losses;
                    goalsfor     += m.HomeGoals;
                    goalsAgainst += m.AwayGoals;
                }



                foreach (Match m in allTeamAwayMatches.Where(i => i.Date <= DateTime.Now))
                {
                    if (m.AwayGoals > m.HomeGoals)
                    {
                        wins++;
                        points += 3;
                    }
                    if (m.AwayGoals < m.HomeGoals)
                    {
                        losses++;
                        points += 0;
                    }
                    if (m.AwayGoals == m.HomeGoals)
                    {
                        draws++;
                        points += 1;
                    }
                    Total         = wins + draws + losses;
                    goalsfor     += m.AwayGoals;
                    goalsAgainst += m.HomeGoals;
                }


                result.Wins        = wins;
                result.Losses      = losses;
                result.Draws       = draws;
                result.GoalsFor    = goalsfor;
                result.GoalsAgains = goalsAgainst;
                result.Difference  = goalsfor - goalsAgainst;
                result.Points      = points;
                result.totoal      = Total;
                table.Add(result);
            }
            ViewData["Result"] = table.OrderByDescending(k => k.Points).ThenByDescending(k => k.Difference);
            return(View());
        }
예제 #28
0
        // GET: Tables
        public ActionResult Index()
        {
            List <LeagueTableResults> results    = new List <LeagueTableResults>();
            MatchesRepository         matchesrep = new MatchesRepository();
            var allmatches = matchesrep.GetAllMatches();

            TeamsRepository teamsrep = new TeamsRepository();

            var allteams = teamsrep.GetAllTeams();

            if (allteams.Count() > 0)
            {
                foreach (Team t in allteams)
                {
                    LeagueTableResults res = new LeagueTableResults();
                    res.TeamId   = t.Id;
                    res.TeamName = t.Name;

                    //Calculate number of wins

                    int wins  = 0;
                    int lost  = 0;
                    int draws = 0;

                    int fgoals = 0;
                    int agoals = 0;

                    int points = 0;


                    var allteammatches     = allmatches.Where(m => m.Fixture.HomeTeamId == t.Id || m.Fixture.AwayTeamId == t.Id);
                    var allteamhomematches = allteammatches.Where(m => m.Fixture.HomeTeamId == t.Id);
                    var allteamawaymatches = allteammatches.Where(m => m.Fixture.AwayTeamId == t.Id);
                    var noplayed           = 0;
                    noplayed = allmatches.Where(m => m.Fixture.HomeTeamId == t.Id || m.Fixture.AwayTeamId == t.Id).Count();
                    foreach (Match m in allteamhomematches)
                    {
                        if (m.HomeTeamGoals > m.AwayTeamGoals)
                        {
                            wins++;
                            points = points + 3;
                        }

                        if (m.HomeTeamGoals < m.AwayTeamGoals)
                        {
                            lost++;
                            points = points + 0;
                        }
                        if (m.HomeTeamGoals == m.AwayTeamGoals)
                        {
                            draws++;
                            points = points + 1;
                        }

                        fgoals += (int)m.HomeTeamGoals;
                        agoals += (int)m.AwayTeamGoals;
                    }

                    foreach (Match m in allteamawaymatches)
                    {
                        if (m.AwayTeamGoals > m.HomeTeamGoals)
                        {
                            wins++;
                            points = points + 3;
                        }
                        if (m.AwayTeamGoals < m.HomeTeamGoals)
                        {
                            lost++;
                            points = points + 0;
                        }
                        if (m.AwayTeamGoals == m.HomeTeamGoals)
                        {
                            draws++;
                            points = points + 1;
                        }

                        fgoals += (int)m.AwayTeamGoals;
                        agoals += (int)m.HomeTeamGoals;
                    }
                    res.Win    = wins;
                    res.Lost   = lost;
                    res.Draw   = draws;
                    res.GF     = fgoals;
                    res.GA     = agoals;
                    res.GD     = fgoals - agoals;
                    res.Points = points;
                    res.Played = noplayed;

                    results.Add(res);
                }
            }

            ViewData["Results"] = results.OrderByDescending(r => r.Points).ThenByDescending(r => r.GD);
            return(View());
        }
예제 #29
0
        public void Construct(MatcherBuilder builder, MenteeLanguagesRepository mlr, MenteeRepository mr, MatchesRepository matches)

        {
            builder.BuildMenteeRep(mr);
            builder.BuildMLRep(mlr);
            builder.BuildMatchesR(matches);
        }