/// <summary>
        /// Method for managers see the inventory of the location
        /// </summary>
        public void viewInventory()
        {
            string inventoryInput;
            string amount;

            do
            {
                List <models.Inventory> currentInventory = inventoryService.GetInventoriesByLocationId(manager.LocationId);
                Console.WriteLine("\nSelect which product to replenish");
                foreach (var i in currentInventory)
                {
                    models.Product product = productService.GetProductById(i.ProductId);
                    Console.WriteLine($"Id: {product.Id}.\t Name: {product.GameName}, Price: {product.Price}, Quantity: {i.Quantity}");
                }

                Console.WriteLine("Press [0] to go back.");

                inventoryInput = Console.ReadLine();

                if (inventoryInput.Equals("0"))
                {
                    break;
                }

                models.Product selectedProduct = productService.GetProductById(int.Parse(inventoryInput));

                Console.WriteLine($"\nPlease enter how many game's of {selectedProduct.GameName} you would like to add to inventory");

                amount = Console.ReadLine();

                inventoryService.AddToInventory(manager.LocationId, selectedProduct.Id, int.Parse(amount));
            } while(!inventoryInput.Equals("0"));
        }
Exemplo n.º 2
0
        public void AddToInventory_GivenANewItem_AddsToDatabase()
        {
            // arrange
            InventoryItem item = new InventoryItem()
            {
                ID = 100
            };
            Mock <IInventoryItemRepository> mockInventoryRepo = new Mock <IInventoryItemRepository>();
            InventoryService sut = new InventoryService(mockInventoryRepo.Object, null, null, null, null);

            // act
            sut.AddToInventory(item);

            // assert
            mockInventoryRepo.Verify(r => r.AddToInventory(It.Is <InventoryItem>(i => i.ID == 100)), Times.Once());
        }