Example #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string queryst= Request.QueryString["id"];
            if (queryst != null)
            {
                PostManager anPostManager=new PostManager();
                Post anPost=new Post();
                anPost.PostId = Convert.ToInt32(queryst);
                anPost.PostTitle = titleTexbox.Text;
                anPost.PostDescreption = edit.InnerText;
                if (DropDownList1.SelectedValue == "true")
                {
                    anPost.PostIsPublished = true;
                }
                else
                {
                    anPost.PostIsPublished = false;
                }

                Model.User anUser = (User)Session["aUser"];

                anPost.userId = anUser.UserId;

                if (anPost.PostTitle != "" && anPost.PostDescreption != "")
                {
                    if (anPostManager.UpdatePostById(anPost) > 0)
                    {
                        Response.Redirect("UserControlPanel.aspx");

                    }
                }
                else
                {
                    msg.InnerText = "Please Enter Both title and Description";
                }

            }
            else
            {
                PostManager anPostManager=new PostManager();
                Post anPost=new Post();
                anPost.PostTitle = titleTexbox.Text;
                anPost.PostDescreption = edit.Value;
                if (DropDownList1.SelectedValue == "true")
                {
                    anPost.PostIsPublished = true;
                }
                else
                {
                    anPost.PostIsPublished = false;
                }

                Model.User anUser = (User)Session["aUser"];

                anPost.userId = anUser.UserId;
              if (anPost.PostTitle != "" && anPost.PostDescreption != "")
                {
                if (anPostManager.InsertPost(anPost) > 0)
                {
                    Response.Redirect("UserControlPanel.aspx");

                }
                }
              else
              {
              msg.InnerText = "Please Enter Both title and Description";
              }

            }
        }