public void Edit(EndUserId endUserId, string?name, RobotApplication?application) { var latestRegistration = Registrations.LastOrDefault(); if (latestRegistration == null) { throw new ValidationException("Robot is not registered"); } latestRegistration.Apply( registration => { if (registration.EndUserId != endUserId) { throw new ValidationException("Robot is registered to somebody else"); } var e = RobotEdited.Create(name, application); Apply(e); Append(Guid.NewGuid(), RobotEdited.EventType, e); }, unregistration => throw new ValidationException("Robot is not registered") ); }
private void Apply(RobotEdited e) { var latestRegistration = Registrations.LastOrDefault(); if (latestRegistration == null) { throw new InvalidOperationException("Robot is not registered"); } latestRegistration.Apply( registration => registration.Apply(this, e), unregistration => throw new InvalidOperationException("Robot is not registered") ); }
public void Apply(Robot robot, RobotEdited e) { Name = e.Name ?? $"{robot.Product:G} - {robot.SerialNumber}"; Application = e.Application; }