From c9a0ef1b84bc36d1f529444f30ef50f4f25ae95b Mon Sep 17 00:00:00 2001 From: Alex <77341673+defectiveAi@users.noreply.github.com> Date: Wed, 4 Dec 2024 08:41:26 +0100 Subject: [PATCH] Trying stuff out. --- .../Model/Actor.cs | 25 +++++++++++++------ .../Model/ActorMarketRole.cs | 7 ------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/source/marketparticipant/Energinet.DataHub.MarketParticipant.Domain/Model/Actor.cs b/source/marketparticipant/Energinet.DataHub.MarketParticipant.Domain/Model/Actor.cs index 4d9f557af..1f2d3e37c 100644 --- a/source/marketparticipant/Energinet.DataHub.MarketParticipant.Domain/Model/Actor.cs +++ b/source/marketparticipant/Energinet.DataHub.MarketParticipant.Domain/Model/Actor.cs @@ -236,15 +236,26 @@ public void Deactivate() public void TransferGridAreasFrom(Actor fromActor) { ArgumentNullException.ThrowIfNull(fromActor); - foreach (var actorGridArea in fromActor.MarketRole.GridAreas) + + if (_actorStatusTransitioner.Status is ActorStatus.Active or ActorStatus.Passive) { - _domainEvents.Add(new GridAreaOwnershipAssigned( - ActorNumber, - MarketRole.Function, - actorGridArea.Id)); + foreach (var actorGridArea in fromActor.MarketRole.GridAreas) + { + _domainEvents.Add(new GridAreaOwnershipAssigned( + ActorNumber, + MarketRole.Function, + actorGridArea.Id)); + } } - MarketRole.UpdateGridAreas(MarketRole.GridAreas.Concat(fromActor.MarketRole.GridAreas)); - fromActor.MarketRole.UpdateGridAreas(Array.Empty()); + MarketRole = new ActorMarketRole( + MarketRole.Function, + MarketRole.GridAreas.Concat(fromActor.MarketRole.GridAreas), + MarketRole.Comment); + + fromActor.MarketRole = new ActorMarketRole( + MarketRole.Function, + [], + MarketRole.Comment); } } diff --git a/source/marketparticipant/Energinet.DataHub.MarketParticipant.Domain/Model/ActorMarketRole.cs b/source/marketparticipant/Energinet.DataHub.MarketParticipant.Domain/Model/ActorMarketRole.cs index c0ab9cd34..3d0772f28 100644 --- a/source/marketparticipant/Energinet.DataHub.MarketParticipant.Domain/Model/ActorMarketRole.cs +++ b/source/marketparticipant/Energinet.DataHub.MarketParticipant.Domain/Model/ActorMarketRole.cs @@ -40,11 +40,4 @@ public ActorMarketRole(EicFunction eic) public IReadOnlyCollection GridAreas { get; private set; } public EicFunction Function { get; } public string? Comment { get; } - - public void UpdateGridAreas(IEnumerable actorGridAreas) - { - ArgumentNullException.ThrowIfNull(actorGridAreas); - - GridAreas = actorGridAreas.ToList(); - } }