private void PlaceOrder() { Console.WriteLine("This is your current order"); Console.WriteLine(_currentLocation.ToString()); Console.WriteLine(_openOrder.ToString()); bool repeat = true; do { Console.WriteLine("Would you like to place the order? [y/n]"); string input = Console.ReadLine().ToLower(); if (input == "y") { repeat = false; using (var log = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.Console().WriteTo.File("../logs/logs.txt", rollingInterval: RollingInterval.Day).CreateLogger()) { try { //first, close the order _openOrder.Closed = true; //and then, create the order int createdId = _orderBL.CreateOrder(_openOrder).Id; //Now we need to create line items associated to the order foreach (LineItem item in _openOrder.LineItems) { item.OrderId = createdId; _orderBL.CreateLineItem(item); } //update the store's inventory after the successful placement of the order by getting all the inventory of the location of the order List <Inventory> allInventory = _locationBL.GetLocationInventory(_currentLocation.Id); //and then update the inventory of the order and persist it to the DB foreach (LineItem lineItem in _openOrder.LineItems) { Inventory boughtItem = allInventory.Find(invenItem => invenItem.Product.Id == lineItem.Product.Id); boughtItem.Quantity -= lineItem.Quantity; _locationBL.UpdateInventoryItem(boughtItem); } Console.WriteLine("Order placed successfully!"); _openOrder = new Order { CustomerId = _currentCustomer.Id, LocationId = _currentLocation.Id, LineItems = new List <LineItem>() }; } catch (Exception ex) { log.Warning(ex.Message); } } } else if (input == "n") { repeat = false; return; } else { Console.WriteLine("I don't understand your input, please try again"); } } while(repeat); }