Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            string           customerID = context.Request.QueryString["customerID"];
            string           articleID  = context.Request.QueryString["articleID"];
            ArticleLikeModel model      = new ArticleLikeModel();

            model.ArticleID  = Guid.Parse(articleID);
            model.CustomerID = Guid.Parse(customerID);
            bool bl = service.CreateArticleLike(model);

            context.Response.Write(bl);
        }
Example #2
0
        /// <summary>
        /// 新增点赞
        /// </summary>
        public bool CreateArticleLike(ArticleLikeModel model)
        {
            int rows = 0;

            //判断重复点赞
            if (DBHelper.GetScaler("SELECT COUNT(1) FROM dbo.ArticleLike WHERE ArticleID='" + model.ArticleID + "' AND CustomerID='" + model.CustomerID + "'") > 0)
            {
                return(false);
            }
            else
            {
                try
                {
                    StringBuilder strSql = new StringBuilder();
                    strSql.Append("insert into ArticleLike(");
                    strSql.Append("LikeID,ArticleID,CustomerID,CreateDate)");
                    strSql.Append(" values (");
                    strSql.Append("@LikeID,@ArticleID,@CustomerID,@CreateDate)");
                    SqlParameter[] parameters =
                    {
                        new SqlParameter("@LikeID",     SqlDbType.UniqueIdentifier, 16),
                        new SqlParameter("@ArticleID",  SqlDbType.UniqueIdentifier, 16),
                        new SqlParameter("@CustomerID", SqlDbType.UniqueIdentifier, 16),
                        new SqlParameter("@CreateDate", SqlDbType.DateTime)
                    };
                    parameters[0].Value = Guid.NewGuid();
                    parameters[1].Value = model.ArticleID;
                    parameters[2].Value = model.CustomerID;
                    parameters[3].Value = DateTime.Now;

                    rows = DBHelper.ExecuteCommand(strSql.ToString(), parameters);
                }
                catch (Exception w5)
                {
                    Tool.WritrErro(w5);
                }
                if (rows > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }