-2

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?

everscope
  • 39
  • 6
  • This question welcomes opinionated answers, but I would personally say, that your controller can very easily get cluttered and unmanageable, if you do everything in it, so I would call a service-method in a service-class, that contains the logic. – thesystem Dec 28 '21 at 13:35
  • "It depends" =) – Guru Stron Dec 28 '21 at 13:46

1 Answers1

1

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

Mamink
  • 187
  • 2
  • 9