public void Stop(GroupAdministratorIdentifier stoppedBy) { if (_active) { Raise(new GroupStopped( _groupId.ToGuid(), _name.ToString(), stoppedBy.ToGuid(), 0 // DateTimeOffset.UtcNow.Ticks )); } }
public Task when_stopping_a_started_group() { var groupId = new GroupIdentifier(Guid.NewGuid()); var administratorId = new GroupAdministratorIdentifier(Guid.NewGuid()); return(new Scenario() .Given(groupId, new GroupStarted( groupId, "Elvis Afficionados", administratorId, 0) ) .When(new StopGroup( groupId.ToGuid(), administratorId)) .Then(groupId, new GroupStopped( groupId, "Elvis Afficionados", administratorId, 0) ) .AssertAsync(_runner)); }
public async Task <Group> TryLoadById(GroupIdentifier identifier, CancellationToken ct = default(CancellationToken)) { var stream = new StreamName($"groups-{identifier.ToGuid():N}"); var result = await _reader.ReadStreamAsync(stream, ct); if (result.State == ReadResultState.Deleted) { throw new GroupDeletedException(identifier); } return(result.State == ReadResultState.Found ? (Group)result.Value : null); }
public static Group Start(GroupIdentifier groupId, GroupName name, GroupAdministratorIdentifier startedBy) { var group = new Group(); group.Raise(new GroupStarted( groupId.ToGuid(), name.ToString(), startedBy.ToGuid(), 0 // DateTimeOffset.UtcNow.Ticks )); return(group); }
public async Task <Group> LoadById(GroupIdentifier identifier, CancellationToken ct = default(CancellationToken)) { var stream = new StreamName($"groups-{identifier.ToGuid():N}"); var result = await _reader.ReadStreamAsync(stream, ct); switch (result.State) { case ReadResultState.NotFound: throw new GroupNotFoundException(identifier); case ReadResultState.Deleted: throw new GroupDeletedException(identifier); } return((Group)result.Value); }
public GroupDeletedException(GroupIdentifier identifier) : base($"The group with identifier {identifier.ToGuid():N} was deleted.") { }
public GroupNotFoundException(GroupIdentifier identifier) : base($"The group with identifier {identifier.ToGuid():N} could not be found.") { }