A RESTful ASP.NET Core Web API that fetches user data from the JSONPlaceholder API and caches it in SQL Server using the DTO pattern with extension methods.
This API demonstrates .NET development practices by implementing a form of local caching. It retrieves user data from the JSONPlaceholder's public API, stores it in SQL Server for faster access, and exposes clean RESTful endpoints.
Built without an ORM, it uses raw SQL queries with parameterized statements for direct database control.
- Framework: ASP.NET Core 8.0
- Language: C#
- Database: SQL Server
- API Documentation: Swagger / OpenAPI
- External API: JSONPlaceholder
Microsoft.Data.SqlClient– SQL Server connectivity without ORMNewtonsoft.Json– JSON serialization / deserialization
- DTO Pattern – Separate models for API responses and database entities
- Extension Methods – Clean mapping between DTOs and entities
- Repository Pattern – Abstracted data access with raw SQL queries
- Caching Strategy – Database caching to reduce API calls
- Dependency Injection – Loose coupling
- .NET 8.0 SDK or later
- SQL Server
- SQL Server Management Studio (SSMS)
https://github.com/Hizbucodes/LiquidLabs-Assignment.git
cd LiquidLabs-
Open SSMS and connect to your SQL Server instance
-
Open the schema file - Database/schema.sql
-
Execute the script
-
Verify :- Databases → UserDataDB → Tables → dbo.Users
Update appsettings.json
{
"ConnectionStrings": {
"LiquidLabsConnectionString": "Server=LAPTOP-LLFF25ML\\SQLEXPRESS;Database=UserDataDB;Trusted_Connection=True;TrustServerCertificate=True"
}
}Using Visual Studio
Open LiquidLabs.API.sln
Press F5
Swagger UI opens automatically
HTTPS: https://localhost:7109
HTTP: http://localhost:5164
Swagger UI: https://localhost:7109/swagger
https://localhost:7109/apiFetches all users. Retrieves from database if cached, otherwise fetches from JSONPlaceholder and stores locally.
GET /api/usersRetrieves a single user by ID. Checks cache first.
GET /api/users/{id}Using Swagger UI
Run the application
Open https://localhost:7109/swagger
Click Try it out
Execute and view response