public async Task RegisterUser(NewUserViewModel newUserViewModel, CancellationToken token = default) { var v = new ValidationContext(newUserViewModel); Validator.ValidateObject(newUserViewModel, v); var userList = await this.userRepo.ListAsync(new UserExistsQuery(newUserViewModel.Username)); if (userList.Count > 0) { throw new ValidationException("This user name already exists"); } else { var user = newUserViewModel.CreateUser(); await this.userRepo.AddAsync(user, token); await uow.SaveChangesAsync(token); } }
public void Execute(object parameter) { NewUserViewModel.CreateUser(); }