示例#1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool DeleteNews(Notic model)
        {
            bool isSuccess = false;
            if (model != null)
            {
                var conf = new Configuration().Configure();
                ISession session = NHibernateHelper.GetSession();
                //配置NHibernate
                //在Configuration中添加HbmMapping
                conf.AddDeserializedMapping(NHibernateHelper.GetEntityMapping<Notic>(), "NoticXML");
                //配置数据库架构元数据
                SchemaMetadataUpdater.QuoteTableAndColumns(conf);

                //建立SessionFactory
                var factory = conf.BuildSessionFactory();
                //打开Session做持久化数据
                using (session = factory.OpenSession())
                {
                    using (var tx = session.BeginTransaction())
                    {
                        session.Delete(model);
                        tx.Commit();
                        isSuccess = true;
                    }
                }
            }
            return isSuccess;
        }
示例#2
0
        public bool AddUpdateNews(Notic model)
        {
            //ReturnValue resoult;
            //if (!string.IsNullOrEmpty(model.NewsID))
            //{
            //    resoult = dal.SearchNews(model.NewsID);
            //    if (!resoult.ErrorFlag)
            //    {
            //        return resoult;
            //    }
            //    if (resoult.Count > 0)
            //    {
            //        resoult = dal.UpdateNews(model);
            //    }
            //    else
            //    {
            //        resoult = dal.AddNews(model);
            //    }
            //}
            //else
            //{
            //    resoult = dal.AddNews(model);
            //}
            //return resoult;

            IList<Notic> list = OptionNews.GetNewsByID(model.Id);
            if (list.Count > 0)
            {
                model.Status = 1;
                model.CreateTime = list[0].CreateTime;
                model.UpdateTime = DateTime.Now;
                return OptionNews.UpdateNews(model);
            }
            else
            {
                model.Status = 0;
                model.CreateTime = DateTime.Now;
                model.UpdateTime = DateTime.Now;
                if (OptionNews.SaveNews(model) == -1)
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
        }
示例#3
0
 public bool DeleteNewsPhysic(int ID)
 {
     Notic model = new Notic();
     model.Id = ID;
     return OptionNews.DeleteNews(model);
 }