public async Task <HttpResponseMessage> Post([FromUri] string postId, CommentViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "数据非法。"));
            }

            var post = await _postService.Get(postId);

            if (post == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "找不到对应的文章。"));
            }

            var record = PostCommentRecord.Create(model.NickName, model.Content, post);

            _commentService.Add(record);

            return(Request.CreateResponse(HttpStatusCode.OK, record.Id));
        }
Beispiel #2
0
 public void Add(PostCommentRecord record)
 {
     _repository.Value.Create(record);
 }