Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Wuyiju.Model.ProductComments model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update ProductComments set ");

            sql.Append(" product_id = @product_id , ");
            sql.Append(" user_id = @user_id , ");
            sql.Append(" user_name = @user_name , ");
            sql.Append(" content = @content , ");
            sql.Append(" useful = @useful , ");
            sql.Append(" status = @status , ");
            sql.Append(" top = @top , ");
            sql.Append(" star01 = @star01 , ");
            sql.Append(" star02 = @star02 , ");
            sql.Append(" star03 = @star03 , ");
            sql.Append(" reply = @reply , ");
            sql.Append(" add_time = @add_time  ");
            sql.Append(" where id=@id ");

            DynamicParameters param = new DynamicParameters();

            if (model != null)
            {
                param.AddDynamicParams(model);
            }

            var rows = db.Execute(sql, param);

            if (rows < 1)
            {
                throw new ApplicationException("更新数据无效");
            }
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Wuyiju.Model.ProductComments obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            dao.Insert(obj);
        }
Exemple #3
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Remove(Wuyiju.Model.ProductComments obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            var old = dao.Get(obj.Id);

            if (old == null)
            {
                throw new ApplicationException("非法操作记录不存在");
            }

            dao.Delete(obj.Id);
        }
Exemple #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Insert(Wuyiju.Model.ProductComments model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into ec_product_comments(");
            sql.Append("product_id,user_id,user_name,content,useful,status,top,star01,star02,star03,reply,add_time");
            sql.Append(") values (");
            sql.Append("@product_id,@user_id,@user_name,@content,@useful,@status,@top,@star01,@star02,@star03,@reply,@add_time");
            sql.Append(") ");

            DynamicParameters param = new DynamicParameters();

            if (model != null)
            {
                param.AddDynamicParams(model);
            }

            var rows = db.Execute(sql, param);

            if (rows < 1)
            {
                throw new ApplicationException("插入数据无效");
            }
        }