Exemplo n.º 1
0
 protected void btnAddRelatedPost_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(DropDownList1.SelectedValue))
     {
         Guid          postID        = Guid.Parse(Request.QueryString.Get("postid"));
         Guid          relatedPostID = Guid.Parse(DropDownList1.SelectedValue);
         DTO.Post      post          = Post_BUS.GetEntityByID <DTO.Post>(postID);
         List <string> lstPost       = (List <string>)Session["RelatedPosts"];
         bool          isAdd         = true;
         if (post.RelatedPosts != null)
         {
             if (lstPost.Contains(relatedPostID.ToString().ToLower()) || post.PostID.Equals(relatedPostID))
             {
                 isAdd = false;
             }
         }
         if (!isAdd)
         {
             Response.Write("<script>" +
                            "sessionStorage['ReloadImg'] = true;" +
                            "alert('Bài  viết liên quan muốn thêm đã có trong danh sách bài viết liên quan hoặc trùng với bài viết hiện tại'); </script>");
         }
         else
         {
             lstPost.Add(relatedPostID.ToString());
             string str = string.Join(";", lstPost.ToArray());
             SetSessionForRelatedPost(str);
             BindRelatedPosts(GetRelatedPosts(str));
             BindDropDownList(new Post_BUS().GetAllPost(post.PostID, str));
             Response.Write("<script>sessionStorage['ReloadImg'] = 'true';</script>");
         }
     }
 }
Exemplo n.º 2
0
        protected void btnDeleteRelatedPost_Click(object sender, EventArgs e)
        {
            // xóa bài viết liên quan
            List <string> lstPost       = (List <string>)Session["RelatedPosts"];
            Guid          relatedPostID = Guid.Parse(sender.GetType().GetProperty("CommandArgument").GetValue(sender).ToString());
            Guid          postID        = Guid.Parse(Request.QueryString.Get("postid"));

            DTO.Post post = Post_BUS.GetEntityByID <DTO.Post>(postID);
            lstPost.Remove(relatedPostID.ToString());
            string str = string.Join(";", lstPost.ToArray());

            SetSessionForRelatedPost(str);
            BindRelatedPosts(GetRelatedPosts(str));
            BindDropDownList(new Post_BUS().GetAllPost(post.PostID, str));
        }
Exemplo n.º 3
0
        private void BindData()
        {
            Guid postID = Guid.Parse(Request.QueryString.Get("postid"));

            DTO.Post post = Post_BUS.GetEntityByID <DTO.Post>(postID);
            txtTenBaiViet.Text  = post.PostName.Trim();
            txtNgayTao.Text     = post.CreatedDate.ToString("HH:mm:ss dd/MM/yyyy");
            imgProduct.ImageUrl = "../../Img/images/" + (string.IsNullOrEmpty(HttpUtility.UrlDecode(post.Image)) ? "noimg.png" : HttpUtility.UrlDecode(post.Image));
            txtImgURL.Text      = (string.IsNullOrEmpty(HttpUtility.UrlDecode(post.Image)) ? "" : "/Admin/Img/images/" + HttpUtility.UrlDecode(post.Image));
            txtSummary.Text     = string.IsNullOrEmpty(post.Summary) ? "" : HttpUtility.UrlDecode(post.Summary.Trim());
            txtDetail.Text      = string.IsNullOrEmpty(post.Content) ? "" : HttpUtility.UrlDecode(post.Content.Trim());
            BindRelatedPosts(GetRelatedPosts(post.RelatedPosts));
            lblEmpty.Text = GetRelatedPosts(post.RelatedPosts).Count == 0 ? "Không có bài viết liên quan" : "";
            BindDropDownList(new Post_BUS().GetAllPost(post.PostID, post.RelatedPosts));
            SetSessionForRelatedPost(post.RelatedPosts);
            Response.Write(string.Format("<script>sessionStorage['ImageURL'] = '{0}' </script>", string.IsNullOrEmpty(HttpUtility.UrlDecode(post.Image)) ? "noimg.png" : HttpUtility.UrlDecode(post.Image)));
        }