Skip to content

Commit

Permalink
feat: make sure a projection state exists when updating desired state
Browse files Browse the repository at this point in the history
  • Loading branch information
koenmetsu authored and CumpsD committed Aug 13, 2019
1 parent eb06213 commit 1fc1b38
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ public async Task UpdateProjectionDesiredState(string projectionName, string use
{
var projectionStateItem = await ProjectionStates.SingleOrDefaultAsync(item => item.Name == projectionName, cancellationToken);

if (projectionStateItem == null)
{
projectionStateItem = new ProjectionStateItem
{
Name = projectionName,
Position = -1L
};
await ProjectionStates.AddAsync(projectionStateItem, cancellationToken);
}

projectionStateItem.DesiredState = userRequestedState;
projectionStateItem.DesiredStateChangedAt = DateTimeOffset.UtcNow;
}
Expand Down

0 comments on commit 1fc1b38

Please sign in to comment.