async Task ExecuteLoadVendorsCommand() { if (IsBusy) { return; } IsBusy = true; try { Vendors.Clear(); IEnumerable <Vendor> vendors = await App.Database.GetDataAsync <Vendor>(); foreach (var vendor in vendors) { Vendors.Add(vendor); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private void FillBasicCollections() { var serviceClient = new CRUD_ManagerServiceClient(); serviceClient.GetVendorsCompleted += (a, b) => { try { foreach (var item in b.Result) { Vendors.Add(item); } } catch (Exception ex) { var err = new ErrorWindow(ex); err.Show(); } }; serviceClient.GetAllBrandsCompleted += (s, e) => { try { foreach (var item in e.Result) { Brands.Add(item); } } catch (Exception ex) { var err = new ErrorWindow(ex); err.Show(); } }; serviceClient.GetAllBrandsAsync(LoggedUserInfo.Iserial); serviceClient.GetAllSeasonsCompleted += (s, e) => { foreach (var item in e.Result) { Seasons.Add(item); } }; serviceClient.GetAllSeasonsAsync(); }
Vendor PrepareVendor(string[] parts) { var vendorId = parts[1]; var currentVendor = Vendors.FirstOrDefault(x => x.VendorId == vendorId); if (currentVendor == null) { currentVendor = new Vendor(); currentVendor.Number = parts[0]; currentVendor.VendorId = parts[1]; currentVendor.Name = parts[3]; currentVendor.INN = parts[11]; currentVendor.KPP = parts[12]; Vendors.Add(currentVendor); } return(currentVendor); }
private static void LoadVendors(IEnumerable <VendorData> vendorData) { foreach (var data in vendorData) { Vendor vendor = new Vendor() { Stock = new Dictionary <string, int>(), AccountBalance = new List <Money>() }; string[] productsAndQuantitiesInStringsArray = data.ProductIdsAndQuantities.Split(';'); foreach (var productQuantity in productsAndQuantitiesInStringsArray) { string[] productAndQuantityArray = productQuantity.Split(':'); vendor.Stock.Add(ProductsDictionary[productAndQuantityArray[0]].Name, int.Parse(productAndQuantityArray[1])); } string[] accountBalanceArray = data.AccountBalanceString.Split(';'); for (int i = 0; i < accountBalanceArray.Length; i++) { vendor.AccountBalance.Add(MoniesDictionary[accountBalanceArray[i]]); } Vendors.Add(data.Id, vendor); } }
async System.Threading.Tasks.Task ExecuteLoadInventoryCommand(bool reload) { if (IsBusy) { return; } if (!IsRefreshing) { IsBusy = true; } try { if (Vendors.Count < 1) { Vendors.Add(new Vendor() { VendorName = "(All)" }); OriginalVendors = (await DataService.GetItemsAsync <Vendor>("vendors")).Data; OriginalVendors.OrderBy(v => v.VendorName).ToList().ForEach(d => Vendors.Add(d)); } if (InventoryCategories.Count < 1) { InventoryCategories.Add(new InventoryCategory() { CategoryName = "(All)" }); OriginalCategories = (await DataService.GetItemsAsync <InventoryCategory>("inventoryCategories")).Data; OriginalCategories.OrderBy(c => c.CategoryName).ToList().ForEach(d => InventoryCategories.Add(d)); } Inventory.Clear(); if (reload || _inventoryItems == null) { _inventoryItems = (await DataService.GetItemsAsync <InventoryItem>("inventoryItems")).Data; } foreach (var item in _inventoryItems .Where(i => SelectedVendor == null || SelectedVendor.VendorId == null || i.VendorId == SelectedVendor.VendorId) .Where(i => SelectedCategory == null || SelectedCategory.InventoryCategoryId == null || i.InventoryCategoryId == SelectedCategory.InventoryCategoryId) .OrderBy(i => i.InventoryItemName)) { bool isNeeded = item.QuantityOnHand.GetValueOrDefault() < item.MinimumQuantity.GetValueOrDefault(); if (!isNeeded && NeededOnly) { continue; } var dispItem = new DisplayItem(); inventoryItemToDisplayItem(item, dispItem); Inventory.Add(dispItem); } } catch (Exception ex) { IsBusy = false; IsRefreshing = false; ExceptionHelper.ShowException(ex); } finally { IsRefreshing = false; IsBusy = false; } }
public virtual void AddVendor(WorkgroupVendor workgroupVendor) { workgroupVendor.Workgroup = this; Vendors.Add(workgroupVendor); }