Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Request.IsAuthenticated)
            {
                Response.Redirect(WebConfigurationManager.AppSettings["LoginPageURL"].ToString());
            }

            if (!Page.IsPostBack)
            {
                using (FlexibleTennisLeagueDataContext dataContext = new FlexibleTennisLeagueDataContext())
                {
                    List <Performance> performances = dataContext.SelectPerformanceByUserId(StoredData.User.UserId).ToList();

                    Performance seasonPerformance = performances.Find(p => p.DivisionId == StoredData.User.Division);
                    seasonWinsLabel.Text   = string.Format("{0}W - {1}L", seasonPerformance.Win, seasonPerformance.Loss);
                    seasonPointsLabel.Text = seasonPerformance.TotalPoints.ToString();

                    overallWinsLabel.Text   = string.Format("{0}W - {1}L", performances.Sum(p => p.Win), performances.Sum(p => p.Loss));
                    overallPointsLabel.Text = performances.Sum(p => p.TotalPoints).ToString();

                    ISingleResult <SelectDivisionResult> divisions = dataContext.SelectDivision(StoredData.User.Division);
                    SelectDivisionResult division = divisions.First();

                    List <SelectRatingsByUserIdStartEndDateResult> ratings = dataContext.SelectRatingsByUserIdStartEndDate(StoredData.User.UserId, division.StartDate, division.EndDate).ToList();

                    List <SelectRatingsByUserIdStartEndDateResult> validOwnRatings = ratings.FindAll(p => p.OwnForehand.HasValue);
                    if (validOwnRatings.Count > 0)
                    {
                        DrawRateOwnPerformanceChart(validOwnRatings);
                        DrawRateOwnDetailPerformanceChart(validOwnRatings);
                    }

                    List <SelectOpponentRatingsByUserIdStartEndDateResult> opponentRatings      = dataContext.SelectOpponentRatingsByUserIdStartEndDate(StoredData.User.UserId, division.StartDate, division.EndDate).ToList();
                    List <SelectOpponentRatingsByUserIdStartEndDateResult> validOpponentRatings = opponentRatings.FindAll(p => p.OpponentForehand.HasValue);
                    if (validOpponentRatings.Count > 0)
                    {
                        DrawRateOthersPerformanceChart(validOpponentRatings);
                        DrawRateOpponentServeChart(validOpponentRatings);
                    }
                }
            }
        }