Home > OS >  Should I use DbContext in controller or rather use it in model or service called from coltroller? MV
Should I use DbContext in controller or rather use it in model or service called from coltroller? MV

Time:12-28

I need to check if some data from the input form is contained in DbContext. Should I check it in controller or controller should just call method from model or service to which will do it?

CodePudding user response:

Your code would be cleaner if there be a mediator called "Services". a class whose duty is to collect data from your DB and provide that to your application layer which in your case is your controller, notice just that has accessibility to your context. Also, you can take a look at here and here to have the cleanest code

  • Related