Exemple #1
0
        public ActionResult AddArticle(TopicDetail Topic)
        {
            if (Topic.Id > 0)
            {
                TopicDetail model = TopicDetailServive.QueryWhere(a => a.Id == Topic.Id).FirstOrDefault();

                if (model != null)
                {
                    model.tdDetail        = Topic.tdDetail;
                    model.tdName          = Topic.tdName;
                    model.tdSectendDetail = Topic.tdSectendDetail;
                    model.tdLogo          = Topic.tdLogo;
                    model.TopicId         = Topic.TopicId;
                    model.tdContent       = Topic.tdContent;
                    model.tdTop           = Topic.tdTop;

                    TopicDetailServive.Edit(model);
                    TopicDetailServive.SaverChanges();
                    return(Content("<script type='text/javascript'>alert('厉害啦!更新成功!');window.location='/admin/Topic/TopicArticle';</script>"));
                }
                else
                {
                    return(Content("<script type='text/javascript'>alert('错啦错啦,没这个数据!');window.location='/admin/Topic/AddArticle';</script>"));
                }
            }
            else
            {
                Topic.tdCreatetime = DateTime.Now;
                TopicDetailServive.Add(Topic);
                TopicDetailServive.SaverChanges();
                return(Content("<script type='text/javascript'>alert('厉害啦!添加成功!');window.location='/admin/Topic/TopicArticle';</script>"));
            }
        }
        public ActionResult ArticleDetail(int id = 0)
        {
            //获取控制器名称
            ViewBag.controllername = RouteData.Values["controller"].ToString().ToLower();
            int pagesize        = 6;
            var blogArticleList = TopicDetailServive.QueryWhere(a => !a.tdIsDelete && a.Id == id).FirstOrDefault();

            if (blogArticleList != null)
            {
                blogArticleList.tdRead++;
                TopicDetailServive.Edit(blogArticleList);
                TopicDetailServive.SaverChanges();
            }

            return(View(blogArticleList));
        }