I am wondering what is the better way to inject a service. I have two ways in mind:
This:
Public async Task<IActionResult> CheckOut([FromBody] FooModel model, [FromService] Config config){ //do stuff with config here...}
Or:
Public class FooClass{ private readonly IConfig _config; public FooClass(IConfig config) { _config = config; } //methods interacting with config...}
Is there a scenario where one is better to use than the other, e.g. if multiple methods use the Config
is it then better to inject it in the constructor?