Example #1
0
        public static async Task <Login> FindLogin(string loginName)
        {
            try
            {
                await Task.Delay(50).ConfigureAwait(false);

                var client = new AzureClient();
                var login  = await client.GetLogin(loginName);

                return(login);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public static async Task <PurchaseOrderDirectory> LoadPurchaseOrderDirectory()
        {
            await Task.Delay(50).ConfigureAwait(false);

            var directory = new PurchaseOrderDirectory();

            try
            {
                var azureClient = new AzureClient();

                var poList = await azureClient.GetPOs(true);

                var purchaseOrders = poList as PurchaseOrder[] ?? poList.ToArray();

                foreach (var purchaseOrder in purchaseOrders)
                {
                    var poKey = purchaseOrder.Id;
                    purchaseOrder.Items =
                        new ObservableCollection <PurchaseOrderItem>(await azureClient.GetPoItems(poKey));
                    var index = 0;
                    foreach (var item in purchaseOrder.Items)
                    {
                        item.Index         = index;
                        item.PurchaseOrder = purchaseOrder;
                        index++;
                    }
                }

                directory.PurchaseOrders = new ObservableCollection <PurchaseOrder>(purchaseOrders);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(directory);
        }