I have CompanyController and DepartmentController:
public class CompanyController : BaseBackendController
{
private ICompanyRepository repository;
public CompanyController(ICompanyRepository repository)
{
this.repository = repository;
}
...
[HttpPost]
public ActionResult BatchDelete(long[] ids)
{
var entities = repository.GetList().Where(item => ids.Contains(item.ID));
repository.BatchDelete(entities);
return RedirectToAction("Index");
}
}
public class DepartmentController : BaseBackendController
{
private IDepartmentRepository repository;
public DepartmentController(IDepartmentRepository repository)
{
this.repository = repository;
}
...
[HttpPost]
public ActionResult BatchDelete(long[] ids)
{
var entities = repository.GetList().Where(item => ids.Contains(item.ID));
repository.BatchDelete(entities);
return RedirectToAction("Index");
}
}
You can see that logic of BatchDelete is the same and I want it place to parent controller, but there is a challenge, the repository. I cant call in base controller repository.GetList().