protected override void OnCommand(object message) { switch (message) { case RegisterUserCommand { UserName: var userName } : Event e; if (this.userNames.Contains(userName)) { e = new UserAlreadyExists(userName); } else { e = new UserRegistered(userName); } Persist(e, Apply); Context.System.EventStream.Publish(e); break; }
public static BadRequest OnUserAlreadyExists(UserAlreadyExists userAlreadyExists) => new BadRequest($@"User ""#{userAlreadyExists.User.Id} {userAlreadyExists.User.Name}"" already exists.");
public DuplicateUserException(string login, UserAlreadyExists innerException) : base("This username is already taken.", innerException) { }