static void deleteItemsTest()
        {
            try
            {
                SalesAPI api = new SalesAPI();

                pcAmerica.DesktopPOS.API.Client.SalesService.Context context = new pcAmerica.DesktopPOS.API.Client.SalesService.Context();
                context.CashierID = "100101";
                context.StoreID = "1001";
                context.StationID = "01";

                // StartNewInvoice - this also automatically locks an invoice so it can't be opened by a terminal
                Invoice inv = api.StartNewInvoice(context, "ROB" + DateTime.Now.Ticks.ToString(), "XXOPEN TABS");
                Console.WriteLine(String.Format("Started new invoice with #: {0}", inv.InvoiceNumber));

                // Unlock Invoice
                /*if (api.UnLockInvoice(context, inv.InvoiceNumber))
                    Console.WriteLine(String.Format("Unlocked invoice # {0}", inv.InvoiceNumber));
                else
                    Console.WriteLine(String.Format("Failed to unlock invoice # {0}", inv.InvoiceNumber));*/

                // Lock Invoice
                if (api.LockInvoice(context, inv.InvoiceNumber))
                    Console.WriteLine(String.Format("Locked invoice # {0}", inv.InvoiceNumber));
                else
                    Console.WriteLine(String.Format("Failed to lock invoice # {0}", inv.InvoiceNumber));

                // GetInvoiceHeader
                inv = api.GetInvoiceHeader(context, inv.InvoiceNumber);
                Console.WriteLine(String.Format("GetInvoiceHeader with #: {0}", inv.InvoiceNumber));

                // GetInvoice
                inv = api.GetInvoice(context, inv.InvoiceNumber);
                Console.WriteLine(String.Format("GetInvoice with #: {0}", inv.InvoiceNumber));

                InventoryAPI InvApi = new InventoryAPI();

                pcAmerica.DesktopPOS.API.Client.InventoryService.Context InvContext = new pcAmerica.DesktopPOS.API.Client.InventoryService.Context();
                InvContext.CashierID = "100101";
                InvContext.StationID = "01";
                InvContext.StoreID = "1001";

                Guid parentGuid = new Guid();
                // ModifyItems
                inv.LineItems.Add(new LineItem() { Id = parentGuid, ItemName = "BURGER", ItemNumber = "SAND1", Price = 1.99M, Quantity = 2, State = EntityState.Added });

                inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = "Add Tomato", ItemNumber = "SANDMod3", Price = 0.10M, Quantity = 1, State = EntityState.Added, ParentId = parentGuid });

                inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = "BURGER", ItemNumber = "SAND1", Price = 1.99M, Quantity = 1, State = EntityState.Added });

                api.UnLockInvoice(context, inv.InvoiceNumber);
                api.LockInvoice(context, inv.InvoiceNumber);

                inv = api.ModifyItems(context, inv.InvoiceNumber, inv.LineItems);

                Invoice inv2 = api.GetInvoice(context, inv.InvoiceNumber);

                Console.WriteLine(String.Format("ModifyItems new invoice value: {0}", inv2.GrandTotal));
                //inv2.LineItems[0].State = EntityState.Deleted;
                //inv2.LineItems[1].State = EntityState.Deleted;
                inv2 = api.ModifyItems(context, inv2.InvoiceNumber, inv2.LineItems);
                Console.WriteLine(String.Format("ModifyItems new invoice value after deleting burger with tomato: {0}", inv2.GrandTotal));

                api.LockInvoice(context, inv2.InvoiceNumber);

                // ApplyCashPayment - applying grand total minus 1 dollar
                AppliedPaymentResponse payResponse = api.ApplyCashPayment(context, inv2.InvoiceNumber, -1, inv2.GrandTotal);
                if (payResponse.Success)
                    Console.WriteLine(String.Format("Applied cash payment, change due {0}", payResponse.ChangeAmount));
                else
                    Console.WriteLine("***ERROR*** Could not apply payment");

                // EndInvoice
                if (api.EndInvoice(context, inv2.InvoiceNumber))
                    Console.WriteLine("Ended invoice successfully");
                else
                    Console.WriteLine("***ERROR*** Could not end invoice");

                // PrintReceipt - providing -1 for the split check # when there are no split checks
                if (api.PrintReceipt(context, inv2.InvoiceNumber, -1))
                    Console.WriteLine("Receipt was printed");
                else
                    Console.WriteLine("***ERROR*** Receive was NOT printed");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                Console.WriteLine("PRESS ENTER TO CONTINUE...");
                Console.ReadLine();
            }
        }
        static void TestPreAuthInvoice()
        {
            try
            {
                SalesAPI salesAPI = new SalesAPI();

                pcAmerica.DesktopPOS.API.Client.SalesService.Context salesContext = new pcAmerica.DesktopPOS.API.Client.SalesService.Context();
                salesContext.CashierID = "100101";
                salesContext.StoreID = "1001";
                salesContext.StationID = "01";

                PaymentAPI paymentAPI = new PaymentAPI();

                // first create the credit card object
                pcAmerica.DesktopPOS.API.Client.PaymentService.CreditCardRequest creditCard1 = new pcAmerica.DesktopPOS.API.Client.PaymentService.CreditCardRequest();
                creditCard1.Amount = 5.00M;
                creditCard1.CardNumber = "5454545454545454";
                creditCard1.ExpirationMonth = 05;
                creditCard1.ExpirationYear = 13;
                creditCard1.BarTab = true;// set this for a pre authed bar tab
                creditCard1.ProcessingType = pcAmerica.DesktopPOS.API.Client.PaymentService.ProcessingType.PreAuth;
                pcAmerica.DesktopPOS.API.Client.PaymentService.CreditCardPaymentProcessingResponse ProcessingResponse1 = paymentAPI.ProcessCreditCard(creditCard1);

                // create an invoice to apply your payment to
                Invoice inv = salesAPI.StartNewInvoice(salesContext, "Jane", "XXOPEN TABS");

                // use paymentIndex of -1 since the card isn't attached to the invoice yet
                AppliedPaymentResponse paymentResponse1 = salesAPI.ApplyCardPayment(salesContext, inv.InvoiceNumber, -1, new pcAmerica.DesktopPOS.API.Client.SalesService.CreditCardPaymentProcessingResponse() { Amount = ProcessingResponse1.Amount, ApprovalCode = ProcessingResponse1.ApprovalCode, CardNumber = ProcessingResponse1.CardNumber, ExpirationMonth = ProcessingResponse1.ExpirationMonth, ExpirationYear = ProcessingResponse1.ExpirationYear, ExtensionData = ProcessingResponse1.ExtensionData, IsPrePaidCard = ProcessingResponse1.IsPrePaidCard, PostAuthReferenceNumber = ProcessingResponse1.PostAuthReferenceNumber, ProcessType = pcAmerica.DesktopPOS.API.Client.SalesService.ProcessingType.PreAuth, ReferenceNumber = ProcessingResponse1.ReferenceNumber, Result = ProcessingResponse1.Result, TipAmount = ProcessingResponse1.TipAmount, TransactionNumber = ProcessingResponse1.TransactionNumber }, -1);

                // some time passes and items are added to the invoice
                InventoryAPI invAPI = new InventoryAPI();
                pcAmerica.DesktopPOS.API.Client.InventoryService.Context invContext = new pcAmerica.DesktopPOS.API.Client.InventoryService.Context();
                invContext.CashierID = "100101";
                invContext.StationID = "01";
                invContext.StoreID = "1001";

                salesAPI.LockInvoice(salesContext, inv.InvoiceNumber);
                inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = "TRIPPLE CHEESE BURGER", ItemNumber = "SAND4", Price = 3.99M, Quantity = 1, State = EntityState.Added, Guest = "1" });
                inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = "TRIPPLE CHEESE BURGER", ItemNumber = "SAND4", Price = 3.99M, Quantity = 1, State = EntityState.Added, Guest = "2" });
                inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = "TRIPPLE CHEESE BURGER", ItemNumber = "SAND4", Price = 3.99M, Quantity = 1, State = EntityState.Added, Guest = "3" });
                inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = "TRIPPLE CHEESE BURGER", ItemNumber = "SAND4", Price = 3.99M, Quantity = 1, State = EntityState.Added, Guest = "4" });
                inv = salesAPI.ModifyItems(salesContext, inv.InvoiceNumber, inv.LineItems);

                //to complete the earlier pre auth card you must call CompletePreAuth and pass it the PaymentIndex you got back from ApplyCardPayment earlier
                creditCard1.Amount = inv.GrandTotal - 7.98M;
                creditCard1.ProcessingType = pcAmerica.DesktopPOS.API.Client.PaymentService.ProcessingType.PostAuth;
                creditCard1.PostAuthReferenceNumber = ProcessingResponse1.PostAuthReferenceNumber;
                creditCard1.ReferenceNumber = ProcessingResponse1.ReferenceNumber;
                creditCard1.PaymentIndex = paymentResponse1.PaymentIndex;

                ProcessingResponse1 = paymentAPI.CompletePreAuth(creditCard1, inv.InvoiceNumber);
                paymentResponse1 = salesAPI.ApplyCardPayment(salesContext, inv.InvoiceNumber, -1, new pcAmerica.DesktopPOS.API.Client.SalesService.CreditCardPaymentProcessingResponse() { Amount = ProcessingResponse1.Amount, ApprovalCode = ProcessingResponse1.ApprovalCode, CardNumber = ProcessingResponse1.CardNumber, ExpirationMonth = ProcessingResponse1.ExpirationMonth, ExpirationYear = ProcessingResponse1.ExpirationYear, ExtensionData = ProcessingResponse1.ExtensionData, IsPrePaidCard = ProcessingResponse1.IsPrePaidCard, PostAuthReferenceNumber = ProcessingResponse1.PostAuthReferenceNumber, ProcessType = pcAmerica.DesktopPOS.API.Client.SalesService.ProcessingType.PostAuth, ReferenceNumber = ProcessingResponse1.ReferenceNumber, Result = ProcessingResponse1.Result, TipAmount = ProcessingResponse1.TipAmount, TransactionNumber = ProcessingResponse1.TransactionNumber }, paymentResponse1.PaymentIndex);

                // create a second credit card object
                pcAmerica.DesktopPOS.API.Client.PaymentService.CreditCardRequest creditCard2 = new pcAmerica.DesktopPOS.API.Client.PaymentService.CreditCardRequest();
                creditCard2.Amount = 7.98M;
                creditCard2.CardNumber = "4545454545454545";
                creditCard2.ExpirationMonth = 05;
                creditCard2.ExpirationYear = 13;
                creditCard2.BarTab = false;// this card is not a bar tab
                creditCard2.ProcessingType = pcAmerica.DesktopPOS.API.Client.PaymentService.ProcessingType.PreAuth;
                //process and apply the 2nd card
                pcAmerica.DesktopPOS.API.Client.PaymentService.CreditCardPaymentProcessingResponse ProcessingResponse2 = paymentAPI.ProcessCreditCard(creditCard2);
                AppliedPaymentResponse paymentResponse2 = salesAPI.ApplyCardPayment(salesContext, inv.InvoiceNumber, -1, new pcAmerica.DesktopPOS.API.Client.SalesService.CreditCardPaymentProcessingResponse() { Amount = ProcessingResponse2.Amount, ApprovalCode = ProcessingResponse2.ApprovalCode, CardNumber = ProcessingResponse2.CardNumber, ExpirationMonth = ProcessingResponse2.ExpirationMonth, ExpirationYear = ProcessingResponse2.ExpirationYear, ExtensionData = ProcessingResponse2.ExtensionData, IsPrePaidCard = ProcessingResponse2.IsPrePaidCard, PostAuthReferenceNumber = ProcessingResponse2.PostAuthReferenceNumber, ProcessType = pcAmerica.DesktopPOS.API.Client.SalesService.ProcessingType.PreAuth, ReferenceNumber = ProcessingResponse2.ReferenceNumber, Result = ProcessingResponse2.Result, TipAmount = ProcessingResponse2.TipAmount, TransactionNumber = ProcessingResponse2.TransactionNumber }, -1);

                //update the invoice object and end the transaction
                inv = salesAPI.GetInvoice(salesContext, inv.InvoiceNumber);
                salesAPI.EndInvoice(salesContext, inv.InvoiceNumber);

                //salesAPI.PrintReceipt(salesContext, inv.InvoiceNumber,-1);

                //add a tips to the invoice
                creditCard1.TipAmount = 1.5M;
                creditCard1.BarTab = false;
                ProcessingResponse1 = paymentAPI.CompletePreAuth(creditCard1, inv.InvoiceNumber);
                salesAPI.ApplyCardPayment(salesContext, inv.InvoiceNumber, -1, new pcAmerica.DesktopPOS.API.Client.SalesService.CreditCardPaymentProcessingResponse() { Amount = ProcessingResponse1.Amount, ApprovalCode = ProcessingResponse1.ApprovalCode, CardNumber = ProcessingResponse1.CardNumber, ExpirationMonth = ProcessingResponse1.ExpirationMonth, ExpirationYear = ProcessingResponse1.ExpirationYear, ExtensionData = ProcessingResponse1.ExtensionData, IsPrePaidCard = ProcessingResponse1.IsPrePaidCard, PostAuthReferenceNumber = ProcessingResponse1.PostAuthReferenceNumber, ProcessType = pcAmerica.DesktopPOS.API.Client.SalesService.ProcessingType.PostAuth, ReferenceNumber = ProcessingResponse1.ReferenceNumber, Result = ProcessingResponse1.Result, TipAmount = ProcessingResponse1.TipAmount, TransactionNumber = ProcessingResponse1.TransactionNumber }, paymentResponse1.PaymentIndex);

                //to complete the earlier pre auth card you must call CompletePreAuth and pass it the PaymentIndex you got back from ApplyCardPayment earlier
                creditCard2.Amount = 7.98M;
                creditCard2.TipAmount = 1.77M;
                creditCard2.ProcessingType = pcAmerica.DesktopPOS.API.Client.PaymentService.ProcessingType.PostAuth;
                creditCard2.PostAuthReferenceNumber = ProcessingResponse2.PostAuthReferenceNumber;
                creditCard2.ReferenceNumber = ProcessingResponse2.ReferenceNumber;
                creditCard2.PaymentIndex = paymentResponse2.PaymentIndex;
                ProcessingResponse2 = paymentAPI.CompletePreAuth(creditCard2, inv.InvoiceNumber);
                salesAPI.ApplyCardPayment(salesContext, inv.InvoiceNumber, -1, new pcAmerica.DesktopPOS.API.Client.SalesService.CreditCardPaymentProcessingResponse() { Amount = ProcessingResponse2.Amount, ApprovalCode = ProcessingResponse2.ApprovalCode, CardNumber = ProcessingResponse2.CardNumber, ExpirationMonth = ProcessingResponse2.ExpirationMonth, ExpirationYear = ProcessingResponse2.ExpirationYear, ExtensionData = ProcessingResponse2.ExtensionData, IsPrePaidCard = ProcessingResponse2.IsPrePaidCard, PostAuthReferenceNumber = ProcessingResponse2.PostAuthReferenceNumber, ProcessType = pcAmerica.DesktopPOS.API.Client.SalesService.ProcessingType.PostAuth, ReferenceNumber = ProcessingResponse2.ReferenceNumber, Result = ProcessingResponse2.Result, TipAmount = ProcessingResponse2.TipAmount, TransactionNumber = ProcessingResponse2.TransactionNumber }, paymentResponse2.PaymentIndex);

                salesAPI.PrintReceipt(salesContext, inv.InvoiceNumber, -1);
            }
            finally
            {
                Console.WriteLine("PRESS ENTER TO CONTINUE...");
                Console.ReadLine();
            }
        }
        // more examples to work specificly with the sample database Burger Express that comes bundled with Resturant Pro Express
        // shows getting list of all inventory items, adding items two different ways, selecting a modifier for an item and splitting a check by guest
        static void TestBurgerExpress()
        {
            try
            {
                SalesAPI api = new SalesAPI();

                DateTime startDateTime = DateTime.Parse("1/1/2010");
                DateTime endDateTime = DateTime.Parse("12/31/2010");

                SalesTotals totals = api.GetTotals(startDateTime, endDateTime);
                Console.WriteLine(String.Format("Sales totals between {0}-{1} -- NetSales:{2} TotalTax:{3} GrandTotal:{4}", startDateTime, endDateTime, totals.NetSales, totals.TotalTax, totals.GrandTotal));

                List<ItemSale> sales = api.GetItemsSold(startDateTime, endDateTime);
                Console.WriteLine(String.Format("Between {0}-{1}, there are {2} records of items being sold", startDateTime, endDateTime, sales.Count));

                pcAmerica.DesktopPOS.API.Client.SalesService.Context context = new pcAmerica.DesktopPOS.API.Client.SalesService.Context();
                context.CashierID = "100101";
                context.StoreID = "1001";
                context.StationID = "01";

                // StartNewInvoice - this also automatically locks an invoice so it can't be opened by a terminal
                Invoice inv = api.StartNewInvoice(context, "Dan" + DateTime.Now.Second.ToString(), "XXOPEN TABS");
                Console.WriteLine(String.Format("Started new invoice with #: {0}", inv.InvoiceNumber));

                // Unlock Invoice
                if (api.UnLockInvoice(context, inv.InvoiceNumber))
                    Console.WriteLine(String.Format("Unlocked invoice # {0}", inv.InvoiceNumber));
                else
                    Console.WriteLine(String.Format("Failed to unlock invoice # {0}", inv.InvoiceNumber));

                // Lock Invoice
                if (api.LockInvoice(context, inv.InvoiceNumber))
                    Console.WriteLine(String.Format("Locked invoice # {0}", inv.InvoiceNumber));
                else
                    Console.WriteLine(String.Format("Failed to lock invoice # {0}", inv.InvoiceNumber));

                // GetInvoiceHeader
                inv = api.GetInvoiceHeader(context, inv.InvoiceNumber);
                Console.WriteLine(String.Format("GetInvoiceHeader with #: {0}", inv.InvoiceNumber));

                // GetInvoice
                inv = api.GetInvoice(context, inv.InvoiceNumber);
                Console.WriteLine(String.Format("GetInvoice with #: {0}", inv.InvoiceNumber));

                InventoryAPI InvApi = new InventoryAPI();

                pcAmerica.DesktopPOS.API.Client.InventoryService.Context InvContext = new pcAmerica.DesktopPOS.API.Client.InventoryService.Context();
                InvContext.CashierID = "100101";
                InvContext.StationID = "01";
                InvContext.StoreID = "1001";

                api.SetPartySizeForInvoice(context, inv.InvoiceNumber, 2);

                List<InventoryItem> items = InvApi.GetItemListExtended(InvContext);

                Console.WriteLine("*******************All Inventory Items************************");
                foreach (InventoryItem singleItem in items)
                {
                    Console.WriteLine(String.Format("Item#: {0} ItemName:{1}", singleItem.ItemNumber, singleItem.ItemName));
                }
                Console.WriteLine("***************************************************************");

                // ModifyItems
                inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = "TRIPPLE CHEESE BURGER", ItemNumber = "SAND4", Price = 3.99M, Quantity = 1, State = EntityState.Added, Guest = "1" });

                InventoryItem itemToAdd = InvApi.GetItem(InvContext, "SALAD3");
                Guid itemToAddID = Guid.NewGuid();
                LineItem LineItemToAdd = new LineItem() { Id = itemToAddID, ItemName = itemToAdd.ItemName, ItemNumber = itemToAdd.ItemNumber, Price = itemToAdd.Price, Quantity = 1, State = EntityState.Added, Guest = "2" };
                inv.LineItems.Add(LineItemToAdd);

                itemToAdd.ModifierGroups = InvApi.GetModiferGroupsForItem(InvContext, itemToAdd.ItemNumber);
                foreach (ModifierGroup ModGroup in itemToAdd.ModifierGroups)
                {
                    Console.WriteLine("ModifierGroup:{0}", ModGroup.ItemName);
                    Console.WriteLine("{0}", ModGroup.Prompt);
                    int i = 1;
                    if (ModGroup.Forced == false)
                    {
                        Console.WriteLine("{0} - NONE", i);
                        i++;
                    }
                    //NOTE THIS HAS CHANGED Modifier Items for Groups now are retrieved by calling GetModiferItemsForModiferGroups
                    ModGroup.ModifierItems = InvApi.GetModifierItemsForModifierGroup(InvContext, ModGroup.ItemNumber);
                    foreach (ModifierItem ModItem in ModGroup.ModifierItems)
                    {
                        Console.WriteLine("{0} - {1} : {2}", i, ModItem.ItemNumber, ModItem.ItemName);
                        i++;
                    }
                    string answer = Console.ReadLine();
                    if (answer.Length > 1)
                    {
                        Console.WriteLine("Invalid answer i Choose option 1 is chosen by default");
                        answer = "1";
                    }
                    else if (char.IsDigit(answer[0]) == false)
                    {
                        Console.WriteLine("Invalid answer i Choose option 1 chosen by defualt");
                        answer = "1";
                    }
                    InventoryItem dressing = InvApi.GetItem(InvContext, ModGroup.ModifierItems[Convert.ToInt32(answer) - 1].ItemNumber);
                    decimal Price = 0;
                    if (ModGroup.Charged == true) { Price = dressing.Price; }
                    inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = dressing.ItemName, ItemNumber = dressing.ItemNumber, Price = dressing.Price, Quantity = 1, State = EntityState.Added, Guest = "2" });
                }

                itemToAdd = InvApi.GetItem(InvContext, "DaveBurger");
                itemToAddID = Guid.NewGuid();
                LineItemToAdd = new LineItem() { Id = itemToAddID, ItemName = itemToAdd.ItemName, ItemNumber = itemToAdd.ItemNumber, Price = itemToAdd.Price, Quantity = 1, State = EntityState.Added, Guest = "2" };
                inv.LineItems.Add(LineItemToAdd);
                itemToAdd.ModifierItems = InvApi.GetIndividualModifiers(InvContext, itemToAdd.ItemNumber);
                if (itemToAdd.ModifierItems.Count > 0)
                    inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = itemToAdd.ModifierItems[0].ItemName, ItemNumber = itemToAdd.ModifierItems[0].ItemNumber, Price = 0.00M, Quantity = 1, State = EntityState.Added, Guest = "1" });

                // This is a sample Kit Item I made that i added some items to you just have to ring up the base item(test) and the kit items will add along with it automaticly
                itemToAdd = InvApi.GetItem(InvContext, "test");
                itemToAddID = Guid.NewGuid();
                LineItemToAdd = new LineItem() { Id = itemToAddID, ItemName = itemToAdd.ItemName, ItemNumber = itemToAdd.ItemNumber, Price = itemToAdd.Price, Quantity = 1, State = EntityState.Added, Guest = "2" };
                inv.LineItems.Add(LineItemToAdd);

                itemToAdd = InvApi.GetItem(InvContext, "test");
                itemToAddID = Guid.NewGuid();
                LineItemToAdd = new LineItem() { Id = itemToAddID, ItemName = itemToAdd.ItemName, ItemNumber = itemToAdd.ItemNumber, Price = itemToAdd.Price, Quantity = 1, State = EntityState.Added, Guest = "2" };
                inv.LineItems.Add(LineItemToAdd);

                itemToAdd = InvApi.GetItem(InvContext, "DRINKCHOICE");
                int j = 1;
                Console.WriteLine(itemToAdd.ItemName2);
                InventoryItem Choice;
                foreach (String choiceItemNumber in itemToAdd.ChoiceItems)
                {
                    Choice = InvApi.GetItem(InvContext, choiceItemNumber);
                    Console.WriteLine(string.Format("{0}: ", Choice.ItemName));
                    j++;
                }
                int choiceItemSelection = Convert.ToInt32(Console.ReadLine()) - 1;
                itemToAdd = InvApi.GetItem(InvContext, itemToAdd.ChoiceItems[choiceItemSelection]);
                itemToAddID = Guid.NewGuid();
                LineItemToAdd = new LineItem() { Id = itemToAddID, ItemName = itemToAdd.ItemName, ItemNumber = itemToAdd.ItemNumber, Price = itemToAdd.Price, Quantity = 1, State = EntityState.Added, Guest = "1" };
                inv.LineItems.Add(LineItemToAdd);

                inv = api.ModifyItems(context, inv.InvoiceNumber, inv.LineItems);
                Console.WriteLine(String.Format("ModifyItems new invoice value: {0}", inv.GrandTotal));

                inv.LineItems[0].Quantity = 2;
                inv.LineItems[0].State = EntityState.Modified;
                inv = api.ModifyItems(context, inv.InvoiceNumber, inv.LineItems);
                Console.WriteLine(String.Format("ModifyItems CHANGED 1st item QUANTITY, new invoice value: {0}", inv.GrandTotal));

                // SendToKitchen
                if (api.SendToKitchen(context, inv.InvoiceNumber))
                    Console.WriteLine("Invoice was printed in kitchen");
                else
                    Console.WriteLine("***ERROR*** Invoice was NOT printed in kitchen");

                // Splitcheck
                inv = api.SplitInvoiceByGuest(context, inv.InvoiceNumber);
                if (inv.SplitInfo.NumberOfSplitChecks == 2)
                    Console.WriteLine("Split invoice by guest");
                else
                    Console.WriteLine("***ERROR*** Invoice could be split");

                // ApplyCashPayment - applying grand total minus 1 dollar (NOTE SPLITS Starts counting at 0 not 1)
                AppliedPaymentResponse payResponse = api.ApplyCashPayment(context, inv.InvoiceNumber, 0, inv.SplitInfo.GrandTotalForSplit[0] - 1);
                if (payResponse.Success)
                    Console.WriteLine(String.Format("Applied cash payment to split 1, change due {0}", payResponse.ChangeAmount));
                else
                    Console.WriteLine("***ERROR*** Could not apply payment");

                // ApplyCardPayment - applying remaining 1 dollar as a credit card
                payResponse = api.ApplyCardPayment(context,
                    inv.InvoiceNumber,
                    0,
                    new pcAmerica.DesktopPOS.API.Client.SalesService.CreditCardPaymentProcessingResponse()
                    {
                        Amount = 1,
                        CardNumber = "4***********1",
                        ReferenceNumber = "123456",
                        Result = true,
                        TipAmount = 1,
                        TransactionNumber = 1234
                    }, -1);
                if (payResponse.Success)
                    Console.WriteLine(String.Format("Applied card payment to split 1, change due {0}", payResponse.ChangeAmount));
                else
                    Console.WriteLine("***ERROR*** Could not apply card payment");

                payResponse = api.ApplyCashPayment(context, inv.InvoiceNumber, 1, inv.SplitInfo.GrandTotalForSplit[1] + 13);
                if (payResponse.Success)
                    Console.WriteLine(String.Format("Applied cash payment to split 2, change due {0}", payResponse.ChangeAmount));
                else
                    Console.WriteLine("***ERROR*** Could not apply payment");

                // EndInvoice
                if (api.EndInvoice(context, inv.InvoiceNumber))
                    Console.WriteLine("Ended invoice successfully");
                else
                    Console.WriteLine("***ERROR*** Could not end invoice");

                // looping and printing receipt for all splits
                for (int i = 0; i < inv.SplitInfo.NumberOfSplitChecks; i++)
                {
                    if (api.PrintReceipt(context, inv.InvoiceNumber, i))
                        Console.WriteLine("Receipt was printed");
                    else
                        Console.WriteLine("***ERROR*** Receive was NOT printed");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                Console.WriteLine("PRESS ENTER TO CONTINUE...");
                Console.ReadLine();
            }
        }
        static void TestInventory()
        {
            InventoryAPI api = new InventoryAPI();

            try
            {
                List<InventoryItem> items = api.GetItemList();
                Console.WriteLine(String.Format("There are currently {0} items in the POS database.", items.Count));

                pcAmerica.DesktopPOS.API.Client.InventoryService.Context context = new pcAmerica.DesktopPOS.API.Client.InventoryService.Context();
                context.StoreID = "1001";
                context.StationID = "01";
                context.CashierID = "100101";

                InventoryItem item = api.GetItem(context, "Non_Inventory");
                if (item == null)
                    Console.WriteLine("***ERROR*** Could not retrieve Non_Inventory item");
                else
                    Console.WriteLine("Retrieved Non_Inventory item");

                Console.WriteLine(string.Format("The Non_Inventory item has Item Type of {0}", item.ItemType));

                List<ModifierGroup> modGroups = api.GetModiferGroupsForItem(context, "Non_Inventory");
                if (modGroups == null || modGroups.Count == 0)
                    Console.WriteLine("No modifier groups exist for the Non_Inventory item!");
                else
                    Console.WriteLine(String.Format("Found {0} modifier groups for the Non_Inventory item!", modGroups.Count));

                List<ModifierItem> modifiers = api.GetIndividualModifiers(context, "Non_Inventory");
                if (modifiers == null || modifiers.Count == 0)
                    Console.WriteLine("No modifiers exist for the Non_Inventory item!");
                else
                    Console.WriteLine(String.Format("Found {0} modifiers for the Non_Inventory item!", modifiers.Count));

                if (item.KitItems == null || item.KitItems.Count == 0)
                    Console.WriteLine("The Non_Inventory has no Kit Items!");
                else
                    Console.WriteLine(String.Format("Found {0} Kit Item(s) for the Non_Inventory item!", item.KitItems.Count));

                InventoryItem kitTest = api.GetItem(context, "kit1");
                if (kitTest.KitItems == null || kitTest.KitItems.Count == 0)
                    Console.WriteLine("kit1 has no Kit Items!");
                else
                    Console.WriteLine(String.Format("Found {0} Kit Item(s) for kit1!", kitTest.KitItems.Count));

                if (item.ChoiceItems == null || item.ChoiceItems.Count == 0)
                    Console.WriteLine("The Non_Inventory has no Choice Items!");
                else
                    Console.WriteLine(String.Format("Found {0} Choice Item(s) for the Non_Inventory item!", item.ChoiceItems.Count));

                InventoryItem choiceTest = api.GetItem(context, "Choice Item One");
                if (choiceTest.ChoiceItems == null || choiceTest.ChoiceItems.Count == 0)
                    Console.WriteLine("Choice Item One has no Choice Items!");
                else
                    Console.WriteLine(String.Format("Found {0} Choice Item(s) for Choice Item One!", choiceTest.ChoiceItems.Count));

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                Console.WriteLine("PRESS ENTER TO CONTINUE...");
                Console.ReadLine();
            }
        }
        static void NewTest()
        {
            try
            {
                SalesAPI api = new SalesAPI();

                pcAmerica.DesktopPOS.API.Client.SalesService.Context salesContext = new pcAmerica.DesktopPOS.API.Client.SalesService.Context();
                salesContext.CashierID = "100101";
                salesContext.StoreID = "1001";
                salesContext.StationID = "07";

                pcAmerica.DesktopPOS.API.Client.SalesService.Context context =
                    new pcAmerica.DesktopPOS.API.Client.SalesService.Context();
                context.CashierID = "100101";
                context.StoreID = "1001";
                context.StationID = "07";

                InventoryAPI InvApi = new InventoryAPI();

                pcAmerica.DesktopPOS.API.Client.InventoryService.Context InvContext = new pcAmerica.DesktopPOS.API.Client.InventoryService.Context();
                InvContext.CashierID = "100101";
                InvContext.StationID = "07";
                InvContext.StoreID = "1001";

                // StartNewInvoice - this also automatically locks an invoice so it can't be opened by a terminal
                Invoice inv = api.StartNewInvoice(context, "Luigi" + DateTime.Now.Second.ToString(), "XXOPEN TABS");
                Console.WriteLine(String.Format("Started new invoice with #: {0}", inv.InvoiceNumber));

                // getting invoice to show locked status should be locked by this station(7)
                inv = api.GetInvoice(context, inv.InvoiceNumber);
                if (inv.Locked == true)
                {
                    Console.WriteLine("Invoice #{0} is locked by Station: {1}", inv.InvoiceNumber.ToString(), inv.LockedByStation);
                }
                else
                {
                    Console.WriteLine("Invoice #{0} is unlocked", inv.InvoiceNumber.ToString());
                }
                //setting party size
                api.SetPartySizeForInvoice(context, inv.InvoiceNumber, 3);

                InventoryItem itemToAdd = InvApi.GetItem(InvContext, "SALAD1");
                Guid itemToAddID = Guid.NewGuid();
                LineItem LineItemToAdd = new LineItem() { Id = itemToAddID, ItemName = itemToAdd.ItemName, ItemNumber = itemToAdd.ItemNumber, Price = itemToAdd.Price, Quantity = 1, State = EntityState.Added, Guest = "42" };
                inv.LineItems.Add(LineItemToAdd);

                itemToAdd.ModifierGroups = InvApi.GetModiferGroupsForItem(InvContext, itemToAdd.ItemNumber);
                foreach (ModifierGroup ModGroup in itemToAdd.ModifierGroups)
                {
                    Console.WriteLine("ModifierGroup:{0}", ModGroup.ItemName);
                    Console.WriteLine("{0}", ModGroup.Prompt);
                    int i = 1;
                    if (ModGroup.Forced == false)
                    {
                        Console.WriteLine("{0} - NONE", i);
                        i++;
                    }
                    //NOTE THIS HAS CHANGED Modifier Items for Groups now are retrieved by calling GetModiferItemsForModiferGroups
                    ModGroup.ModifierItems = InvApi.GetModifierItemsForModifierGroup(InvContext, ModGroup.ItemNumber);
                    foreach (ModifierItem ModItem in ModGroup.ModifierItems)
                    {
                        Console.WriteLine("{0} - {1} : {2}", i, ModItem.ItemNumber, ModItem.ItemName);
                        i++;
                    }
                    string answer = Console.ReadLine();
                    if (answer.Length > 1)
                    {
                        Console.WriteLine("Invalid answer i Choose option 1 is chosen by default");
                        answer = "1";
                    }
                    else if (char.IsDigit(answer[0]) == false)
                    {
                        Console.WriteLine("Invalid answer i Choose option 1 chosen by defualt");
                        answer = "1";
                    }
                    InventoryItem dressing = InvApi.GetItem(InvContext, ModGroup.ModifierItems[Convert.ToInt32(answer) - 1].ItemNumber);
                    decimal Price = 0;
                    if (ModGroup.Charged == true) { Price = dressing.Price; }
                    inv.LineItems.Add(new LineItem() { Id = Guid.NewGuid(), ItemName = itemToAdd.ItemName, ItemNumber = dressing.ItemNumber, Price = dressing.Price, Quantity = 1, State = EntityState.Added, Guest = "42" });
                }

                // I created this item with the prompt description status set.
                itemToAdd = InvApi.GetItem(InvContext, "MiscItem");
                itemToAddID = Guid.NewGuid();
                LineItemToAdd = new LineItem() { Id = itemToAddID, ItemName = "Keychain", ItemNumber = itemToAdd.ItemNumber, Price = itemToAdd.Price, Quantity = 1, State = EntityState.Added, Guest = "11" };
                inv.LineItems.Add(LineItemToAdd);

                api.ModifyItems(context, inv.InvoiceNumber, inv.LineItems);
                api.UnLockInvoice(context, inv.InvoiceNumber);
                inv = api.GetInvoice(context, inv.InvoiceNumber);
                Console.WriteLine("The invoice has {0} guests", inv.PartySize);
                foreach (LineItem individualItem in inv.LineItems)
                {
                    Console.WriteLine("Guest {0} has ordered: {1}-{2}", individualItem.Guest, individualItem.ItemNumber, individualItem.ItemName);
                }

                //should show this invoice as locked by this station
                api.LockInvoice(context, inv.InvoiceNumber);
                List<OnHoldInfo> onHoldInfos = api.GetAllOnHoldInvoices(context);
                Console.WriteLine(String.Format("Retrieved {0} OnHoldInfo from GetAllOnHoldInvoices",
                                                    onHoldInfos.Count));
                foreach (OnHoldInfo onHoldInfo in onHoldInfos)
                {

                    foreach (OnHoldInfo OHI in onHoldInfos)
                    {
                        if (OHI.Locked == true)
                        {
                            Console.WriteLine(String.Format("Invoice {0} is locked by Station {1}",
                                                            OHI.InvoiceNumber, OHI.LockedByStation));
                        }
                    }
                }

                //checking locked status should be locked by this station
                inv = api.GetInvoice(context, inv.InvoiceNumber);
                if (inv.Locked == true)
                {
                    Console.WriteLine("Invoice #{0} is locked by Station: {1}", inv.InvoiceNumber.ToString(), inv.LockedByStation);
                }
                else
                {
                    Console.WriteLine("Invoice #{0} is unlocked", inv.InvoiceNumber.ToString());
                }

                api.UnLockInvoice(context, inv.InvoiceNumber);
                onHoldInfos.Clear();
                onHoldInfos = api.GetAllOnHoldInvoices(context);
                //should show this invoice as unlocked.
                Console.WriteLine(String.Format("Retrieved {0} OnHoldInfo from GetAllOnHoldInvoices",
                                                    onHoldInfos.Count));
                foreach (OnHoldInfo onHoldInfo in onHoldInfos)
                {

                    foreach (OnHoldInfo OHI in onHoldInfos)
                    {
                        if (OHI.Locked == true)
                        {
                            Console.WriteLine(String.Format("Invoice {0} is locked by Station {1}",
                                                            OHI.InvoiceNumber, OHI.LockedByStation));
                        }
                    }
                }
            }
            finally
            {
                Console.WriteLine("PRESS ENTER TO CONTINUE...");
                Console.ReadLine();
            }
        }