Example #1
0
        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));
        }
Example #2
0
        public void CanFindStockItemByIdAndIncludeItemEntries()
        {
            var results = _stockData.GetStockItemByIdWithItemEntries(51);

            WriteLog();
            Assert.IsTrue(_log.Contains("ItemEntries"));
            Assert.AreNotEqual(0, results.ItemEntries.Count());
        }