Пример #1
0
        public async Task<IHttpActionResult> PostComment(Comment comment)
        {
            comment.CommentId = Guid.NewGuid();
#if DEBUG
            await Database.SaveCommentAsync(comment);
            return Ok();
#else
            var result = string.Empty;
            using (var client = new HttpClient())
            {
                var responsePost = await client.PostAsJsonAsync(GetUrl("/ideaComments"), comment);
                result = await responsePost.Content.ReadAsStringAsync();
                if (!responsePost.IsSuccessStatusCode)
                    return InternalServerError();
            }
            return Ok(result);
#endif
        }
Пример #2
0
 public static async Task SaveCommentAsync(Comment comment)
 {
     if (null == comment) return;
     if (comment.CommentId == Guid.Empty) comment.CommentId = Guid.NewGuid();
     _comments.Add(comment);
 }