示例#1
0
        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
            {
            }
        }
示例#2
0
 public void DeleteWish(UserWish wish)
 {
     wishlist.Remove(wish);
 }
示例#3
0
 public void AddWish(UserWish wish)
 {
     wishlist.Add(wish);
 }