public async Task <MessageModel <string> > Post([FromBody] TopicDetail topicDetail) { var data = new MessageModel <string>(); if (topicDetail != null && topicDetail.Id > 0) { data.Success = await _topicDetailServices.Update(topicDetail); if (data.Success) { data.Msg = "更新成功"; data.Response = topicDetail?.Id.ObjToString(); } } else { topicDetail.tdCreatetime = DateTime.Now; topicDetail.tdRead = 0; topicDetail.tdCommend = 0; topicDetail.tdGood = 0; topicDetail.tdTop = 0; var id = (await _topicDetailServices.Add(topicDetail)); data.Success = id > 0; if (data.Success) { data.Response = id.ObjToString(); data.Msg = "添加成功"; } } return(data); }
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 async Task <MessageModel <string> > Post([FromBody] TopicDetail request) { var data = new MessageModel <string>(); var id = await _topicDetailServices.Add(request); data.success = id > 0; if (data.success) { data.response = id.ObjToString(); data.msg = "添加成功"; } return(data); }
public async Task <MessageModel <string> > Post([FromBody] TopicDetail topicDetail) { var data = new MessageModel <string>(); topicDetail.tdCreatetime = DateTime.Now; topicDetail.tdRead = 0; topicDetail.tdCommend = 0; topicDetail.tdGood = 0; topicDetail.tdTop = 0; var id = (await _topicDetailServices.Add(topicDetail)); data.success = id > 0; if (data.success) { data.response = id.ObjToString(); data.msg = "添加成功"; } return(data); }