I created a service class 'TeacherService' with an interface that I want to pass it into my controller's constructor, but when I try there is an error in one of the constructors
As soon as I type a comma into the constructors parameters it red unerlines
new TeacherRepository()
saying it can't resolve the constructor. Here is the code.
public class TeacherController : Controller
{
private readonly ITeacherRepository teacherRepository;
private readonly ITeacherService teacherService;
// If you are using Dependency Injection, you can delete the following constructor
public TeacherController() : this(new TeacherRepository())
{
}
public TeacherController(ITeacherRepository teacherRepository, ITeacherService teacherService)
{
this.teacherRepository = teacherRepository;
this.teacherService = teacherService;
}