protected override void OnNavigatedTo(NavigationEventArgs e) { user = (User)e.Parameter; travelList = new ObservableCollection<TravelList>(user.TravelList); setProgress(travelList); TravellingItems.ItemsSource = travelList; }
private async System.Threading.Tasks.Task<TravelList> AddTravelList(User u , TravelList t) { User o = new User(); // string content = "Name="+name+ "&DepartureDate="+d+"&Location="+location; System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://apiproject2.azurewebsites.net/api/TravelLists/add?id=" + u.Id+"&Name="+t.Name+"&Location="+t.Location+"&Date="+t.DepartureDate+""); HttpResponseMessage response = await client.SendAsync(request); string data = await response.Content.ReadAsStringAsync(); var res = System.Threading.Tasks.Task.Factory.StartNew(() => JsonConvert.DeserializeObject<TravelList>(data)); return await res; }
private async System.Threading.Tasks.Task<User> GetUser(String username,String password) { String strAlgName = HashAlgorithmNames.Sha512; String strMsg = TextPass.Password; String strEncodedHash = this.HashPass(strAlgName, strMsg); User o = new User(); System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://apiproject2.azurewebsites.net/api/Users/login?name=" + username+"&password="+strEncodedHash); HttpResponseMessage response = await client.SendAsync(request); string data = await response.Content.ReadAsStringAsync(); var res = System.Threading.Tasks.Task.Factory.StartNew(() => JsonConvert.DeserializeObject<User>(data)); return await res; }
private async void ButtonRegister_Click(object sender, RoutedEventArgs e) { try { if (TextPassCheck.Password.Length == 0 || TextUser.Text.Length == 0 || TextPass.Password.Length == 0 || TextEmail.Text.Length == 0) { TextInfo.Text = "Gelieve alles in te vullen."; } else { if (TextPassCheck.Password.Equals(TextPass.Password)) { String strAlgName = HashAlgorithmNames.Sha512; String strMsg = TextPass.Password; String strEncodedHash = this.HashPass(strAlgName, strMsg); User user = new User(); user.Password = strEncodedHash; user.Name = TextUser.Text; System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); Debug.WriteLine(user); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://apiproject2.azurewebsites.net/api/Users/register?name=" + TextUser.Text + "&password="******"&email=" + TextEmail.Text); HttpResponseMessage response = await client.SendAsync(request); Frame.Navigate(typeof(LoginPage)); } else { TextInfo.Text = "Wachtwoorden zijn niet gelijk."; } } }catch(Exception ex) { TextInfo.Text = "Er is een fout opgetreden"; } }
private async System.Threading.Tasks.Task<Category> DeleteCat(int id) { User o = new User(); // string content = "Name="+name+ "&DepartureDate="+d+"&Location="+location; System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Delete, "http://apiproject2.azurewebsites.net/api/Categories/" + id); HttpResponseMessage response = await client.SendAsync(request); string data = await response.Content.ReadAsStringAsync(); var res = System.Threading.Tasks.Task.Factory.StartNew(() => JsonConvert.DeserializeObject<Category>(data)); return await res; }
private async System.Threading.Tasks.Task<Item> AddItem(int C_id, Item i) { User o = new User(); // string content = "Name="+name+ "&DepartureDate="+d+"&Location="+location; System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://apiproject2.azurewebsites.net/api/Categories/addItem?catId=" + C_id+"&name="+i.Name+"&quantity="+i.Quantity+"&completed="+i.Completed); HttpResponseMessage response = await client.SendAsync(request); string data = await response.Content.ReadAsStringAsync(); var res = System.Threading.Tasks.Task.Factory.StartNew(() => JsonConvert.DeserializeObject<Item>(data)); return await res; }