public static int CalculateStockoutDays(int itemId,int storeId, DateTime startDate, DateTime endDate)
        {
            var repository = new StockoutRepository();
            var stockoutsInRange = repository.GetAll().Where(m => m.ItemID == itemId && m.StoreID ==storeId ).Where(m => m.StartDate < endDate && (m.EndDate == null || m.EndDate > startDate)).ToList();
            //var stockoutsOutOfRange = repository.GetAll().Where(m => m.ItemID == itemId && m.StoreID == storeId).Where(m => m.StartDate > startDate).ToList();

                foreach (var stockout in stockoutsInRange)
                {
                    if (stockout.StartDate < startDate)
                        stockout.StartDate = startDate;
                    if (stockout.EndDate == null)
                        stockout.EndDate = DateTime.Now;
                    else if (stockout.EndDate > endDate)
                        stockout.EndDate = endDate;
                }
                return Enumerable.Sum(stockoutsInRange, m => m.NumberOfDays);
        }