protected void ibtnVote_Click(object sender, ImageClickEventArgs e) { //Get ContestEntryID that is being voted for ImageButton ibtnVote = (ImageButton)sender; int contestEntryId = int.Parse(ibtnVote.CommandArgument); //Load judge object and check if he/she has already voted for this entry ContestJudgeBLL judge = (ContestJudgeBLL)Session["ContestJudge"]; if (!judge.VoteContestEntryID.Equals(contestEntryId)) { //If judge has voted previously, then subtract his/her vote from previous entry if (judge.VoteContestEntryID != null && judge.VoteContestEntryID > 0) { SubtractVote(judge.VoteContestEntryID); } //Add judge's new vote to entry AddVote(contestEntryId); //Update judge's vote judge.VoteContestEntryID = contestEntryId; judge.Update(); Session["ContestJudge"] = judge; } ClientScriptManager cs = Page.ClientScript; cs.RegisterStartupScript(this.GetType(), "confirmation", "$(function () {$('#notificationSettingsModal').modal({ show: true, keyboard: false, backdrop: 'static' });});", true); }
protected void btnLogin_Click(object sender, EventArgs e) { //Validate voting deadline if (ValidateDeadlineDate()) { //Validate email and password inputs if (!validateInputs()) { return; } //Create ContestJudge object from username and password int contestId = int.Parse(ConfigurationManager.AppSettings["ContestID"]); ContestJudgeBLL judge = new ContestJudgeBLL(tbxEmail.Text, tbxPassword.Text, contestId); if (judge.ContestJudgeID > 0) { Session["ContestJudge"] = judge; //saveCookie(); if (Request["from"] != null) { Response.RedirectPermanent(Request["from"]); } Response.RedirectPermanent("change-vote.aspx"); } else { errorMessage.Attributes.Add("style", "display:block"); errorMessage.InnerHtml = "The username or password you entered is incorrect. Please try again."; } } }
private void LoadPage() { ContestBLL contest = new ContestBLL(int.Parse(ConfigurationManager.AppSettings["ContestID"])); //Allow to vote only if deadline has not passed if (ValidateDeadlineDate(contest.VotingDeadline)) { ContestJudgeBLL judge = (ContestJudgeBLL)Session["ContestJudge"]; int contestEntryId = judge.VoteContestEntryID != null ? (int)judge.VoteContestEntryID : 0; repContestEntries.DataSource = ContestEntryBLL.List(int.Parse(ConfigurationManager.AppSettings["ContestID"]), contestEntryId); repContestEntries.DataBind(); LoadNotificationSettingsModal(contest.VotingDeadline, judge.FirstName); } else { //Load message notifying of voting deadline primaryHeader.InnerHtml = " "; secondaryHeader.Attributes.Add("style", "display:none;"); infoMessage.InnerHtml = "Thank you for signing up as a judge. Unfortunately, the voting deadline for this contest has passed. Look out for future contests you can participate in. Thanks again!"; infoMessage.Attributes.Add("style", "display:block"); //Kill user session and delete cookie to prevent user from voting from another page KillSession(); } }
protected void ibtnVote_Click(object sender, ImageClickEventArgs e) { //Get ContestEntryID that is being voted for ImageButton ibtnVote = (ImageButton)sender; int contestEntryId = int.Parse(ibtnVote.CommandArgument); //Load judge object and check if he/she has already voted for this entry ContestJudgeBLL judge = (ContestJudgeBLL)Session["ContestJudge"]; if (!judge.VoteContestEntryID.Equals(contestEntryId)) { //If judge has voted previously, then subtract his/her vote from previous entry if (judge.VoteContestEntryID != null && judge.VoteContestEntryID > 0) { SubtractVote(judge.VoteContestEntryID); } //Add judge's new vote to entry AddVote(contestEntryId); //Update judge's vote judge.VoteContestEntryID = contestEntryId; judge.Update(); Session["ContestJudge"] = judge; } //Reload repeater LoadPage(); }
private void LoadPage() { ContestJudgeBLL judge = (ContestJudgeBLL)Session["ContestJudge"]; int contestEntryId = judge.VoteContestEntryID != null ? (int)judge.VoteContestEntryID : 0; repContestEntries.DataSource = ContestEntryBLL.List(int.Parse(ConfigurationManager.AppSettings["ContestID"]), contestEntryId); repContestEntries.DataBind(); }
private void SaveComment(ContestJudgeBLL judge) { ContestCommentBLL comment = new ContestCommentBLL(); comment.Comment = tbxJudgeComment.Text; comment.ContestEntryID = (int)judge.VoteContestEntryID; comment.ContestJudgeID = judge.ContestJudgeID; comment.Save(); }
protected void btnSaveComment_Click(object sender, EventArgs e) { ContestJudgeBLL judge = (ContestJudgeBLL)Session["ContestJudge"]; //Save commment SaveComment(judge); //Display coupon ShowCoupon(); //Email coupon //EmailCoupon(judge.Email); }
protected void btnContinue_Click(object sender, EventArgs e) { if (Session["ContestJudge"] != null) { ContestJudgeBLL judge = (ContestJudgeBLL)Session["ContestJudge"]; SetNotificationSettings(judge.Email, judge.ContestJudgeID); } //Show thank you message Response.RedirectPermanent("thank-you.aspx"); }
protected string SetVoteButton(int contestEntryId) { if (Session["ContestJudge"] != null) { ContestJudgeBLL judge = (ContestJudgeBLL)Session["ContestJudge"]; if (judge.VoteContestEntryID.Equals(contestEntryId)) { return("~/assets/img/checked.png"); } } return("~/assets/img/unchecked.png"); }
private void SetNotificationSettings() { if (ContestJudgeBLL.EmailUnsubscribe(tbxEmail.Text, GetContestJudgeID(), GetSubscriptionValue())) { unsubscribeBox.InnerHtml = "Thank you. Your subscription has been updated."; SendEmailNotification(); } else { errorMessage.InnerHtml = "This email is not registered in our database. Please try again."; errorMessage.Attributes.Add("style", "display:block"); } }
protected string SetSelectedClass(int contestEntryId) { if (Session["ContestJudge"] != null) { ContestJudgeBLL judge = (ContestJudgeBLL)Session["ContestJudge"]; if (judge.VoteContestEntryID.Equals(contestEntryId)) { return("entry generic-container selected-entry"); } } return("entry generic-container"); }
protected void SetVoteButton(int contestEntryId) { ibtnVote.ImageUrl = "~/assets/img/unchecked.png"; ibtnVote.CommandArgument = contestEntryId.ToString(); if (Session["ContestJudge"] != null) { ContestJudgeBLL judge = (ContestJudgeBLL)Session["ContestJudge"]; if (judge.VoteContestEntryID.Equals(contestEntryId)) { ibtnVote.ImageUrl = "~/assets/img/checked.png"; } } }
private void LoadUserFromCookie() { if (Request.Cookies["userInfoHTVC"] != null) { //Load user cookie info string email = Server.HtmlEncode(Request.Cookies["userInfoHTVC"]["username"]); string password = Server.HtmlEncode(Request.Cookies["userInfoHTVC"]["password"]); int contestId = int.Parse(ConfigurationManager.AppSettings["ContestID"]); ContestJudgeBLL judge = new ContestJudgeBLL(email, password, contestId); if (judge.ContestID > 0) { Session["ContestJudge"] = judge; Response.RedirectPermanent("list-entries.aspx"); } } }
private void LoadPage() { //If judge is logged in, set the judge's selected entry //as the contestEntryId variable. int contestEntryId = 0; if (LoadUserFromCookie()) { ContestJudgeBLL judge = (ContestJudgeBLL)Session["ContestJudge"]; contestEntryId = (int)judge.VoteContestEntryID; //If user is logged in, hide button that redirect to register and login page voteButtons.Attributes.Add("style", "display:none"); } repContestEntries.DataSource = ContestEntryBLL.List(int.Parse(ConfigurationManager.AppSettings["ContestID"]), contestEntryId); repContestEntries.DataBind(); }
private bool LoadUserFromCookie() { if (Request.Cookies["userInfoHTVC"] != null) { //Load user cookie info string email = Server.HtmlEncode(Request.Cookies["userInfoHTVC"]["username"]); string password = Server.HtmlEncode(Request.Cookies["userInfoHTVC"]["password"]); int contestId = int.Parse(ConfigurationManager.AppSettings["ContestID"]); ContestJudgeBLL judge = new ContestJudgeBLL(email, password, contestId); if (judge.ContestJudgeID > 0) { Session["ContestJudge"] = judge; return(true); } } return(false); }
protected void btnSaveComment_Click(object sender, EventArgs e) { if (Session["ContestJudge"] != null && Request["id"] != null && tbxJudgeComment.Text != string.Empty) { int contestEntryId = 0; int.TryParse(Request["id"], out contestEntryId); if (contestEntryId > 0) { ContestJudgeBLL judge = (ContestJudgeBLL)Session["ContestJudge"]; ContestCommentBLL comment = new ContestCommentBLL(); comment.Comment = tbxJudgeComment.Text; comment.ContestEntryID = contestEntryId; comment.ContestJudgeID = judge.ContestJudgeID; comment.Save(); tbxJudgeComment.Text = string.Empty; LoadPage(); } } }
protected void btnSignUp_Click(object sender, EventArgs e) { int contestId = int.Parse(ConfigurationManager.AppSettings["ContestID"]); if (!EmailExistsInDatabase(contestId)) { if (!ScreenNameExistsInDatabase(contestId)) { //Save judge to db ContestJudgeBLL judge = new ContestJudgeBLL(); judge.ContestID = contestId; judge.CustomerID = null; judge.FirstName = tbxFirstName.Text; judge.LastName = tbxLastName.Text; judge.Email = tbxEmail.Text; judge.Zipcode = tbxZipcode.Text; judge.ScreenName = tbxScreenName.Text; judge.Password = tbxPassword.Text; judge = judge.Save(); //Save in session and cookie Session["ContestJudge"] = judge; saveCookie(); //Redirect to voting page Response.RedirectPermanent("view-entries.aspx"); } else { errorMessage.Attributes.Add("style", "display:block"); errorMessage.InnerHtml = "This screen name is already registered. Please enter another one."; } } else { errorMessage.Attributes.Add("style", "display:block"); errorMessage.InnerHtml = "This email is already registered. Please enter another one."; } }
private bool EmailExistsInDatabase(int contestId) { return(ContestJudgeBLL.EmailExists(tbxEmail.Text, contestId)); }
private void SetNotificationSettings(string email, int contestJudgeId) { ContestJudgeBLL.EmailUnsubscribe(email, contestJudgeId, GetSubscriptionValue()); }
private bool ScreenNameExistsInDatabase(int contestId) { return(ContestJudgeBLL.ScreenNameExists(tbxScreenName.Text, contestId)); }