public static AMCViewModel Create(int itemId, int storeId, int unitid,int amcRange, DateTime endDate)
 {
     var vwGetAllItemsRepository =new vwGetAllItemsRepository();
     var amcrepo = new AmcReportRepository();
     var allItemIdsonamc = amcrepo.AllAmcReport().SingleOrDefault(m => m.ItemID == itemId && m.StoreID == storeId && m.UnitID ==unitid);
     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),
                             UnitID = unitid,
                         };
     AddorUpdateAmc(itemId, storeId, unitid,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 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);
        }