Tags: Models, Collections, Linked resources, Queries, Pagination, Persistence, Call methods, Resource parameters
A customer management system, where you can search and filter customers by name and country. The search results are live and updated as customers are edited, added, or deleted by multiple users simultaneously.
- Install NATS Server and Resgate (done with 3 docker commands).
git clone https://github.com/jirenius/csharp-res
Open the solution, examples\04_Search\Search.sln
, in Visual Studio 2017.
Set multiple startup projects with the projects below (how to). Press F5 to build and run.
- SearchService
- WebClient
Open the client
http://localhost:8081
- Open the client in two separate tabs.
- Make a query (eg. Set Filter to
B
, and Country toGermany
) in one tab. - In a separate tab, try to:
- create a New customer matching the query.
- edit a customer so that it starts to match the query.
- edit a customer so that it no longer matches the query.
- delete a customer that matches the query.
- In the tab with the query, try to:
- edit the name of a customer so that it changes order.
- edit the country of a customer so that it no longer matches the query.
- Open the client and make some changes.
- Restart the service and the client.
- Observe that all changes are persisted (in the LiteDB database).
Request | Resource | Description |
---|---|---|
get | search.customers?from=0&limit=5&name=A&country=Sweden |
Query collection of customer references. All query parameters are optional. |
call | search.customers.newCustomer |
Adds a new customer. |
get | search.customer.<ID> |
Models representing customers. |
call | search.customer.<ID>.set |
Sets the customers' name, email, and country properties. |
call | search.customer.<ID>.delete |
Deletes a customer. |
get | search.countries |
Collection of available countries. |
Resources can be retrieved using ordinary HTTP GET requests, and methods can be called using HTTP POST requests.
GET http://localhost:8080/api/search/customers?from=0&limit=5&name=A&country=Sweden
POST http://localhost:8080/api/search/customers/newCustomer
Body
{ "name": "John Doe", "email": "[email protected]", "country": "France" }
GET http://localhost:8080/api/search/customer/<ID>
POST http://localhost:8080/api/search/customer/<ID>/set
Body
{ "name": "Jane Doe", "country": "United Kingdom" }
POST http://localhost:8080/api/search/customer/<ID>/delete
No body
GET http://localhost:8080/api/search/countries