public static void OptimizedCreate(int itemId, string fullItemName, int storeId, int amcRange, DateTime endDate)
        {
            var vwGetAllItemsRepository = new vwGetAllItemsRepository();
            var startDate = endDate.Subtract(TimeSpan.FromDays(amcRange * 30));

            AddAMC(itemId, fullItemName, storeId, amcRange, endDate, startDate);
        }
        public static AMCViewModel Create(int itemId, int storeId, int amcRange, DateTime endDate)
        {
            var vwGetAllItemsRepository = new vwGetAllItemsRepository();
            var amcrepo         = new AmcReportRepository();
            var allItemIdsonamc = amcrepo.AllAmcReport().SingleOrDefault(m => m.ItemID == itemId && m.StoreID == storeId);
            var products        = vwGetAllItemsRepository.AllItems().SingleOrDefault(m => m.ID == itemId);
            var startDate       = endDate.Subtract(TimeSpan.FromDays(amcRange * 30));
            var viewModel       = new AMCViewModel
            {
                ItemID          = itemId,
                StoreID         = storeId,
                AmcRange        = amcRange,
                IssueInAmcRange = Builder.CalculateTotalConsumptionWithoutDOS(itemId, storeId, startDate, endDate),
                DaysOutOfStock  = Builder.CalculateStockoutDays(itemId, storeId, startDate, DateTime.Now),
                AmcWithDos      = Builder.CalculateAverageConsumption(itemId, storeId, startDate, endDate, CalculationOptions.Monthly),
                IssueWithDOS    = Builder.CalculateTotalConsumptionAMC(itemId, storeId, startDate, endDate)
            };

            AddorUpdateAmc(itemId, storeId, amcRange, endDate, amcrepo, viewModel, allItemIdsonamc, startDate);
            if (products != null)
            {
                viewModel.FullItemName = products.FullItemName;
            }
            viewModel.AmcWithoutDos = Convert.ToDouble(Builder.CalculateTotalConsumptionWithoutDOS(itemId, storeId, startDate, endDate)) / Convert.ToDouble(viewModel.AmcRange);
            return(viewModel);
        }
        public static List <ItemViewModel> Create(IEnumerable <Item> items)
        {
            var collection = new List <ItemViewModel>();
            var vwGetAllItemsRepository = new vwGetAllItemsRepository();

            foreach (var item in items)
            {
                var viewModel = new ItemViewModel(item);
                var products  = vwGetAllItemsRepository.FindBy(viewModel.ItemId).SingleOrDefault();
                if (products != null)
                {
                    viewModel.FullItemName = products.FullItemName;
                }
                collection.Add(viewModel);
            }
            return(collection);
        }