Example #1
0
        private void SendComment()
        {
            string strNewsCode = Request.Form["NewsCode"];
            string Name        = Request.Form["Name"];
            string Email       = Request.Form["Email"];
            string Comment     = Request.Form["Comment"];

            int HCSectionCode = 1;
            int ItemCode;

            Int32.TryParse(strNewsCode, out ItemCode);

            BOLComments CommentsBOL = new BOLComments();
            bool        Result      = CommentsBOL.SaveComment(HCSectionCode, ItemCode, Name, Email, Comment);

            op_result _op_result = new op_result();

            if (Result)
            {
                _op_result.result = "نظر با موفقیت ثبت شد";
                //msgBox.Text = "نظر شما با موفقیت دریافت شد";
            }
            else
            {
                _op_result.result = "متاسفانه خطایی در ثبت نظر رخ داده است";
            }

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string json = serializer.Serialize((object)_op_result);

            Response.Write(json);
            Response.End();
        }
Example #2
0
        private void SendLike()
        {
            string NewsLikes = "";

            if (Request.Cookies["AceNewsDB"] != null)
            {
                NewsLikes = Request.Cookies["AceNewsDB"]["NewsLikes"];
            }


            op_result _op_result = new op_result();

            int    HCSectionCode = 1;
            int    ItemCode;
            string strNewsCode = Request.Form["NewsCode"];

            Int32.TryParse(strNewsCode, out ItemCode);

            if (NewsLikes == null)
            {
                NewsLikes = "";
            }

            string[] NewsLikesArray = NewsLikes.Split(',');
            if (!NewsLikesArray.Contains(strNewsCode))
            {
                if (ItemCode != 0)
                {
                    BOLLikes LikesBOL = new BOLLikes();
                    bool     Result   = LikesBOL.InsertLike(HCSectionCode, ItemCode);
                    if (Result)
                    {
                        _op_result.result = "OK";
                        if (NewsLikes == "")
                        {
                            NewsLikes = strNewsCode;
                        }
                        else
                        {
                            NewsLikes = NewsLikes + "," + strNewsCode;
                        }
                    }
                    else
                    {
                        _op_result.result = "NOK";
                    }
                }
                else
                {
                    _op_result.result = "NOK";
                }
            }
            else
            {
                _op_result.result = "NOK";
            }



            Response.Cookies["AceNewsDB"].Expires      = DateTime.Now.AddDays(30);
            Response.Cookies["AceNewsDB"]["NewsLikes"] = NewsLikes;

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string json = serializer.Serialize((object)_op_result);

            Response.Write(json);
            Response.End();
        }