Created
January 22, 2021 04:19
-
-
Save nosavvy33/66a2f9994dadb6327f3dd7160b7f3d6a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| [ApiController] | |
| [Route("calculator")] | |
| public class CalculatorController : Controller | |
| { | |
| // interfaces and not implementations | |
| private readonly IPrinter _printer; | |
| private readonly ICalculator _calculator; | |
| // "initialized" interfaces passed as controller's constructor parameters | |
| public CalculatorController(IPrinter printer, ICalculator calculator) | |
| { | |
| this._printer = printer; | |
| this._calculator = calculator; | |
| } | |
| [HttpGet("sum")] | |
| public IActionResult Sum([FromQuery] int a, [FromQuery] int b) | |
| { | |
| this._printer.PrintToConsole(this._calculator.Sum(a, b)); | |
| return Ok(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment