From e89974f9f93e17e2f5f101130b5c1e438ec64a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Th=C3=A9ate?= <97221392+antoineatrhea@users.noreply.github.com> Date: Mon, 8 Jan 2024 09:17:06 +0100 Subject: [PATCH] Fix #491: SelectedIterationSetup correctly set (#493) --- .../ViewModels/Components/OpenModelViewModel.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/COMET.Web.Common/ViewModels/Components/OpenModelViewModel.cs b/COMET.Web.Common/ViewModels/Components/OpenModelViewModel.cs index a3891f74..f2776b06 100644 --- a/COMET.Web.Common/ViewModels/Components/OpenModelViewModel.cs +++ b/COMET.Web.Common/ViewModels/Components/OpenModelViewModel.cs @@ -139,7 +139,7 @@ public void InitializesProperties() this.IsOpeningSession = false; this.AvailableEngineeringModelSetups = this.sessionService.GetParticipantModels() - .Where(x => x.IterationSetup.Any(setup => this.sessionService.OpenIterations.Items.All(i => i.Iid != setup.IterationIid))) + .Where(x => x.IterationSetup.Exists(setup => this.sessionService.OpenIterations.Items.All(i => i.Iid != setup.IterationIid))) .OrderBy(x => x.Name); } @@ -169,7 +169,7 @@ await this.sessionService.ReadIteration(this.SelectedEngineeringModel.IterationS public void PreSelectIteration(Guid modelId, Guid iterationId, Guid domainId) { this.selectedEngineeringModel = this.AvailableEngineeringModelSetups.FirstOrDefault(x => x.Iid == modelId); - var iterationSetup = this.SelectedEngineeringModel?.IterationSetup.FirstOrDefault(x => x.IterationIid == iterationId); + var iterationSetup = this.SelectedEngineeringModel?.IterationSetup.Find(x => x.IterationIid == iterationId); if (iterationSetup != null) { @@ -194,12 +194,7 @@ private void ComputeAvailableCollections() } else { - this.SelectedIterationSetup = this.selectedEngineeringModel.IterationSetup - .Where(x => x.FrozenOn == null) - .Select(x => new IterationData(x)) - .LastOrDefault(); - - this.SelectedDomainOfExpertise = this.SelectedEngineeringModel.ActiveDomain.FirstOrDefault(x => x == this.sessionService.Session.ActivePerson.DefaultDomain); + this.SelectedDomainOfExpertise = this.SelectedEngineeringModel.ActiveDomain.Find(x => x == this.sessionService.Session.ActivePerson.DefaultDomain); this.AvailablesDomainOfExpertises = this.sessionService.GetModelDomains(this.SelectedEngineeringModel); @@ -207,6 +202,8 @@ private void ComputeAvailableCollections() .Where(x => this.sessionService.OpenIterations.Items.All(i => i.Iid != x.IterationIid)) .OrderBy(x => x.IterationNumber) .Select(x => new IterationData(x)); + + this.SelectedIterationSetup = this.AvailableIterationSetups.Last(); } } }