private void SetDefaultEditProperties() { EditID = EditingItem.ID; EditName = EditingItem.Name; EditCategory = Categories.SingleOrDefault(category => category.ID.Equals(EditingItem.ItemCategory.ID)); EditSalesPrice = EditingItem.SalesPrice; EditPurchasePrice = EditingItem.PurchasePrice; UpdateEditSuppliers(); EditSelectedSupplier = EditSuppliers.FirstOrDefault(); }
private void UpdateEditSuppliers() { EditSuppliers.Clear(); foreach (var supplier in EditingItem.Suppliers.OrderBy(supplier => supplier.Name)) { EditSuppliers.Add(new SupplierVM { Model = supplier }); } }
private Item MakeEditedItem() { var editedItem = new Item { ID = _editID, ItemCategory = _editCategory.Model, Name = _editName, PurchasePrice = _editPurchasePrice, SalesPrice = _editSalesPrice, Suppliers = new ObservableCollection <Supplier>() }; foreach (var supplier in EditSuppliers.ToList()) { editedItem.Suppliers.Add(supplier.Model); } return(editedItem); }