public async Task <AddUserResource> Handle(AddUserCommand request, CancellationToken cancellationToken) { if (_dataContext.Users.Any(x => x.Username == request.Username)) { return(new AddUserResource(null, "Username is already taken")); } var user = new User() { Username = request.Username }; user.PasswordHash = _passwordHasher.HashPassword(request.Password); _dataContext.Users.Add(user); await _dataContext.SaveChangesAsync(); return(new AddUserResource(UserResource.FromUser(user))); }