rodger.Schmeler96 answered on July 12th 19 at 16:44
ServiceLayer - literally service level. It is assumed that the controller only accesses the services that perform the business logic.
For example - there is an action that accepts a purchase requisition user. We want:
1. to reserve items
2. invoice for payment
3. to send a notification to the user by email
We can write all the logic directly in the action, but it will lead to heavy code duplication and confusing logic. Instead, we will create separate services for each activity( interaction with email, transactions in goods, transactions with payment system).
In the body of the controller, we will give the necessary data to these services and process possible errors. Then return to the user the result.
Jayme91 answered on July 12th 19 at 16:46
Example: to generate a UUID, stored in database and give to the client.
Service UuidGenerator - knows how to create a UUID.
Service UuidDbSaver - able to save the UUID in the database.
Controller: receives a request calls UuidGenerator, it pushes in and returns UuidDbSaver.