Skip to content

imkumardeepak/TableByModel

Repository files navigation

TableByModel

This project demonstrates a .NET 8 Web API with a standardized API response model, CRUD operations for student management, and Entity Framework Core for database interactions.

Features

  • Standardized API Response: All API endpoints return responses wrapped in a consistent ApiResponse<T> model, including status codes, success/failure indicators, data payload, error messages, and timestamps.
  • Student Management: CRUD operations for StudentDetails and StudentSubject entities.
  • Data Annotation Validation: Request validation and input sanitization using data annotations.
  • Entity Framework Core: Database interaction with PostgreSQL using EF Core migrations.
  • Global Error Handling: Centralized error handling to provide consistent error responses.

Getting Started

Prerequisites

  • .NET 8 SDK
  • PostgreSQL database server
  • Redis (optional, for caching)

Configuration

Update the appsettings.json file with your database connection string and other settings:

{
  "ConnectionStrings": {
    "DefaultConnection": "Host=localhost;Port=5432;Database=DummyDb;Username=postgres;Password=system",
    "RedisConnection": "localhost:6379"
  },
  "JwtSettings": {
    "Secret": "YOUR_SUPER_SECRET_KEY_THAT_IS_AT_LEAST_32_CHARS_LONG",
    "Issuer": "TableByModel",
    "Audience": "TableByModelClient"
  }
}

Database Migrations

Apply database migrations to create the necessary tables:

dotnet ef database update

Running the Application

dotnet run

The application will start and listen on http://localhost:5160 (or the port configured in launchSettings.json).

API Endpoints

Access the Swagger UI at http://localhost:5160/swagger to explore and test the API endpoints.

Project Structure

  • Controllers/: Contains API controllers, e.g., StudentController.cs.
  • Response/: Defines the ApiResponse.cs model for standardized responses.
  • Filters/: Includes ApiResponseFilter.cs for wrapping API responses.
  • Model/: Contains entity models, e.g., StudentDetails.cs.
  • Services/: Business logic and data access, e.g., StudentService.cs.
  • AppDbContext.cs: Entity Framework Core DbContext for database interaction.
  • Migrations/: Database migration files.

About

Helping In Develop Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages