Exemplo n.º 1
0
        public ActionResult Add(Topic Topic)
        {
            if (Topic.Id > 0)
            {
                Topic model = TopicServive.QueryWhere(a => a.Id == Topic.Id).FirstOrDefault();

                if (model != null)
                {
                    model.tDetail        = Topic.tDetail;
                    model.tName          = Topic.tName;
                    model.tSectendDetail = Topic.tSectendDetail;
                    model.tLogo          = Topic.tLogo;

                    TopicServive.Edit(model);
                    TopicServive.SaverChanges();
                    return(Content("<script type='text/javascript'>alert('厉害啦!更新成功!');window.location='/admin/Topic/Index';</script>"));
                }
                else
                {
                    return(Content("<script type='text/javascript'>alert('错啦错啦,没这个数据!');window.location='/admin/Topic/Add';</script>"));
                }
            }
            else
            {
                Topic.tCreatetime = DateTime.Now;
                Topic.tAuthor     = LoginUser.uRealName;
                TopicServive.Add(Topic);
                TopicServive.SaverChanges();
                return(Content("<script type='text/javascript'>alert('厉害啦!添加成功!');window.location='/admin/Topic/Index';</script>"));
            }
        }