Beispiel #1
0
        private async void MakeWish(object sender, RoutedEventArgs e)
        {
            Wish wish = new Wish();

            wish.Title = "Nieuwke";

            var json = JsonConvert.SerializeObject(wish);


            var res = await client.PostAsync(new Uri("http://localhost:51656/api/WishList/" + wishList.Id + "/Wishes"),
                                             new StringContent(json, Encoding.UTF8, "application/json"));

            var jsonResp = await res.Content.ReadAsStringAsync();

            var nieuwke = JsonConvert.DeserializeObject <Wish>(jsonResp);

            wishes.Add(nieuwke);
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var wish = e.Parameter as Wish;

            this.client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Globals.LoggedInUser.access_token.ToString());
            var jsonwish = client.GetStringAsync(new Uri("http://localhost:51656/api/Wishes/" + wish.Id)).Result;
            var wishdb   = JsonConvert.DeserializeObject <Wish>(jsonwish);

            this.wish = wishdb;

            OldName.Text = wishdb.Title;
            if (wishdb.WishCategory != null)
            {
                OldCat.Text = wishdb.WishCategory.Name;
            }
            if (wishdb.Description != null)
            {
                OldDesc.Text = wishdb.Description;
            }



            //api/MyWishCategories
            var json = await client.GetStringAsync(new Uri("http://localhost:51656/api/MyWishCategories"));

            var lst = JsonConvert.DeserializeObject <List <WishCategory> >(json);

            myWishCategories = lst;



            foreach (var x in lst)
            {
                WishCategoryCB.Items.Add(x.Name);
            }
        }