Ejemplo n.º 1
0
        static async System.Threading.Tasks.Task MainAsync(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("Request a new token...");
            Console.WriteLine("");
            BasketService bs = new BasketService("test1", "test1");
            await bs.CreateToken();

            if (bs != null)
            {
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("Token");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(bs.Token);
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine("");
                Console.WriteLine("Token expired date");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(bs.TokenExpiredDate.ToString());
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Token creation is failed.");
            }

            await ShowProducts(bs.AuthorizationToken);

            Console.WriteLine("");

            BasketRequest request = new BasketRequest();

            request.ClientId = "A300";
            request.SKU      = "A111";
            request.Quantity = 1;
            bool addResult = await bs.AddItem(request);

            if (addResult)
            {
                Console.WriteLine("Add a new item in the basket");
                Console.ForegroundColor = ConsoleColor.White;
                await ShowProducts(bs.AuthorizationToken);
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Add a new item in the basket is failed!");
            }

            await ShowBasket(bs, "A300");

            Console.WriteLine("");
            Console.WriteLine("Done.");
            Console.ReadKey();
        }