public static int UpdateNews_Bjh(DtoNews model) { try { var news = new T_News_Bjh() { Id = model.Id, CurReadTimes = model.CurReadTimes, LastDealTime = DateTime.Now, LastReadTimes = model.LastReadTimes, IsHot = model.IsHot, IsDeal = 1, TotalComments = model.TotalComments, NewsHotClass = model.NewsHotClass, IntervalMinutes = model.IntervalMinutes, GroupId = model.GroupId, }; return(Sql.Update(news, "Id={0}".Formats(model.Id))); } catch (Exception ex) { Log.Error(ex.Message + ex.StackTrace); } return(1); }
/// <summary> /// 添加一条新闻 /// </summary> /// <param name="model">新闻实体</param> /// <returns></returns> public static int Insert_News_Bjh(DtoNews model) { try { if (model.Author == null) { model.Author = ""; } if (model.Contents == null) { model.Contents = ""; } if (model.FromSiteName == null) { model.FromSiteName = ""; } if (model.PubTime == null) { model.PubTime = DateTime.Now; } if (model.FromUrl == null) { model.FromUrl = ""; } if (model.LogoOriginalUrl == null) { model.LogoOriginalUrl = ""; } if (model.LogoUrl == null) { model.LogoUrl = ""; } if (model.Title == null) { model.Title = ""; } ////非图片的,且内容小于100的不入库 //if (model.NewsTypeId != NewsTypeEnum.图片 && model.Contents.Length < 100) //{ // return -1; //} //if(string.IsNullOrWhiteSpace(model.Title.Trim())) //{ // return -1; //} var item = new T_News_Bjh() { Author = model.Author, Contents = model.Contents, //CreateTime = model.CreateTime, FromSiteName = model.FromSiteName, FromUrl = model.FromUrl, IsShow = 0, LogoOriginalUrl = model.LogoOriginalUrl, LogoUrl = model.LogoUrl, NewsTypeId = (int)model.NewsTypeId, PubTime = model.PubTime, Title = model.Title, AuthorId = model.AuthorId, TotalComments = model.TotalComments, Tags = model.Tags, NewsHotClass = model.NewsHotClass, LastReadTimes = model.LastReadTimes, LastDealTime = DateTime.Now, IsHot = model.IsHot, IsDeal = model.IsDeal, IntervalMinutes = model.IntervalMinutes, CurReadTimes = model.CurReadTimes, CreateTime = DateTime.Now, GroupId = model.GroupId, }; var id = Sql.InsertId <T_News_Bjh>(item); return(id); } catch (Exception ex) { Log.Error(ex.Message); //Log.Error(ex.Message + ex.StackTrace); return(-1); } }