public async Task sendWish(UserWish wish) { //UserWish wish1 = new UserWish { Id = "ati is missing", Wish_ = new Wish() }; var json = JsonConvert.SerializeObject(wish); var data = new StringContent(json, Encoding.UTF8, "application/json"); var url = "https://localhost:44345/api/UserWishes"; using var client = new HttpClient(); Console.WriteLine("sent a wish"); var response = await client.PostAsync(url, data); Console.WriteLine("Status code is: " + response.Content.ReadAsStringAsync().Result); //var gotwish = JsonConvert.DeserializeObject<UserWish>(response.Content.ReadAsStringAsync().Result); if (!response.IsSuccessStatusCode) { throw new Exception("Wish is already added"); } else { } }
public void DeleteWish(UserWish wish) { wishlist.Remove(wish); }
public void AddWish(UserWish wish) { wishlist.Add(wish); }