This question is from a Best Practices perspective.
I am using Micro-ORM to separate DAL with Views. I am often confused on my application design approach. While the Micro-ORM takes care of the separation of layers, I also want separation of business logic.
It is suggested to use Classes in this regard, but use of Classes is puzzling in itself.
For example, I have a Web Form with a Button. On click of this button, I want to call a method called as: AddCompany.
I want to know where should I keep this AddCompany method. If it is residing in the .cs file of the Web Form, the business logic is again tightly coupled.
And if I move this method to a Class, I need to pass all the Web Form input box values as parameters to this class.
You don’t need to pass the input controls – you need to pass the input.
In most cases, we have business layer service classes which take dependencies in the constructor – such as a database connection or a reference to a repository. Then they have methods that take classes as parameters. Typically these classes are pretty dumb data transfer objects, but they definitely don’t reference the controls.
For ASP.NET webforms, in most cases you’ll have to write some code to map the data coming into the form into the class.