コード例 #1
0
 public HttpResponseMessage Post([FromBody] InventoryItem inventoryItem)
 {
     if (_repo.AddInventoryItem(inventoryItem) && _repo.Save())
     {
         return(Request.CreateResponse(HttpStatusCode.Created, inventoryItem));
     }
     return(Request.CreateResponse(HttpStatusCode.BadRequest));
 }
コード例 #2
0
        public Task <bool> AddInventory(Inventory inventory)
        {
            bool isprodAdded = _inventoryRepository.AddInventoryItem(inventory);

            if (isprodAdded)
            {
                return(Task.FromResult(isprodAdded));
            }
            return(Task.FromResult <bool>(false));
        }
コード例 #3
0
        public void AddIngredientToFridge(InventoryItem inventoryItem)
        {
            var existingInventoryItem = _inventoryRepository.Get(inventoryItem.Name);

            if (existingInventoryItem == null)
            {
                _inventoryRepository.AddInventoryItem(inventoryItem);
                return;
            }

            inventoryItem.Quantity += inventoryItem.Quantity;
            _inventoryRepository.UpdateInventoryItem(inventoryItem);
        }