public bool updatePost(Post post) { string body = JsonConvert.SerializeObject(post); HttpResponseMessage response = client.PutAsync(address + "/posts/" + post.id, new StringContent(body, Encoding.UTF8, "application/json")).Result; return response.IsSuccessStatusCode; }
public MainViewModel() { PostCollection = new ObservableCollection<Post>(); client = new Client(); user = new User(); filesaver = new FileSaver(); CurrentPost = new Post(); }
public bool postPost(User user, Post post) { string body = JsonConvert.SerializeObject(post); HttpResponseMessage response = client.PostAsync(address + "/users/" + user.Login + "/posts/", new StringContent(body, Encoding.UTF8, "application/json")).Result; return response.IsSuccessStatusCode; }
public bool AddPost(string type) { bool result; if (type == "Send") { result = client.postPost(user, CurrentPost); } else { result = client.updatePost(CurrentPost); } CurrentPost = new Post(); Title = ""; Content = ""; return result; }