public ActionResult Create(FormCollection formCollection, CommentCreateRequest request, [FetchUser(KeyName = "userid")]UserModel userModel) { request.AuthUid = userModel.Id; request.Files = Request.Files; request.AuthUser = userModel; request.Content = UrlDecode(request.Content); this._commentDataService.Create(request); return new ContentResult(){Content = "OK"}; }
public ExecuteResult<CommentInfoResponse> Create(CommentCreateRequest request) { CommentEntity entity; if ((request.Files == null || request.Files.Count == 0) && string.IsNullOrEmpty(request.Content)) { return new ExecuteResult<CommentInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "没有评论内容!" }; } using (var ts = new TransactionScope()) { if (request.SourceType == (int)SourceType.Comment) { var repliedComment = _commentRepository.Get(l => l.Id == request.SourceId).First(); entity = _commentRepository.Insert(new CommentEntity() { Content = request.Content, CreatedDate = DateTime.Now, CreatedUser = request.AuthUser.Id, ReplyUser = repliedComment.User_Id, SourceId = repliedComment.SourceId, SourceType = repliedComment.SourceType, Status = 1, UpdatedDate = DateTime.Now, UpdatedUser = request.AuthUser.Id, User_Id = request.AuthUser.Id, ReplyId = request.SourceId }); } else { entity = _commentRepository.Insert(new CommentEntity { Content = request.Content, CreatedDate = DateTime.Now, CreatedUser = request.AuthUid, ReplyUser = request.ReplyUser, SourceId = request.SourceId, SourceType = (int)request.SType, Status = 1, UpdatedDate = DateTime.Now, UpdatedUser = request.AuthUid, User_Id = request.AuthUid }); } //处理文件上传 if (request.Files != null && request.Files.Count > 0) { ServiceLocator.Current.Resolve<IResourceService>().Save(request.Files, request.AuthUid, 0, entity.Id, SourceType.CommentAudio); } ts.Complete(); } return new ExecuteResult<CommentInfoResponse>(MappingManager.CommentInfoResponseMapping(entity, request.Version)); }
public ActionResult Create(CommentCreateRequest request, int? authuid , UserModel authUser) { request.Content = UrlDecode(request.Content); request.AuthUid = authuid.Value; request.AuthUser = authUser; request.Files = Request.Files; return new RestfulResult { Data = this._commentDataService.Create(request) }; }