Outline

Solution: IAccountRepository Dependency Injection

In the Conduit.Api Project

Modify the UserController (notice the singular "User")
  • Inject IAccountRepository
    • Add a private member
      • Name: AccountRepo
      • Type: IAccountRepository
    • Modify Constructor by adding new parameter
      • Name: accountRepo
      • Type: IAccountRepository
      • Assign the value of the parameter to the AccountRepo Member

Here's the code to the UserController.cs file:

using ...

namespace Conduit.Api.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        private IAccountRepository AccountRepo;
        private ILogger<UserController> Logger;

        public UserController(IAccountRepository accountRepo, ILogger<UserController> logger)
        {
            AccountRepo = accountRepo;
            Logger = logger;
        }
    }
}
 

I finished! On to the next chapter