-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
55 lines (47 loc) · 2.22 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Text.Json;
using libPantryDotNet;
namespace TestApp
{
class Program
{
public static string yourPantryIdHere = "";
public static string basket_to_mess_with = "test_basket";
public static Tuple<string, string> exampleObject;
static void Main(string[] args)
{
exampleObject = new Tuple<string, string>("item1", "1");
//It must be serialized before it can be sent.
//string EO = JsonSerializer.Serialize(exampleObject);
string EO = JsonSerializer.Serialize(exampleObject);
Console.WriteLine(EO);
//It's valid Json!
var pantry = new Pantry();
var pInfo = pantry.GetPantry(yourPantryIdHere);
Console.WriteLine("Your pantry is called " + pInfo.name);
Console.WriteLine("Your pantry is " + pInfo.percentFull + "% full.");
Console.WriteLine("You have " + pInfo.baskets.Count + " baskets.");
Console.WriteLine("Your Baskets:");
foreach (var basket in pInfo.baskets)
{
Console.WriteLine(basket);
}
if (pInfo.baskets.Contains(basket_to_mess_with))
{
Console.WriteLine("Deleting " + basket_to_mess_with);
Console.WriteLine(pantry.DeleteBasket(basket_to_mess_with, yourPantryIdHere, true));
}
Console.WriteLine("Creating a basket called " + basket_to_mess_with);
Console.WriteLine(pantry.CreateBasket(basket_to_mess_with, EO, yourPantryIdHere));
System.Threading.Thread.Sleep(1000);
Console.WriteLine("Updating a value in that basket");
exampleObject = new Tuple<string, string>("Item1", "Updated!");
EO = JsonSerializer.Serialize(exampleObject);
Console.WriteLine(pantry.UpdateBasket(basket_to_mess_with, EO, yourPantryIdHere));
Console.WriteLine("Reading back the Basket");
Console.WriteLine(pantry.GetBasket(basket_to_mess_with, yourPantryIdHere));
Console.WriteLine("Press Any Key to close");
Console.ReadKey();
}
}
}