コード例 #1
0
ファイル: Home.aspx.cs プロジェクト: wbobeirne/Submitter
        protected void GenerateSubmissionView(int numSubs)
        {
            SubmissionManagementBO bo = new SubmissionManagementBO();
            List<SubmissionVO> subList;
            string sortType = Request.QueryString["sort"];

            if (sortType == "top") {
                subList = bo.GetListOfSubmissionsTop(NUMBER_OF_SUBMISSIONS);
                submissionViewTitle.Text = "<h1>See what's on top</h1>";
            }
            else if (sortType == "popular") {
                subList = bo.GetListOfSubmissionsPopular(NUMBER_OF_SUBMISSIONS);
                submissionViewTitle.Text = "<h1>See what's popular</h1>";
            }
            else {
                submissionViewTitle.Text = "<h1>See what's new</h1>";
                subList = bo.GetListOfSubmissionsNew(NUMBER_OF_SUBMISSIONS);
            }

            foreach (SubmissionVO sub in subList) {

                Submission submission = (Submission)Page.LoadControl("~/Controls/Submission.ascx");
                submission.ID = "submission" + sub.SubmissionID;
                submission.submissionID = sub.SubmissionID;

                submissionsPanel.Controls.Add(submission);
            }
        }
コード例 #2
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);
            }
        }
コード例 #3
0
        public void GenerateSubmissionViewForUser(int userID)
        {
            SubmissionManagementBO bo = new SubmissionManagementBO();
            List<SubmissionVO> subList = bo.GetListOfSubmissionsByUser(5, userID);

            foreach (SubmissionVO sub in subList) {
                Submission submission = (Submission)Page.LoadControl("~/Controls/Submission.ascx");
                submission.ID = "submission" + sub.SubmissionID;
                submission.submissionID = sub.SubmissionID;

                subPanel.Controls.Add(submission);
            }
        }
コード例 #4
0
        protected void CreateSubmission_Submit(object sender, EventArgs e)
        {
            SubmissionManagementBO bo = new SubmissionManagementBO();

            try {
                if (createSubmissionTitle.Text.Equals("")) {
                    throw new Exception("You must enter a title");
                }
                if (createSubmissionLink.Text.Equals("")) {
                    throw new Exception("You must enter a link");
                }
                bo.CreateNewSubmission(createSubmissionTitle.Text, createSubmissionLink.Text, Session["login"].ToString());
                Response.Redirect(WebConstants.HOME_PAGE + "?sort=new");
            }
            catch (Exception exc) {
                submissionError.Text = exc.Message;
            }
        }
コード例 #5
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";
                }
            }
        }
コード例 #6
0
        private void GenerateRecentContent(string type)
        {
            if (type == "submissions") {

                //We need to add a table for submissions, since they are just trs and tds
                Literal lit1 = new Literal();
                lit1.Text = "<table width=\"100%\">";
                recentContentPanel.Controls.Add(lit1);

                SubmissionManagementBO bo = new SubmissionManagementBO();
                List<SubmissionVO> subList = bo.GetListOfSubmissionsByUser(5, UserID);

                foreach (SubmissionVO sub in subList) {

                    Submission submission = (Submission)Page.LoadControl("~/Controls/Submission.ascx");
                    submission.ID = "submission" + sub.SubmissionID;
                    submission.submissionID = sub.SubmissionID;

                    recentContentPanel.Controls.Add(submission);
                }

                //We need to close the table tag we added
                Literal lit2 = new Literal();
                lit2.Text = "</table>";
                recentContentPanel.Controls.Add(lit2);
            }
            else if(type == "comments") {

                CommentManagementBO bo = new CommentManagementBO();
                List<CommentVO> comList = bo.GetListOfCommentsByUserID(5, UserID);

                foreach (CommentVO comment in comList) {

                    Comment com = (Comment)Page.LoadControl("~/Controls/Comment.ascx");
                    com.ID = "comment" + comment.CommentID;
                    com.commentDepth = 0;
                    com.commentID = comment.CommentID;

                    recentContentPanel.Controls.Add(com);
                }
            }
        }