示例#1
0
 protected static MySqlParameter[] GetParameters(NewsdescInfo item)
 {
     return(new MySqlParameter[] {
         GetParameter("?news_id", MySqlDbType.UInt32, 10, item.News_id),
         GetParameter("?content", MySqlDbType.Text, -1, item.Content)
     });
 }
示例#2
0
 private static void RemoveCache(NewsdescInfo item)
 {
     if (item == null)
     {
         return;
     }
     RedisHelper.Remove(string.Concat("pifa_BLL_Newsdesc_", item.News_id));
 }
示例#3
0
 public static pifa.DAL.Newsdesc.SqlUpdateBuild UpdateDiy(NewsdescInfo item, uint News_id)
 {
     if (itemCacheTimeout > 0)
     {
         RemoveCache(item != null ? item : GetItem(News_id));
     }
     return(new pifa.DAL.Newsdesc.SqlUpdateBuild(item, News_id));
 }
示例#4
0
 public static int Update(NewsdescInfo item)
 {
     if (itemCacheTimeout > 0)
     {
         RemoveCache(item);
     }
     return(dal.Update(item));
 }
示例#5
0
        public APIReturn _Add([FromForm] uint?News_id, [FromForm] string Content)
        {
            NewsdescInfo item = new NewsdescInfo();

            item.News_id = News_id;
            item.Content = Content;
            item         = Newsdesc.Insert(item);
            return(APIReturn.成功.SetData("item", item.ToBson()));
        }
示例#6
0
 public static NewsdescInfo Insert(NewsdescInfo item)
 {
     item = dal.Insert(item);
     if (itemCacheTimeout > 0)
     {
         RemoveCache(item);
     }
     return(item);
 }
示例#7
0
        public ActionResult Edit([FromQuery] uint News_id)
        {
            NewsdescInfo item = Newsdesc.GetItem(News_id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            ViewBag.item = item;
            return(View());
        }
示例#8
0
        public object GetItem(IDataReader dr, ref int index)
        {
            NewsdescInfo item = new NewsdescInfo();

            if (!dr.IsDBNull(++index))
            {
                item.News_id = (uint?)dr.GetInt32(index);
            }
            if (!dr.IsDBNull(++index))
            {
                item.Content = dr.GetString(index);
            }
            return(item);
        }
示例#9
0
        public APIReturn _Edit([FromQuery] uint News_id, [FromForm] string Content)
        {
            NewsdescInfo item = Newsdesc.GetItem(News_id);

            if (item == null)
            {
                return(APIReturn.记录不存在_或者没有权限);
            }
            item.Content = Content;
            int affrows = Newsdesc.Update(item);

            if (affrows > 0)
            {
                return(APIReturn.成功.SetMessage($"更新成功,影响行数:{affrows}"));
            }
            return(APIReturn.失败);
        }
示例#10
0
        public static NewsdescInfo GetItem(uint News_id)
        {
            if (itemCacheTimeout <= 0)
            {
                return(Select.WhereNews_id(News_id).ToOne());
            }
            string key   = string.Concat("pifa_BLL_Newsdesc_", News_id);
            string value = RedisHelper.Get(key);

            if (!string.IsNullOrEmpty(value))
            {
                try { return(NewsdescInfo.Parse(value)); } catch { }
            }
            NewsdescInfo item = Select.WhereNews_id(News_id).ToOne();

            if (item == null)
            {
                return(null);
            }
            RedisHelper.Set(key, item.Stringify(), itemCacheTimeout);
            return(item);
        }
示例#11
0
 public SqlUpdateBuild(NewsdescInfo item, uint News_id)
 {
     _item  = item;
     _where = SqlHelper.Addslashes("`news_id` = {0}", News_id);
 }
示例#12
0
 public int Update(NewsdescInfo item)
 {
     return(new SqlUpdateBuild(null, item.News_id.Value)
            .SetContent(item.Content).ExecuteNonQuery());
 }
示例#13
0
 public NewsdescInfo Insert(NewsdescInfo item)
 {
     SqlHelper.ExecuteNonQuery(TSQL.Insert, GetParameters(item));
     return(item);
 }