/// <summary> /// 发布帖子 /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool AddForum(Forum entity) { entity.ForumId = Guid.NewGuid(); entity.CreateUser = ""; entity.CreateTime = DateTime.Now; entity.ReplyAmount = 0; entity.CheckAmount = 0; return _forumRepository.AddEntity(entity); }
public JsonResult PostForum(Forum model) { bool isSuccess = false; try { isSuccess = _forumBLL.AddForum(model); msg = isSuccess == true ? new MessageModel() { MessageType = MessageType.Success, Messages = "发布帖子成功!" } : new MessageModel() { MessageType = MessageType.Fail, Messages = "发布帖子失败!" }; } catch (Exception) { msg = new MessageModel() { Messages = "发布帖子发生异常,请联系管理员!", MessageType = MessageType.Fail }; } return Json(msg, JsonRequestBehavior.AllowGet); }
/// <summary> /// 发布帖子 /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool AddEntity(Forum entity) { dbEntities.Entry<Forum>(entity).State = EntityState.Added; int result = dbEntities.SaveChanges(); return result > 0; }