Пример #1
0
 public Ba_News GetSingleById(int Ns_ID)
 {
     var model = session.Get<Ba_News>(Ns_ID);
     if (model == null)
         model = new Ba_News();
     return model;
 }
Пример #2
0
        public string Submit(NewsOperate_Form form)
        {
            string result = string.Empty;
            News dal = new News();
            var model = dal.GetSingleById(form.news_id);
            if (model == null)
                model = new Ba_News();
            model.Ns_Title = form.news_title;
            model.Ns_Type = form.news_type;
            model.Ns_Content = form.news_description;
            model.Ns_ImagePath = form.news_imageurl;
            model.Ns_PostTime = DateTime.Now;
            model.Ns_State = true;
            try
            {
                dal.Save(model);
                result = "1";
            }
            catch (System.Exception ex)
            {
                result = ex.ToString();
            }

            return result;
        }
Пример #3
0
        //
        // GET: /SuperAdmin/NewsOperate/
        public ActionResult Index(int? id)
        {
            ViewBag.jsInit = Public.SuperAdminCommon.JSInit("NewsManage", "NewsOperate");

            var newstype = new NewsType();
            ViewBag.newstype = newstype.GetList();

            var model = new Ba_News();
            if (id != null)
            {
                News dal = new News();
                model = dal.GetSingleById((int)id);
            }
            if (model == null)
                model = new Ba_News();

            ViewBag.model = model;

            if (model.Ns_ID.Equals(0))
                ViewBag.Title = "新增最新情報";
            else
                ViewBag.Title = "更新最新情報";

            return View();
        }
Пример #4
0
 public void Update(Ba_News news)
 {
     session.Update(news);
     session.Flush();
 }
Пример #5
0
 public void SaveOrUpdate(Ba_News news)
 {
     session.SaveOrUpdate(news);
     session.Flush();
 }
Пример #6
0
 public void Add(Ba_News news)
 {
     session.Save(news);
     session.Flush();
 }