protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { m_ContestContext = new TableHockeyContest(); //Get contest details for existing contest or create new. Init contest uc int m_nContestId = -1; if (!String.IsNullOrEmpty(Request.QueryString["ContestId"])) //TODO: Integer validation. { //Get existing contest and init uc. m_nContestId = Convert.ToInt32(Request.QueryString["ContestId"]); MembershipUser user = Membership.GetUser(m_sUser.Trim()); if (user != null) { using (var context = new TableHockeyData.UHSSWEB_DEVEntities()) { try { var querySingleContest = (from c in context.TableHockeyContest where c.OwnerUserId == (Guid)user.ProviderUserKey && c.ContestId == m_nContestId select c).FirstOrDefault(); if (querySingleContest.EndGameForContestId != null) { //It's an end game for another contest, redirect to end game page edit. Response.Redirect("~/pgEditContestTableEndGame.aspx?ContestId=" + Convert.ToString(m_nContestId), false); } if (querySingleContest != null) { this.ucEditTableHockeyContest1.InitControl((TableHockeyContest)querySingleContest); } else { this.ucEditTableHockeyContest1.InitControl(null); } } catch (Exception ex) { Response.Redirect("~/pgEditContest.aspx"); } } divAddPlayers.Visible = true; } } else { //Init uc for new contest divAddPlayers.Visible = false; this.ucEditTableHockeyContest1.InitControl(null); } } else { } }
public void InitControl(TableHockeyData.TableHockeyContest i_TableHockeyContest) { if (i_TableHockeyContest != null) { //Edit existing contest m_contest = i_TableHockeyContest; } else { //Create new contest m_contest = new TableHockeyContest(); m_contest.ContestId = -1; } setUCGUI(); Session["ucEditTableHockeyContest.m_contest"] = m_contest; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { m_ContestContext = new TableHockeyContest(); //Get contest details for existing contest or create new. Init contest uc int m_nContestId = -1; if (!String.IsNullOrEmpty(Request.QueryString["ContestId"])) { //Get existing contest and init uc. m_nContestId = Convert.ToInt32(Request.QueryString["ContestId"]); MembershipUser user = Membership.GetUser(m_sUser.Trim()); //Check if caller requests the page in anonymous mode. bool m_bAnonymousMode = false; if (!String.IsNullOrEmpty(Request.QueryString["AnonymousMode"])) { m_bAnonymousMode = true; } if ((user != null) || (m_bAnonymousMode)) { using (var context = new TableHockeyData.UHSSWEB_DEVEntities()) { try { var querySingleContest = (from c in context.TableHockeyContest where c.ContestId == m_nContestId select c).FirstOrDefault(); //c.OwnerUserId == (Guid)user.ProviderUserKey && var queryEndGameContest = (from c in context.TableHockeyContest where c.EndGameForContestId == m_nContestId select c).FirstOrDefault(); // where c.OwnerUserId == (Guid)user.ProviderUserKey && if (querySingleContest != null) { if (querySingleContest.EndGameForContestId == null) { TableViewModel m_tableViewModel = new TableViewModel(m_nContestId, 100); this.ucContestTable1.InitControl(m_tableViewModel.m_tableRows, false, 100, false); displayRounds(m_nContestId); } else { this.ucContestTable1.Visible = false; this.divExportTable.Visible = false; this.divUcContestRoundPlaceHolder.Visible = false; displayEndGameRounds(querySingleContest.ContestId); } } if (queryEndGameContest != null) { //We have end game rounds, display them all. displayEndGameRounds(queryEndGameContest.ContestId); } } catch (Exception ex) { Response.Redirect("~/pgMain.aspx"); } } } } } else { } }