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 Login(string login, string password) { LoginRequest request = new LoginRequest { Login = login, Password = password }; bool result = client.Login(request); if (result) { Name = login; user = client.getUser(login); filesaver.saveFile(JsonConvert.SerializeObject(user)); return true; } else { return false; } }
public bool Logout() { Name = ""; user = new User(); PostCollection = new ObservableCollection<Post>(); filesaver.deleteFile(); return true; }
public MainViewModel() { PostCollection = new ObservableCollection<Post>(); client = new Client(); user = new User(); filesaver = new FileSaver(); CurrentPost = new Post(); }
public bool Register(string login, string password) { RegistrationRequest request = new RegistrationRequest { Login = login, Password = password, Firstname = "ImiÄ™", Lastname = "Nazwisko",Avatar = "", Bio= "" }; bool result = client.Register(request); if (result) { Name = login; user = client.getUser(login); filesaver.saveFile(JsonConvert.SerializeObject(user)); //[email protected] //[email protected] return true; } else { return false; } }