public CatalogItem() { VendorAssignedProductId = string.Empty; Supplier = new Vendor(); Description = String.Empty; UnitCost = 0M; }
public bool IsValidProductId(Vendor vendor, string catalogId, string vendorAssignedProductId) { CatalogItem catalogItem = GetAllCatalogItems().Find( x => x.Id != catalogId && x.VendorAssignedProductId == vendorAssignedProductId && x.Supplier.Equals(vendor)); return catalogItem == null; }
public bool Contains(Vendor vendor, string vendorAssignedProductId) { foreach (var catalogItem in GetAllCatalogItems()) { if(catalogItem.Supplier.Equals(vendor) && catalogItem.VendorAssignedProductId.Equals(vendorAssignedProductId)) { return true; } } return false; }
public void LoadFromXml(XElement xElement) { xElement.LoadObjectFromXml(Catalog, "Catalog"); xElement.LoadObjectFromXml(Inventory, "Inventory"); Suppliers = new List<Vendor>(); foreach (XElement suppliersElement in xElement.Elements("Suppliers")) { foreach (XElement vendorElement in suppliersElement.Elements("Vendor")) { Vendor vendor = new Vendor(); vendor.LoadFromXml(vendorElement); Suppliers.Add(vendor); } } SetVendors(); SetInventoryItems(); }
private List<InventoryItem> GetInventoryItemsForVendor(Vendor vendor) { List<InventoryItem> inventoryItems = new List<InventoryItem>(); foreach (InventoryItem inventoryItem in Inventory.InventoryItems) { if (inventoryItem.CatalogItem.Supplier.Equals(vendor)) { inventoryItems.Add(inventoryItem); } } return inventoryItems; }
private List<CatalogItem> GetCatalogItemsForVendor(Vendor vendor) { List<CatalogItem> catalogItems = new List<CatalogItem>(); foreach (CatalogItem catalogItem in Catalog.BoxedItems) { if (catalogItem.Supplier.Equals(vendor)) { catalogItems.Add(catalogItem); } } foreach (CatalogItem catalogItem in Catalog.VolumeItems) { if (catalogItem.Supplier.Equals(vendor)) { catalogItems.Add(catalogItem); } } foreach (CatalogItem catalogItem in Catalog.CatalogItems) { if (catalogItem.Supplier.Equals(vendor)) { catalogItems.Add(catalogItem); } } return catalogItems; }
public void RemoveVendor(Vendor vendor) { List<InventoryItem> inventoryItemsToDelete = GetInventoryItemsForVendor(vendor); List<CatalogItem> catalogItemsToDelete = GetCatalogItemsForVendor(vendor); DeleteInventory(inventoryItemsToDelete); DeleteCatalog(catalogItemsToDelete); Suppliers.Remove(vendor); }
void AddVendor(Vendor vendor) { lbxVendors.Items.Add(vendor); cbxCatalogVendor.Items.Add(vendor); _productGraph.Suppliers.Add(vendor); }
void SaveVendor() { Vendor vendor = FindVendor(txtVendorId.Text); if(vendor == null) { vendor = CreateVendor(); AddVendor(vendor); } _currentVendor = vendor; FillVendorFromForm(vendor); LoadVendors(); }
void LoadVendors() { lbxVendors.Items.Clear(); cbxCatalogVendor.Items.Clear(); foreach(Vendor vendor in _productGraph.Suppliers) { lbxVendors.Items.Add(vendor); cbxCatalogVendor.Items.Add(vendor); } lbxVendors.SelectedItem = _currentVendor; _currentVendor = null; }
void FillVendorFromForm(Vendor vendor) { vendor.Name = txtVendorName.Text; vendor.PhoneNumber = txtVendorPhoneNo.Text; vendor.PointOfContact = txtVendorContactPerson.Text; vendor.Comments = txtVendorComments.Text; Address address = vendor.Addresses[0]; address.Street = txtVendorStreet.Text; address.City = txtVendorCity.Text; address.State = txtVendorState.Text; address.Zip = txtVendorZip.Text; }
Vendor CreateVendor() { Vendor newVendor = new Vendor(); Address address = new Address(); newVendor.Addresses.Add(address); return newVendor; }
//Creates a dummy file private void WriteFile(string filePath) { Model.Location tempLocation = new Location {Description = "Shop", Name = "Shop"}; Model.Location warehouseLocation = new Location{Description = "Storage Room", Name = "Storage"}; Vendor gracoVendor = new Vendor { Addresses = new List<Address> { new Address{City = "Temple", State = "TX", Street = "4001 North Point Blvd", Zip = "76502"} }, Id = "Graco", Name = "Graco", PhoneNumber = "254 555-1234", PointOfContact = "Jimmy Walker" }; ProductGraph productGraph = new ProductGraph(); productGraph.Inventory = new Inventory(); productGraph.Catalog = new Catalog(); productGraph.Inventory.Locations.Add(tempLocation); productGraph.Inventory.Locations.Add(warehouseLocation); productGraph.Inventory.InventoryItems.Add( new InventoryItem{Id = "0000001", Location = tempLocation, ReOrderPoint = 10, ReOrderQuantity = 10, QtyOnHand = 21} ); productGraph.Inventory.InventoryItems.Add( new InventoryItem { Id = "0000002", Location = warehouseLocation, ReOrderPoint = 10, ReOrderQuantity = 10, QtyOnHand = 21 } ); productGraph.Catalog.CatalogItems.Add( new CatalogItem() { Description = "Mat 32x40, Chinese Red, White Core", Supplier = gracoVendor, UnitCost = 10m, VendorAssignedProductId = "132343" }); productGraph.Catalog.CatalogItems.Add(new CatalogItem { Description = "Mat 32x40, Sky Blue, White Core", Supplier = gracoVendor, UnitCost = 10m, VendorAssignedProductId = "132343" }); productGraph.Catalog.BoxedItems.Add(new BoxedItem { Description = "Glass Clear, 16in x 20in", Supplier = gracoVendor, UnitCost = 10m, VendorAssignedProductId = "000000224324", BoxCost = 40, UnitsInBox = 8 }); productGraph.Catalog.BoxedItems.Add(new BoxedItem { Description = "Glass Clear, 32in x 40in", Supplier = gracoVendor, VendorAssignedProductId = "00000003", BoxCost = 80, UnitsInBox = 4 }); productGraph.Catalog.BoxedItems.Add(new BoxedItem { Description = "Framing Nails 1/8in", Supplier = gracoVendor, VendorAssignedProductId = "00000003", BoxCost = 25, UnitsInBox = 12 }); productGraph.Catalog.VolumeItems.Add(new VolumeItem { Description = "Gold Decor Molding 4in Wide", Supplier = gracoVendor, UnitCost = 10m, VendorAssignedProductId = "00000005", MininumVolume = 4, UnitOfMeasure = "Ft" }); productGraph.Catalog.VolumeItems.Add(new VolumeItem { Description = "Gold Decor Molding 2in Wide", Supplier = gracoVendor, UnitCost = 5m, VendorAssignedProductId = "00000007", MininumVolume = 4, UnitOfMeasure = "Ft" }); productGraph.Suppliers = new List<Vendor>{gracoVendor}; List<string> xml = productGraph.ProduceXml("", true); using(StreamWriter writer = new StreamWriter(filePath)) { foreach (string line in xml) { writer.WriteLine(line); } } }