I'm new to MVC and the different layers architecture and this is what I have currently:
2 models: User, Company
2 service layers: UserService, CompanyService
2 interfaces which abstract the database layer from the service layer: IUser, ICompany
2 database layers: UserDB, CompanyDB
Here's the scenario - a functionality that will update both User and Company table in the database. If update company succeed and update user failed, I will rollback the database for the company. Hence I think it makes sense to do this in 1 method.
If so, where do I put this method that handles 2 models? Is it normal to create
UserCompanyDB in the database layer and
UserCompanyService in the service layer just for this purpose? And even
IUserCompany as well.
Since I'm new to everything, chances are, you may think I'm having some misconceptions on the layers based on my current way of thinking? If so I would like to take this opportunity to rectify it too.
Oh and if it helps, I'm mainly trying to follow the example in this link: https://www.playframework.com/documentation/2.5.x/JavaTest#Unit-testing-models