public CreateAUserValidationContext(CreateAUserCommand command, IUserRepository repository) { Command = command; RepositoryValidationContext = new CommonUserRepositoryValidationContext(repository) { Id = Command.UserId, Email = Command.Email }; }
public void Setup() { var validCommand = new CreateAUserCommand { UserId = "any user id", Email = "*****@*****.**", }; _repository = new UserRepository(_dbContext); _validationContext = new CreateAUserValidationContext(validCommand, _repository); }
public async Task <Domain.Models.Users.User> ResolveAsync() { var userId = _userIdResolver.Resolve(); var existingUser = _userRepository.GetUserOrDefaultByItsId(userId); if (existingUser != null) { return(existingUser); } var createUserCommand = new CreateAUserCommand { UserId = userId }; var createdUser = await _mediator.Send(createUserCommand); return(createdUser); }