public async Task <HttpResponseMessage> Update(CommentViewModel commentViewModel) { var comment = commentViewModel.ConvertToComment(); // Preparo content del put var json = JsonConvert.SerializeObject(comment); var buffer = Encoding.UTF8.GetBytes(json); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); // PUT api/comentarios/id var response = await _httpClient.PutAsync(_urlApiComments + "/" + comment.Id, byteContent); return(response); }
public async Task <HttpResponseMessage> Create(CommentViewModel commentViewModel, int petId, ApplicationUser user) { var comment = commentViewModel.ConvertToComment(); comment.PetId = petId; comment.UserId = user.Id; // Preparo content del post var json = JsonConvert.SerializeObject(comment); var buffer = Encoding.UTF8.GetBytes(json); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); // POST api/comentarios var response = await _httpClient.PostAsync(_urlApiComments, byteContent); return(response); }