/// <summary>
        /// Method that converts Data Access Inventory object to a Business Logic Inventory object for interacting with UI
        /// </summary>
        /// <param name="inventory"></param>
        /// <returns>Business Logic Inventory</returns>

        private BL.Inventory ParseInventory(Inventory inventory)
        {
            using var context = GetContext();
            BL.Inventory i = new BL.Inventory()
            {
                Stock = inventory.Stock,
                Prod  = ParseProduct(context.Product.Single(p => p.ProductId == inventory.ProductId))
            };
            return(i);
        }
        /// <summary>
        /// Method that converts Business Logic Inventory Object to Data Access Inventory Object for DB interaction
        /// </summary>
        /// <param name="inventory"></param>
        /// <returns>Data Access Inventory</returns>
        private Inventory ParseInventory(BL.Inventory inventory)
        {
            using var context = GetContext();
            Inventory i = new Inventory
            {
                Stock   = inventory.Stock,
                Product = context.Product.First(p => p.Name == inventory.Prod.Name)
            };

            return(i);
        }
        /// <summary>
        /// Method that updates the inventory in DB
        /// </summary>
        /// <param name="inv"></param>
        /// <param name="local"></param>
        public void UpdateInventory(BL.Inventory inv, BL.Location local)
        {
            //updates store inventory and also rejects orders with too high quantity
            using var context = GetContext();
            if (inv.Stock < 1)
            {
                throw new BL.InvalidStockException("Quantity should be greater than 0");
            }
            Inventory item = context.Inventory.Single(i => i.LocationId == context.Location.Single(l => l.BranchName == local.BranchName).LocationId&& i.ProductId == context.Product.First(p => p.Name == inv.Prod.Name).ProductId);

            if (inv.Stock > item.Stock)
            {
                throw new InsufficientStockException("Stock Insufficient");
            }
            item.Stock = item.Stock - inv.Stock;
            context.SaveChanges();
            Log.Information("Inventory Updated");
        }