public IActionResult Results(ConsumptionEventSearchModel searchModel) { searchModel.ItemsPerPage = searchModel.ResultsPerPage; var query = new ConsumptionEventSearchQueryEntity() { InventoryItemId = searchModel.InventoryItemId, DateCreatedStart = searchModel.DateCreatedStart, DateCreatedEnd = searchModel.DateCreatedEnd, ConsumedBy = searchModel.ConsumedBy, OrderNumber = searchModel.OrderNumber, ResultsPerPage = searchModel.ResultsPerPage }; var results = _eventService.FindConsumptionSearchResults(query); var filterResults = results .Skip((searchModel.CurrentPage - 1) * searchModel.ItemsPerPage) .Take(searchModel.ItemsPerPage) .ToList(); var presentation = new ConsumptionEventSearchResultsModel { CurrentPage = searchModel.CurrentPage, Events = filterResults, ItemsPerPage = searchModel.ResultsPerPage, TotalItems = (results.Count() > 0 ? results.Count() : 1) }; return(View(presentation)); }
public IActionResult Results(ConsumptionEventSearchModel searchModel) { searchModel.ItemsPerPage = searchModel.ResultsPerPage; var results = _eventService.FindConsumptionSearchResults(searchModel); var filterResults = results .Skip((searchModel.CurrentPage - 1) * searchModel.ItemsPerPage) .Take(searchModel.ItemsPerPage) .ToList(); var presentation = new ConsumptionEventSearchResultsModel { CurrentPage = searchModel.CurrentPage, Events = filterResults, ItemsPerPage = searchModel.ResultsPerPage, TotalItems = (results.Count() > 0 ? results.Count() : 1) }; return(View(presentation)); }