コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            StringBuilder sb = new StringBuilder();

            try
            {
                int             topicId      = Convert.ToInt32(context.Request.QueryString["topicId"]);
                List <SubTopic> subTopicList = new TopicsLogic().GetSubTopicsByTopicId(new Topic()
                {
                    TopicId = topicId
                });

                if (subTopicList.Count > 0)
                {
                    foreach (SubTopic subTopicObject in subTopicList)
                    {
                        sb.AppendLine(string.Format("<option value='{0}'>{1}</option>", subTopicObject.SubTopicId, subTopicObject.Name));
                    }
                }
                else
                {
                    sb.AppendLine("<option value='-1'>No hay opciones disponibles.</option>");
                }
            }
            catch (Exception ex)
            {
                this.LogError(ex);
                sb.AppendLine("<option value='-1'>Ocurrió un error mientras se cargaban los datos</option>");
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write(sb.ToString());
        }
コード例 #2
0
        public List <Topic> GetTopics()
        {
            List <Topic> topicList = new TopicsLogic().GetTopics();
            Topic        firstItem = new Topic()
            {
                Name = "[Seleccione]", TopicId = -1
            };

            topicList.Insert(0, firstItem);
            return(topicList);
        }
コード例 #3
0
        public string LeftTopicsMenu()
        {
            StringBuilder sb        = new StringBuilder();
            List <Topic>  topicList = new TopicsLogic().GetTopics();

            foreach (Topic topicObject in topicList)
            {
                sb.AppendLine(string.Format("<li class='treeview'><a href='#'><i class='fa fa-fire-extinguisher'></i><span>{0}</span><small class='badge pull-right'>{1}</small><i class='fa fa-angle-left pull-right'></i></a>", topicObject.Name, topicObject.SubTopics.Count));
                sb.AppendLine("<ul class='treeview-menu'>");

                foreach (SubTopic subTopicObject in topicObject.SubTopics)
                {
                    sb.AppendLine(string.Format("<li><a href='{0}pagesPost/PostForSubTopic.aspx?subTopicId={1}'><i class='fa fa-angle-double-right'></i>{2}</a></li>", this.ApplicationRoot, URLParams.EncodeParam(subTopicObject.SubTopicId.ToString()), subTopicObject.Name));
                }

                sb.AppendLine("</ul>");
                sb.AppendLine("</li>");
            }

            return(sb.ToString());
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session[SessionKeys.PostSaveSuccess] != null)
            {
                this.operationResult.InnerHtml       = this.MessageSuccess("Tu post se guardo correctamente.");
                Session[SessionKeys.PostSaveSuccess] = null;
            }
            else if (Session[SessionKeys.PostEditSuccess] != null)
            {
                this.operationResult.InnerHtml       = this.MessageSuccess("Tu post se editó correctamente.");
                Session[SessionKeys.PostEditSuccess] = null;
            }

            //Obtencion de parametro y almacenado en hidden para poder usarlo luego.
            int postId = Convert.ToInt32(this.URLParams.DecodeParam(Page.Request.QueryString["postId"]));

            this.encryptedKey.Value = this.URLParams.EncodeParam(postId.ToString());

            //Seteamos los valores en la pantalla
            Post post = new PostLogic().GetPostById(new Post(postId));

            this.txtTitle.Value         = post.Title;
            this.txtContent.Text        = post.ContentPost;
            this.txtTags.Value          = post.Tags;
            this.cboTopic.SelectedValue = post.Topic.TopicId.ToString();

            List <SubTopic> subTopicList = new TopicsLogic().GetSubTopicsByTopicId(post.Topic);

            foreach (SubTopic subTopicObject in subTopicList)
            {
                ListItem lItem = new ListItem(subTopicObject.Name, subTopicObject.SubTopicId.ToString());
                this.cboSubTopics.Items.Add(lItem);
            }
            this.cboSubTopics.SelectedValue = post.SubTopic.SubTopicId.ToString();

            this.cboLevel.SelectedValue = post.DifficultyLevel.DifficultyLevelId.ToString();
        }