public static FuelVendor GetVendor(string name, bool create = true) { var provider = Vendors.FirstOrDefault((provider) => string.Compare(provider.Name, name, ignoreCase: true) == 0); if (provider == null && create) { provider = new FuelVendor { Name = name }; } return(provider); }
private void inventoryItemToDisplayItem(InventoryItem invItem, DisplayItem displayItem) { var invCat = invItem.InventoryCategoryId != null?InventoryCategories.FirstOrDefault(ic => ic.InventoryCategoryId == invItem.InventoryCategoryId) : null; var vendor = invItem.VendorId != null?Vendors.FirstOrDefault(v => v.VendorId == invItem.VendorId) : null; bool isNeeded = invItem.QuantityOnHand.GetValueOrDefault() < invItem.MinimumQuantity.GetValueOrDefault(); displayItem.Line1 = invItem.InventoryItemName; displayItem.Line2 = (invCat == null ? "" : invCat.CategoryName) + (vendor == null ? "" : $" - {vendor.VendorName}"); displayItem.Line3 = $"In Stock: {invItem.QuantityOnHand.GetValueOrDefault()} | Min Qty: {invItem.MinimumQuantity.GetValueOrDefault()} | Needed: {(isNeeded ? (invItem.MinimumQuantity.GetValueOrDefault() - invItem.QuantityOnHand.GetValueOrDefault()) : 0)}"; displayItem.Tag = invItem; displayItem.Tag2 = isNeeded ? Color.Red : Color.LightGray; }
public void LoadViewModel(_Proxy.tbl_PurchaseOrderHeader header) { TransID = header.TransID; VendorCode = header.Vendor; Vendor = Vendors.FirstOrDefault(x => x.vendor_code == VendorCode); IsPosted = header.IsPosted; WareHouseItem = WarehousesList.FirstOrDefault(x => x.WarehouseID == header.WareHouseID); try { DelivaryDate = header.DelivaryDate; CreationDate = (DateTime)header.CreationDate; } catch (Exception) { } //_client.CloseAsync(); }
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); }
/// <summary> /// Calls the service endpoint and gets all the available districts /// </summary> /// <param name="path"></param> /// <returns></returns> public async Task <bool> SetPrimaryVendorAsync(string path) { try { ProcessingSetPrimaryVendor = true; if (SelectedDistrict != null && SelectedVendor != null) { // Get the right object reference (the one bound to the Vendor listbox) var originalVendor = Vendors.FirstOrDefault(v => v.VendorId == SelectedDistrict.PrimaryVendor.VendorId); SelectedDistrict.PrimaryVendor = SelectedVendor; HttpResponseMessage response = await client.PutAsJsonAsync(path, SelectedDistrict).ConfigureAwait(false); if (response.IsSuccessStatusCode) { await RefreshVendors(); // Operation completed successfully return(true); } else { //If operation failed, set the original district back as primary SelectedDistrict.PrimaryVendor = originalVendor; } } return(false); } catch (Exception e) { log.Error(e.ToString()); return(false); } finally { ProcessingSetPrimaryVendor = false; } }
public Vendor GetVendor(int wid, int vid) { var vendor = Vendors.FirstOrDefault(v => v.VendorId == vid); return(vendor); }