Skip to content

Commit

Permalink
Trying stuff out.
Browse files Browse the repository at this point in the history
  • Loading branch information
defectiveAi committed Dec 4, 2024
1 parent 8a8f105 commit c9a0ef1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ActorGridArea>());
MarketRole = new ActorMarketRole(
MarketRole.Function,
MarketRole.GridAreas.Concat(fromActor.MarketRole.GridAreas),
MarketRole.Comment);

fromActor.MarketRole = new ActorMarketRole(
MarketRole.Function,
[],
MarketRole.Comment);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,4 @@ public ActorMarketRole(EicFunction eic)
public IReadOnlyCollection<ActorGridArea> GridAreas { get; private set; }
public EicFunction Function { get; }
public string? Comment { get; }

public void UpdateGridAreas(IEnumerable<ActorGridArea> actorGridAreas)
{
ArgumentNullException.ThrowIfNull(actorGridAreas);

GridAreas = actorGridAreas.ToList();
}
}

0 comments on commit c9a0ef1

Please sign in to comment.