コード例 #1
0
        public void GenerateSubmissionView(int numSubs)
        {
            SubmissionManagementBO bo = new SubmissionManagementBO();
            UserManagementBO userBO = new UserManagementBO();
            List<SubmissionVO> subList;
            string sortType = Request.QueryString["sort"];

            if (sortType == "top") {
                subList = bo.GetListOfSubmissionsTop(NUMBER_OF_SUBMISSIONS);
            }
            if (sortType == "popular") {
                subList = bo.GetListOfSubmissionsPopular(NUMBER_OF_SUBMISSIONS);
            }
            else {
                subList = bo.GetListOfSubmissionsNew(NUMBER_OF_SUBMISSIONS);
            }

            foreach (SubmissionVO sub in subList) {

                Submission submission = new Submission();
                submission.ID = "submission" + sub.SubmissionID;
                submission.submissionID = sub.SubmissionID;

                subPanel.Controls.Add(submission);
            }
        }
コード例 #2
0
        public void LoadUserDetails()
        {
            UserManagementBO bo = new UserManagementBO();
            UserVO vo = null;

            if (Username != null){
                vo = bo.GetUser(Username);
                UserID = vo.UserID;
            }
            else if (UserID != 0){
                vo = bo.GetUser(UserID);
                Username = vo.Username;
            }

            usernameLabel.Text = "<h1>" + vo.Username + "</h1>";
            ratingLabel.Text = vo.Rating + " collective positive rating";
            joinDateLabel.Text = "Joined on " + vo.RegisterDate.ToLongDateString();

            if (Session["login"] != null) {
                if (Session["login"].ToString() == Username) {
                    passwordChangePanel.Visible = true;
                }
            }

            //Load the content in the first time we visit
            if (!Page.IsPostBack) {
                GenerateRecentContent("submissions");
            }
        }
コード例 #3
0
        protected void GenerateLoggedInText()
        {
            UserManagementBO userBO = new UserManagementBO();
            UserVO userVO = userBO.GetUser(Session["login"].ToString());

            viewProfile.Text = userVO.Username;
            loggedInLabel.Text = " [" + userVO.Rating.ToString() + "] | ";
        }
コード例 #4
0
        public void SubmitVote(int comID, int uID, int vote)
        {
            UserManagementBO userBO = new UserManagementBO();

            CommentDAO dao = new CommentDAO();

            dao.SubmitVote(uID, comID, vote);
            userBO.ChangeRating(uID, vote);
        }
コード例 #5
0
ファイル: Comment.ascx.cs プロジェクト: wbobeirne/Submitter
        protected void LoadCommentDetails()
        {
            CommentManagementBO bo = new CommentManagementBO();
            UserManagementBO userBO = new UserManagementBO();
            CommentVO vo = bo.GetComment(commentID);
            comVO = vo;

            //Give comment space for its depth
            for (int i = 0; i < commentDepth; i++) {
                spacingLabel.Text = spacingLabel.Text + "<td width=\"25px\"></td>";
            }

            commentRating = vo.Rating;
            string username = userBO.GetUser(vo.UserID).Username;

            userLink.Text = username;

            commentInfo.Text = " rated at " +
                                commentRating + " points, posted " +
                                bo.FormatePostTime(vo.PostDate);

            commentContents.Text = "<p>" + vo.CommentContents + "</p>";

            //Choose which controls to display
            if(Session["login"] == null){
                editButton.Visible = false;
                deleteButton.Visible = false;
                replyButton.Visible = false;
            }
            else if (!username.Equals(Session["login"].ToString())) {
                editButton.Visible = false;
                deleteButton.Visible = false;
            }

            //Change vote image based on whether or not it's been voted on
            if(Session["login"] != null){
                int i = bo.CheckIfVoted(commentID, userBO.GetUser(Session["login"].ToString()).UserID);
                if (i == 1) {
                    upArrow.ImageUrl = "~/Images/uparrow_voted.png";
                }
                else if (i == -1) {
                    downArrow.ImageUrl = "~/Images/downarrow_voted.png";
                }
            }
        }
コード例 #6
0
        protected void Login_Submit(object sender, EventArgs e)
        {
            UserManagementBO umbo = new UserManagementBO();

            try {
                if (umbo.CheckIfValidLogin(loginUsername.Text, loginPassword.Text)) {
                    Session["login"] = loginUsername.Text;
                    System.Diagnostics.Trace.WriteLine(Session["login"]);
                    Session.Timeout = 1000;
                    Response.Redirect(Request.Url.ToString());
                }
            }
            catch (Exception exc) {
                loginErrorMessage.Visible = true;

                loginErrorMessage.Text = exc.Message;
            }
        }
コード例 #7
0
        protected void SubmitReply_Click(object sender, EventArgs e)
        {
            CommentManagementBO bo = new CommentManagementBO();
            UserManagementBO userBO = new UserManagementBO();

            try {
                if (replyTextBox.Text == "") {
                    throw new Exception("You must enter text to reply");
                }

                bo.CreateNewComment(userBO.GetUser(Session["login"].ToString()).Username, replyTextBox.Text,
                                    Convert.ToInt32(Request.QueryString["subid"]), Convert.ToInt32(parentCommentID.Text));

                Response.Redirect(Request.Url.ToString());
            }
            catch (Exception exc) {
                errorLabel.Text = exc.Message;
            }
        }
コード例 #8
0
        protected void CreateUser_Submit(object sender, EventArgs e)
        {
            UserManagementBO userBO = new UserManagementBO();

            //Make sure username isn't already taken
            try {
                //For starters, make sure they've entered info in all the fields.
                if (createUserUsername.Text.Equals("") || createUserPassword.Text.Equals("")) {
                    throw new Exception(MISSING_INFO_EXCEPTION);
                }
                //Check if there are any illegal characters.
                if(createUserUsername.Text.IndexOfAny(ILLEGAL_CHAR_ARRAY) >= 0){
                    throw new Exception(ILLEGAL_CHARACTER_EXCEPTION);
                }

                //Check if name taken
                try {
                    userBO.GetUser(createUserUsername.Text);
                    //If it's found in the db, it won't throw the exception, causing it
                    //to hit this exception
                    throw new Exception(USERNAME_ALREADY_TAKEN_EXCEPTION);
                }
                catch (Exception exce) {
                    //If the exception we caught was the username taken, throw it again
                    if(exce.Message.Equals(USERNAME_ALREADY_TAKEN_EXCEPTION)){
                        throw new Exception(USERNAME_ALREADY_TAKEN_EXCEPTION);
                    }
                }

                //Make sure the passwords are the same
                if (createUserPassword.Text != createUserPassword2.Text) {
                    throw new Exception(PASSWORD_MISMATCH_EXCEPTION);
                }

                //And if their info passed all of that, we make their account
                userBO.CreateNewUser(createUserUsername.Text, createUserPassword.Text);
                Session["login"] = createUserUsername.Text;
                Response.Redirect(WebConstants.HOME_PAGE);
            }
            catch (Exception exc) {
                errorMessage.Text = exc.Message;
            }
        }
コード例 #9
0
 protected void SubmitVote(int vote)
 {
     UserManagementBO userBO = new UserManagementBO();
     UserVO userVO;
     if (Session["login"] != null) {
         userVO = userBO.GetUser(Session["login"].ToString());
         if (userBO.CheckIfVoted(submissionID, userVO.UserID) == 0) {
             userBO.SubmitVote(submissionID, userVO.UserID, vote);
             int i = int.Parse(submissionRating.Text);
             i += vote;
             submissionRating.Text = i.ToString();
             if (vote == 1) {
                 upArrow.ImageUrl = "~/Images/uparrow_voted.png";
             }
             else if (vote == -1) {
                 downArrow.ImageUrl = "~/Images/downarrow_voted.png";
             }
         }
     }
 }
コード例 #10
0
        protected void GenerateSubmissionDetails()
        {
            CommentManagementBO comBO = new CommentManagementBO();
            SubmissionManagementBO bo = new SubmissionManagementBO();
            SubmissionVO sub = bo.GetSubmission(submissionID);
            UserManagementBO userBO = new UserManagementBO();
            UserVO vo = userBO.GetUser(sub.UserID);

            submissionRating.Text = sub.Rating.ToString();
            submissionCommentLink.Text = (comBO.GetListOfSubmissionComments(submissionID).Count + " comments");

            Uri url;
            try {
                url = new Uri(sub.Link);
            }
            catch (Exception e) {
                try {
                    url = new Uri("http://" + sub.Link);
                }
                catch (Exception exc) {
                    url = new Uri("http://CouldntParseUrl");
                }
            }

            submissionTitle.Text = "<a href=\"" + url + "\">" + sub.Title + "</a> (" + url.Host.ToString() + ")";

            submissionDetails.Text = bo.FormatePostTime(sub.PostTime);

            userLink.Text = vo.Username;

            //Change arrow based on voting
            if(Session["login"] != null){
                int i = userBO.CheckIfVoted(submissionID, userBO.GetUser(Session["login"].ToString()).UserID);
                if (i == 1) {
                    upArrow.ImageUrl = "~/Images/uparrow_voted.png";
                }
                else if (i == -1) {
                    downArrow.ImageUrl = "~/Images/downarrow_voted.png";
                }
            }
        }
コード例 #11
0
        protected void PasswordChange_Click(object sender, EventArgs e)
        {
            UserManagementBO bo = new UserManagementBO();
            UserVO vo = bo.GetUser(UserID);

            //Look for invalid inputs
            try {
                if (newPassword.Text != newPasswordConfirm.Text) {
                    throw new Exception("Both new password fields must match");
                }

                if (!bo.CheckIfValidLogin(Username, oldPassword.Text)) {
                    throw new Exception("Invalid entry for current password");
                }

                bo.ChangePassword(UserID, newPassword.Text);
                errorLabel.Text = "Password succesfully changed";
            }
            catch (Exception exc) {
                errorLabel.Text = exc.Message;
            }
        }
コード例 #12
0
        public void SubmitVote(int comID, int uID, int vote)
        {
            UserManagementBO userBO = new UserManagementBO();

            CommentDAO dao = new CommentDAO();

            dao.SubmitVote(uID, comID, vote);
            userBO.ChangeRating(uID, vote);
        }
コード例 #13
0
ファイル: Comment.ascx.cs プロジェクト: wbobeirne/Submitter
 protected void SubmitVote(int vote)
 {
     CommentManagementBO comBO = new CommentManagementBO();
     UserManagementBO userBO = new UserManagementBO();
     CommentVO comVO = comBO.GetComment(commentID);
     UserVO userVO;
     if (Session["login"] != null) {
         userVO = userBO.GetUser(Session["login"].ToString());
         if (comBO.CheckIfVoted(commentID, userVO.UserID) == 0) {
             comBO.SubmitVote(commentID, userVO.UserID, vote);
             commentRating += vote;
             Response.Redirect(Request.Url.ToString());
         }
     }
 }