public ActionResult Del(FormCollection formCollection, CommentDestroyRequest request, [FetchUser(KeyName = "userid")]UserModel userModel) { request.AuthUid = userModel.Id; request.AuthUser = userModel; this._commentDataService.Destroy(request); return new ContentResult() { Content = "OK" }; }
public ExecuteResult<CommentInfoResponse> Destroy(CommentDestroyRequest request) { var entity = this._commentRepository.GetItem(request.CommentId); if (entity == null) { return new ExecuteResult<CommentInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "评论不存在" }; } if (entity.User_Id != request.AuthUid) { return new ExecuteResult<CommentInfoResponse>(null) { StatusCode = StatusCode.ClientError, Message = "您没有权限删除其他人的评论" }; } using (var ts = new TransactionScope()) { var r = ServiceLocator.Current.Resolve<IResourceService>(); var commentResources = r.Get(entity.Id, SourceType.CommentAudio); foreach (var rs in commentResources) { r.Del(rs.Id); } _commentRepository.Delete(entity); ts.Complete(); } return new ExecuteResult<CommentInfoResponse>(MappingManager.CommentInfoResponseMapping(entity, request.Version)); }
public ActionResult Destroy(CommentDestroyRequest request, int? authuid, UserModel authUser) { request.AuthUid = authuid.Value; request.AuthUser = authUser; return new RestfulResult { Data = this._commentDataService.Destroy(request) }; }