public void AddWish(Wish wish) { if (Wishes != null) { Wishes.Add(wish); } }
private async void PostWish(Wish wish) { if (wish.Title == null || wish.Title.Trim().Equals("")) { DisplayDialog("Invalid Wish.", "Please enter a name for the wish."); return; } if (wish.Description == null || wish.Description.Trim().Equals("")) { DisplayDialog("Invalid Wish.", "Please enter a description for the wish."); return; } if (wish.Categorie == WishCategorie.DEFAULT) { DisplayDialog("Invalid Wish.", "Please enter a category for the wish."); return; } string wishJson = JsonConvert.SerializeObject(wish); Debug.Write(wishJson); HttpClient client = new HttpClient(); var res = await client.PostAsync("http://localhost:65172/api/wishes/", new StringContent(wishJson, System.Text.Encoding.UTF8, "application/json")); Debug.Write(res); if (res.Content != null) { string newWishJson = await res.Content.ReadAsStringAsync(); Wishes.Add(JsonConvert.DeserializeObject <Wish>(newWishJson)); } //sorting the wishes by Category then by Title Wishes = new ObservableCollection <Wish>(Wishes.OrderBy(val => val.Categorie).ThenBy(val => val.Title)); WishList.Wishes = Wishes; //_parent.WishListsOwning.Where(val => val.WishListID == WishList.WishListID).SingleOrDefault().Wishes = Wishes; _parent.CurrentData = new WishListViewModel(WishList, this._parent); }
public void AddWish(Wish item) { Wishes.Add(item); }
public void AddWish(Wish wish) { Wishes.Add(wish); }