Exemplo n.º 1
0
        public ActionResult HistoryQuery(StockItemHistoryQuery query)
        {
            var stockItem = stockItemService.GetById(query.StockItemId);
            var history   = stockItemService.GetHistory(stockItem, query.Start, query.End).ToList();
            var viewData  = new StockItemHistoryViewData
            {
                StockItem = stockItem,
                History   = history,
                Start     = query.Start,
                End       = query.End
            };

            return(View("History", viewData));
        }
Exemplo n.º 2
0
        public void GetHistory_should_get_a_stockItems_history_between_the_given_dates()
        {
            var stockItem = StockItem.Create("widget", "small", new DateTime(2011, 1, 1), user);
            var history1  = stockItem.ReceiveStock(10, new DateTime(2011, 2, 1), user);
            var history2  = stockItem.Dispatch(2, 1, new DateTime(2011, 3, 1), user);
            var history3  = stockItem.Dispatch(2, 2, new DateTime(2011, 4, 1), user);

            stockItem.Dispatch(2, 3, new DateTime(2011, 5, 1), user);

            var start = new DateTime(2011, 2, 1);
            var end   = new DateTime(2011, 4, 1);

            historyRepository.GetAllDelegate = () => stockItem.History.AsQueryable();

            var history = stockItemService.GetHistory(stockItem, start, end);

            history.Count().ShouldEqual(3);
            history.ElementAt(0).ShouldBeTheSameAs(history1);
            history.ElementAt(1).ShouldBeTheSameAs(history2);
            history.ElementAt(2).ShouldBeTheSameAs(history3);
        }