//int[] scenarios //for EditEntities get //top 1/6 to add util descriptions private StrategyForExpectedResponse populateStrategyForExpectedResponse(ArchitecturalStrategy strategy, IQueryable<Scenario> affiliatedScenarios) { var scenarioRepository = new ScenarioRepository(); var respStrat = new StrategyForExpectedResponse(); respStrat.ScenariosForStratUtil = new List<ScenariosForStratUtil>(); respStrat.ID = strategy.ID; respStrat.Name = strategy.Name; var sToAdd = new ScenariosForStratUtil(); //add scenarios to strategy foreach (var s in affiliatedScenarios) { //get xWalkItem for Scenario --for Expected Response ExpectedUtility ExpectedUtilityItem = scenarioRepository.Get_ExpectedUtility(respStrat.ID, s.ID); //Scenario s = scenarioRepository.GetByID(sID); respStrat.ScenariosForStratUtil.Add(new ScenariosForStratUtil {//s = a scenario scenarioID = s.ID, Name = s.Name, Description = s.Description.Trim(), expectedUtilID = ExpectedUtilityItem.ID, ExpectedUtilityDescription = ExpectedUtilityItem.ExpectedUtilityDescription == null ? null : ExpectedUtilityItem.ExpectedUtilityDescription.Trim(), ExpectedUtility = ExpectedUtilityItem.ExpectedUtility1, Utilities = new List<Utility>(), }); //add utilties best/worse/current/desired //order utilities according to QualityAttribute order var utils = s.Utilities.OrderBy(x => x.QualityAttributeResponseType.Order); foreach (var u in utils) {//Utilities to Scenario //add utilities to last added scenario in ScenariosForUtilUpdate list respStrat.ScenariosForStratUtil[respStrat.ScenariosForStratUtil.Count - 1].Utilities .Add(new Utility { ID = u.ID, Description = u.Description, QualityAttributeResponseType = u.QualityAttributeResponseType, Utility1 = u.Utility1 }); }//end util for loop }//end scenario for return respStrat; }
//Transfer Expected Utility Values: For /ArchitecturalStrategy/Edit private static void TransferValuesTo(ExpectedUtility itemToUpdate, ScenariosForStratUtil scenario) { itemToUpdate.ExpectedUtility1 = scenario.ExpectedUtility; itemToUpdate.ExpectedUtilityDescription = scenario.ExpectedUtilityDescription.Trim(); }