Develop the Mock Service
Develop a mock service for saving data in-memory.
We'll cover the following
We will only see how to manage the join between User
and the Group
. The usual create, read, delete, and edit operations for the User
as well as Group
have the same implementation as discussed in earlier chapters. For your reference, the link to the entire source code has been given in the Appendix should you face any issues understanding the flow.
add
function
The mock service will interact with an in-memory database to save the data, which will be consumed by the mock user interface. We will start with the add
functionality. We have a list of UserGroupDto
. With every new occurrence, one instance of UserGroupDto
containing a UserDto
and a GroupDto
is added to the list. A Singleton design pattern by means of enum
is followed for the in-memory database implementation. The identifier field starts at one and progresses by one for every new count.
Get hands-on with 1400+ tech skills courses.