public async Task <bool> Handle(SaveClientSecretCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); return(false); } var savedClient = await _clientRepository.GetByClientId(request.ClientId); if (savedClient == null) { await Bus.RaiseEvent(new DomainNotification("Client", "Client not found")); return(false); } var secret = request.ToEntity(savedClient); _clientSecretRepository.Add(secret); if (await Commit()) { await Bus.RaiseEvent(new NewClientSecretEvent(request.Id, request.ClientId, secret.Type, secret.Description)); return(true); } return(false); }
public async Task Handle(SaveClientSecretCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { NotifyValidationErrors(request); return; } var savedClient = await _clientRepository.GetByClientId(request.ClientId); if (savedClient == null) { await Bus.RaiseEvent(new DomainNotification("1", "Client not found")); return; } var secret = new ClientSecret { Client = savedClient, Description = request.Description, Expiration = request.Expiration, Type = request.Type, Value = request.GetValue() }; _clientSecretRepository.Add(secret); if (Commit()) { await Bus.RaiseEvent(new NewClientSecretEvent(request.Id, request.ClientId, secret.Type, secret.Description)); } }