Esempio 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>"));
            }
        }
Esempio n. 2
0
        public async Task <MessageModel <string> > Post([FromBody] Topic request)
        {
            var data = new MessageModel <string>();

            var id = await _topicServices.Add(request);

            data.success = id > 0;

            if (data.success)
            {
                data.response = id.ObjToString();
                data.msg      = "添加成功";
            }

            return(data);
        }