public ActionResult GenerateSummary() { var personalData = TempData.GetPersonalDataList(); personalData.ForEach(pd => pd.Requirements = _requirementsProvider.GetRequirements(pd, 5)); var bannedSubCategories = GetBannedSubCategories(); var bannedMainCategories = GetBannedMainCategories(); var recipes = _recipeProvider.GetRecipes().Where(r => !bannedMainCategories.Contains(r.MainCategory) && !bannedSubCategories.Contains(r.SubCategory)).ToList(); TempData.SavePersonalDataList(personalData); var nsgaSolver = _nsgaSolverFactory.GetGroupDietSolver(recipes, personalData, TempData.GetSettings().NsgaConfiguration); var nsgaResult = nsgaSolver.Solve(); TempData.SaveLog(nsgaResult.Log); TempData.SaveNsgaResult(nsgaResult); var viewModelBuilder = new GroupDietViewModelBuilder(); var dietsViewModel = viewModelBuilder.Build(nsgaResult, personalData); TempData.SaveGroupDietsResultViewModel(dietsViewModel); return(RedirectToAction("Summary")); }
private static List <PersonalData> GetPersonalData() { var rp = new RequirementsProvider(); var pd = new List <PersonalData> { new PersonalData { Age = 25, Gender = Gender.M, Height = 185, Weight = 85, Pal = 1.5, Id = 0, }, new PersonalData { Age = 22, Gender = Gender.K, Height = 160, Weight = 50, Pal = 1.8, Id = 1 }, new PersonalData { Age = 35, Gender = Gender.M, Height = 220, Weight = 110, Pal = 1.9, Id = 2, }, new PersonalData { Age = 44, Gender = Gender.K, Height = 170, Weight = 65, Pal = 1.3, Id = 3 } }; var preferences = Getpreferences(); pd.ForEach(d => d.Requirements = rp.GetRequirements(d, 5)); pd.ForEach(d => d.Preferences = preferences); return(pd); }