myoverall question is trying to understand what is the best practice of building a large .net core API.
Atm, Iv'e been taught to work with 4 different layers -
API (controllers)
Entity (just simple classes without any implementation, includes database entities and custom classes for user requests/response)
Logic (Basically built the same as the entity, but instead of classes it has the actual logic of each class)
Data (does the actual talk with the database so I can implement different db's behind it)
I currently seeing a video guide of State design pattern and it seems like he combined the entity and the logic layers, as he has the actual logic implementation on the classes themselves. Is that the right way to work?
The way I do it is that the API layer creates an instance of the logic layer and sent the requested entity to the logic where the actual code happens.
Second question - I am building an app that does bank transactions, is it correct to have a property on the transaction class that is called State, and the type is Interface TransactionState
and have lets say 3 state classes that inherit from TransactionState interface?
and than the actual logic I should do from the class state? (Which brings me back to the first question)
for example -
Transaction newTransaction = new Transaction(.....)
newTransaction.State.Validate();
newTransaction.State.Proccess();
sorry for the long question, hope someone will have the time to read it lol
Thanks !