public async Task <ICommandResult> HandleAsync(CriarUsuarioCommand command) { var usuario = await _usuarioRepository.GetAsync(command.Email); AddNotifications(new Contract() .Requires() .IsNull(usuario, "usuario.e-mail", "E-mail já utilizado!")); if (Invalid) { return new CriarUsuarioCommandResult { Success = false, Message = "Inconsistências encontradas", Data = Notifications } } ; usuario = new Usuario(command.Email, command.Nome); usuario.SetSenha(command.Senha, _encrypter); AddNotifications(usuario.Notifications); if (Invalid) { return new CriarUsuarioCommandResult { Success = false, Message = "Inconsistências encontradas", Data = Notifications } } ; _logger.LogInformation($"Realizando o regirstro do usuario: {command.Email}"); await _usuarioRepository.AdicionarAsync(usuario); return(new CriarUsuarioCommandResult { Success = true, Message = "Usuário registrado com sucesso", Data = command.Email }); }
protected override async Task ExecuteCommandAsync(Usuario entity) => await usuarioRepository.AdicionarAsync(entity);