Esempio n. 1
0
        private ScheduleStandingsViewModel GetTeamRecord(Team team, List<ScheduleGame> games)
        {
            int teamNo;

            if (Int32.TryParse(team.TeamNumber, out teamNo)) ///getting team no!
            {
                var teamNumber = GetTeamNo(games.First().ScheduleNumber, teamNo);
                var seasonRecord = new ScheduleStandingsViewModel
                   {
                       TeamNo = Convert.ToInt32(team.TeamNumber),
                       TeamName = team.TeamName,
                       DivNo = team.DivisionID.ToString(),
                       Won = 0,
                       Lost = 0,
                       PF = 0,
                       PA = 0
                   };

                var records = games.Where(g => g.HomeTeamNumber == teamNumber || g.VisitingTeamNumber == teamNumber);
                foreach (var record in records)
                {
                    if (record.HomeTeamScore > 0 || record.VisitingTeamScore > 0)
                    {
                        if (teamNumber == record.HomeTeamNumber)
                        {
                            seasonRecord.PA += (int)record.VisitingTeamScore;
                            seasonRecord.PF += (int)record.HomeTeamScore;

                            if (record.HomeTeamScore > record.VisitingTeamScore)
                                seasonRecord.Won++;
                            else
                                seasonRecord.Lost++;
                        }
                        else
                        {
                            if (teamNumber == record.VisitingTeamNumber)
                            {
                                seasonRecord.PF += (int)record.VisitingTeamScore;
                                seasonRecord.PA += (int)record.HomeTeamScore;
                                if (record.VisitingTeamScore > record.HomeTeamScore)
                                    seasonRecord.Won++;
                                else
                                    seasonRecord.Lost++;
                            }
                        }
                    }
                }
                if ((seasonRecord.Won + seasonRecord.Lost) > 0)
                {
                    Decimal Pct = ((decimal)seasonRecord.Won / (decimal)(seasonRecord.Won + seasonRecord.Lost)) * 100;
                    seasonRecord.Pct = Pct;
                }
                else
                    seasonRecord.Pct = 0;
                return seasonRecord;
            }
            else
                return new ScheduleStandingsViewModel();
        }
Esempio n. 2
0
        private void LoadStandings(int iDiv)
        {
            if (panelStandings.Visible)
            {
                var vm = new ScheduleStandingsViewModel();
                var standings = vm.GetStandings(iDiv);

                grdStandings.DataSource = standings;
                //grdStandings.DataValueField = "DivisionID";
                //grdStandings.DataTextField = "Div_Desc";
                grdStandings.DataBind();
            }
        }
Esempio n. 3
0
 public void GetStandingsTest()
 {
     var vm = new ScheduleStandingsViewModel();
     var standings =  vm.GetStandings(757);
     Assert.IsTrue(standings.Any<Csbchoops.Web.ViewModels.ScheduleStandingsViewModel>());
 }