Created
January 3, 2024 13:22
-
-
Save vmussak/7ce1a64065f081f25565b84e2a4e05c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IActionResult EnviarMensagem(IServiceProvider serviceProvider, int clienteId) | |
{ | |
//busca o cliente pelo clienteId informado | |
var cliente = new Cliente | |
{ | |
Nome = "Vinicius Mussak", | |
TipoCliente = "Premium", | |
Id = clienteId | |
}; | |
//Recupera a instância pelo tipo do cliente | |
var service = serviceProvider.GetRequiredKeyedService<IMensagemBoasVindas>(cliente.TipoCliente); | |
var mensagem = service.CriarMensagem(cliente); | |
return Ok(mensagem); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment