Ejemplo 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);
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Request.IsAuthenticated)
            {
                Response.Redirect(WebConfigurationManager.AppSettings["LoginPageURL"].ToString());
            }

            Guid userId = new Guid(Request.QueryString["UserId"]);

            using (FlexibleTennisLeagueDataContext dataContext = new FlexibleTennisLeagueDataContext())
            {
                ISingleResult <SelectUserPublicProfileByProfileIdResult> users = dataContext.SelectUserPublicProfileByProfileId(userId);
                SelectUserPublicProfileByProfileIdResult user = users.First();
                userLabel.Text = user.FirstName + " " + user.LastName;

                //Load Image
                if (user.ProfileImageName.HasValue)
                {
                    profileImage.ImageUrl = string.Format("~/ProfileImages/{0}.jpg", user.ProfileImageName.ToString());
                }

                divisionLabel.Text     = user.Division;
                homeCourtLabel.Text    = user.CourtName;
                ntrpRankingLabel.Text  = user.NTRPRanking.ToString();
                ageGroupLabel.Text     = user.AgeGroup;
                racquetHandLabel.Text  = user.RacquetHand;
                favoriteShotLabel.Text = user.FavoriteShot;
                racquetLabel.Text      = user.Racquet;


                if (!StoredData.User.TempDivision.Value || (user.DivisionId != StoredData.User.Division) || !StoredData.User.AccessExpired.Value)
                {
                    emailHyperLink.Text           = user.EmailId;
                    emailHyperLink.NavigateUrl    = string.Format("mailto:{0}", user.EmailId);
                    phoneLabel.Text               = user.Phone;
                    facebookHyperLink.Text        = user.Facebook;
                    facebookHyperLink.NavigateUrl = user.Facebook;
                    linkedInHyperLink.Text        = user.LinkedIn;
                    linkedInHyperLink.NavigateUrl = user.LinkedIn;
                    myspaceHyperLink.Text         = user.MySpace;
                    myspaceHyperLink.NavigateUrl  = user.MySpace;
                    orkutHyperLink.Text           = user.Orkut;
                    orkutHyperLink.NavigateUrl    = user.Orkut;
                }

                List <Performance> performances = dataContext.SelectPerformanceByUserId(user.UserId).ToList();

                Performance seasonPerformance = performances.Find(p => p.DivisionId == user.DivisionId);
                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();

                if (!StoredData.User.TempDivision.Value)
                {
                    List <GetUpcomingMatchesResult> upcomingMatches = dataContext.GetUpcomingMatches(user.UserId).ToList();
                    upcomingMatchesRadGrid.DataSource = upcomingMatches;
                    upcomingMatchesRadGrid.DataBind();

                    List <GetPreviousMatchesResult> previousMatches = dataContext.GetPreviousMatches(user.UserId).ToList();
                    previousMatchesRadGrid.DataSource = previousMatches;
                    previousMatchesRadGrid.DataBind();


                    int upcomingMatchCount = Convert.ToInt32(upcomingMatches.Count(p => p.UserId == StoredData.User.UserId));
                    int previousMatchCount = Convert.ToInt32(previousMatches.Count(p => p.UserId == StoredData.User.UserId));
                }

                //Get availability
                List <SelectAvailabilitiesByUserIdResult> availabilities = dataContext.SelectAvailabilitiesByUserId(user.UserId).ToList();
                SetAvailabilities(availabilities);

                if (StoredData.User.TempDivision.Value || StoredData.User.AccessExpired.Value)
                {
                    matchRequestLinkButton.Enabled = false;
                }
                else
                {
                    List <SelectDivisionResult> selectDivisionResult = dataContext.SelectDivision(StoredData.User.Division.Value).ToList();
                    foreach (SelectDivisionResult result in selectDivisionResult)
                    {
                        if (result.StartDate > DateTime.Now)
                        {
                            matchRequestLinkButton.Enabled = false;
                        }
                    }
                }

                //TODO: Have to uncomment these lines below
                //if ((upcomingMatchCount + previousMatchCount) < 2)
                matchRequestLinkButton.Attributes.Add("onClick", string.Format("openRadWindow('{0}'); return false;", user.UserId));
                //else
                //matchRequestLinkButton.Attributes.Add("onClick", "alert('You have already played two matches against this player for the season. You cannot play against a player more than twice.');return false;");
                //matchRequestLinkButton.PostBackUrl = WebConfigurationManager.AppSettings["MatchRequestPath"].ToString();
            }
        }