public ActionResult Index(DateTime begin, DateTime end, int method, int depth, List <double> productSamples, List <double> employeeSamples) { IEnumerable <ProductDTO> productsDTO = forecastService.GetProducts(); var mapper = new MapperConfiguration(config => config.CreateMap <ProductDTO, ProductViewModel>()).CreateMapper(); var products = mapper.Map <IEnumerable <ProductDTO>, List <ProductViewModel> >(productsDTO); double[,] resultProductSamples = new double[products.Count(), end.Year - begin.Year + 1]; double[,] resultEmployeeSamples = new double[products.Count(), end.Year - begin.Year + 1]; double[,] resultPerfomanceSamples = new double[products.Count(), end.Year - begin.Year + 1]; int counter = 0; for (int i = 0; i < products.Count(); i++) { for (int j = 0; j < end.Year - begin.Year + 1; j++) { resultProductSamples[i, j] = productSamples[counter]; resultEmployeeSamples[i, j] = employeeSamples[counter]; resultPerfomanceSamples[i, j] = productSamples[counter] / employeeSamples[counter]; counter++; } } IUnitOfWork connection = new EFUnitOfWork("Data Source = (LocalDB)\\MSSQLLocalDB; " + "AttachDbFilename = '|DataDirectory|\\mtaInfo.mdf'; Integrated Security = True"); if (method == 2) { forecastService = new MovingAverageForecasstService(connection); } if (method == 3) { forecastService = new ExponentialSmoothingForecastService(connection); } Forecast[] productForecast = forecastService.Forecasting(begin, end, depth, resultProductSamples); Forecast[] perfomanceForecast = forecastService.Forecasting(begin, end, depth, resultPerfomanceSamples); double[] employeeForecast = new double[productForecast.Length]; for (int i = 0; i < employeeForecast.Length; i++) { if (perfomanceForecast[i].forecast == 0) { double min = 1; for (int j = 0; j < perfomanceForecast.Length; j++) { if (perfomanceForecast[j].forecast == perfomanceForecast[i].forecast) { continue; } if (perfomanceForecast[j].forecast < min) { min = perfomanceForecast[j].forecast; } } perfomanceForecast[i].forecast = min; } else { employeeForecast[i] = productForecast[i].forecast / perfomanceForecast[i].forecast; } } double[] deficit = new double[products.Count()]; for (int i = 0; i < deficit.Length; i++) { deficit[i] = employeeForecast[i] - resultEmployeeSamples[i, end.Year - begin.Year]; } ViewBag.productForecast = productForecast; ViewBag.employeeForecast = employeeForecast; ViewBag.perfomanceForecast = perfomanceForecast; ViewBag.resultProductSamples = resultProductSamples; ViewBag.resultPerfomanceSamples = resultPerfomanceSamples; ViewBag.resultEmployeeSamples = resultEmployeeSamples; ViewBag.deficit = deficit; ViewBag.begin = begin; ViewBag.end = end; return(View("~/Views/Home/Forecast.cshtml", products)); }