public void CheckAllOrders()
        {
            List <StoreDto> listOfStores = GetAllStores();
            cartAPI         api          = new cartAPI();

            //UpsDbMethods upsDb = new UpsDbMethods();
            //bool rer = upsDb.ReadAllUpsData();
            //Calls the authorization url
            if (listOfStores != null)
            {
                foreach (var st in listOfStores)
                {
                    List <string> OrderStatuses = GetAllOrderStatusTextByStore(st.Id);
                    foreach (var orderStatuse in OrderStatuses)
                    {
                        try
                        {
                            string lastRun = String.Format("{0:MM/dd/yyyy}", st.LastRun);
                            //string status = GetOrderStatusText(st.OrderStatus);
                            XDocument xdoc = XDocument.Parse(api.getOrder(st.Url, st.ApiKey, 100, 1, false, "", orderStatuse, lastRun, "", "").OuterXml);
                            if (!xdoc.Root.Name.LocalName.Equals("Error"))
                            {
                                var OrderInformation = from x in xdoc.Descendants("Order")
                                                       select new
                                {
                                    //---OrderInformation
                                    OrderID         = x.Descendants("OrderID").First().Value,
                                    Total           = x.Descendants("Total").First().Value,
                                    InvoiceNumber   = x.Descendants("InvoiceNumber").First().Value,
                                    CustomerID      = x.Descendants("CustomerID").First().Value,
                                    OrderStatus     = x.Descendants("OrderStatus").First().Value,
                                    DateStarted     = x.Descendants("DateStarted").First().Value,
                                    LastUpdate      = x.Descendants("LastUpdate").First().Value,
                                    OrderComment    = x.Descendants("Comments").Descendants("OrderComment").First().Value,
                                    OrderIntComment = x.Descendants("Comments").Descendants("OrderInternalComment").First().Value,
                                    OrderExtComment = x.Descendants("Comments").Descendants("OrderExternalComment").First().Value,
                                    Shippinginfo    = x.Descendants("ShippingInformation").Descendants("Shipment"),
                                    ItemInfo        = x.Descendants("ShippingInformation").Descendants("OrderItems").Descendants("Item"),
                                    Email           = x.Descendants("BillingAddress").Descendants("Email").First().Value
                                };
                                var result = orders.CreateOrdersFromStore(OrderInformation, st.Id);
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error Getting Store: " + st.Name + " Error:" + ex.Message + " at: " + DateTime.Now);
                        }
                    }
                    UpdateStoreLastRun(st.Id);
                }
            }
        }
        public string CheckForAnOrder(int storeId, string invoice)
        {
            if (CheckIfOrderExist(invoice))
            {
                return("Invoice " + invoice + " is already on the records");
            }
            cartAPI   api   = new cartAPI();
            var       store = GetStoreById(storeId);
            XDocument xdoc  = XDocument.Parse(api.getOrder(store.Url, store.ApiKey, 100, 1, false, invoice, "", "", "", "").OuterXml);

            if (!xdoc.Root.Name.LocalName.Equals("Error"))
            {
                var OrderInformation = from x in xdoc.Descendants("Order")
                                       select new
                {
                    //---OrderInformation
                    OrderID         = x.Descendants("OrderID").First().Value,
                    Total           = x.Descendants("Total").First().Value,
                    InvoiceNumber   = x.Descendants("InvoiceNumber").First().Value,
                    CustomerID      = x.Descendants("CustomerID").First().Value,
                    OrderStatus     = x.Descendants("OrderStatus").First().Value,
                    DateStarted     = x.Descendants("DateStarted").First().Value,
                    LastUpdate      = x.Descendants("LastUpdate").First().Value,
                    OrderComment    = x.Descendants("Comments").Descendants("OrderComment").First().Value,
                    OrderIntComment = x.Descendants("Comments").Descendants("OrderInternalComment").First().Value,
                    OrderExtComment = x.Descendants("Comments").Descendants("OrderExternalComment").First().Value,
                    Shippinginfo    = x.Descendants("ShippingInformation").Descendants("Shipment"),
                    ItemInfo        = x.Descendants("ShippingInformation").Descendants("OrderItems").Descendants("Item"),
                    Email           = x.Descendants("BillingAddress").Descendants("Email").First().Value
                };
                var result = orders.CreateOrdersFromStore(OrderInformation, store.Id);

                return("Invoice " + invoice + " has been added succesfully");
            }
            else
            {
                return("Invoice " + invoice + " was not found in the selected store. Try another store");
            }
        }