public static void addItemType() { using (var db = new ItemContext()) { // Create and save a new Item Type Console.Write("Enter a name for a new Item Type: "); var itemName = Console.ReadLine(); Console.Write("Enter Item Quantity: "); var qty = int.Parse(Console.ReadLine()); var newItemType = new ItemTypes { ItemName = itemName, Quantity = qty }; db.ItemTypes.Add(newItemType); db.SaveChanges(); for(int i=0; i < qty; i++) { var newItem = new Items { ItemTypeId = newItemType.ItemTypeId }; db.Items.Add(newItem); db.SaveChanges(); } printItemTypes(); } }
public static void addInvLoc() { using (var db = new ItemContext()) { Console.Write("Enter a name for a new Inventory Location: "); var locationName = Console.ReadLine(); var newLocation = new InventoryLocations { InventoryLocationName = locationName }; db.InventoryLocations.Add(newLocation); db.SaveChanges(); var query = from b in db.InventoryLocations orderby b.InventoryLocationName select b; foreach (var location in query) { Console.WriteLine(location.InventoryLocationName); } } }