public IHttpActionResult AddItemEntry(int id, ItemEntry item) { if (id != item.StockItemId) { return(BadRequest()); } var stockItem = _stockRepo.GetStockItemByIdWithItemEntries(id); if (stockItem == null) { return(NotFound()); } try { stockItem.InsertNewItemEntry(item.Quantity, item.PricePerUnit, item.ExpirationDate, item.Temperature); _stockRepo.UpdateItemsForExistingStock(stockItem); Hub.Clients.Group("Restaurant").addItemEntry(item); } catch (DbUpdateConcurrencyException) { if (!StockItemExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void CanUpdateItemEntriesForStockItem() { //get stock item var stockItem = _stockData.GetStockItemByIdWithItemEntries(51); //add new item stockItem.InsertNewItemEntry(1, 2.50m, DateTime.Now.AddDays(1)); //update stock item _stockData.UpdateItemsForExistingStock(stockItem); Assert.IsTrue(_log.Contains("ItemEntries")); }