Develop the Mock Service

Develop a mock service for saving data in-memory.

We will not go over the management of Client and Account objects because we have seen it many times in the previous chapters. We will only look at how to manage the link between Client and Account. If you have any questions about this, the entire code is shared in the Appendix section.

add function

The mock service is connected to a custom in-memory database for saving the data, which will be used by the mock user interface. We will start with the add functionality. We have a list of ClientAccountDto, and with every new entry, one instance of ClientAccountDto that has a ClientDto, and an AccountDto is added to the list. A Singleton design pattern implemented as an enum is used for the in-memory database implementation. The identifier field starts at one and advances by one for every new count.

Get hands-on with 1200+ tech skills courses.