Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Wuyiju.Model.Article obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }

            using (var db = new DataContext())
            {
                var _dao = this.GetDao(db);
                _dao.Insert(obj);
            }
        }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Modify(Wuyiju.Model.Article obj)
        {
            if (obj == null)
            {
                throw new ApplicationException("参数不能为空");
            }
            using (var db = new DataContext())
            {
                var _dao = this.GetDao(db);
                var old  = _dao.Get(obj.Id);

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

                _dao.Update(obj);
            }
        }
Example #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Wuyiju.Model.Article model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update ec_article set ");
            sql.Append(" cate_id = @cate_id , ");
            sql.Append(" title = @title , ");
            sql.Append(" `from` = @from , ");
            sql.Append(" img = @img , ");
            sql.Append(" url = @url , ");
            sql.Append(" brief = @brief , ");
            sql.Append(" info = @info , ");
            sql.Append(" add_time = @add_time , ");
            sql.Append(" sort_order = @sort_order , ");
            sql.Append(" is_hot = @is_hot , ");
            sql.Append(" is_best = @is_best , ");
            sql.Append(" status = @status , ");
            sql.Append(" seo_title = @seo_title , ");
            sql.Append(" seo_keys = @seo_keys , ");
            sql.Append(" seo_desc = @seo_desc , ");
            sql.Append(" filename = @filename , ");
            sql.Append(" click = @click  ");
            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("更新数据无效");
            }
        }
Example #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Insert(Wuyiju.Model.Article model)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into ec_article(");
            sql.Append("cate_id,title,`from`,img,url,brief,info,add_time,sort_order,is_hot,is_best,status,seo_title,seo_keys,seo_desc,filename,click");
            sql.Append(") values (");
            sql.Append("@cate_id,@title,@from,@img,@url,@brief,@info,@add_time,@sort_order,@is_hot,@is_best,@status,@seo_title,@seo_keys,@seo_desc,@filename,@click");
            sql.Append(") ");

            DynamicParameters param = new DynamicParameters();

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

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

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