The University Management System is a modular application built with ASP.NET Core 8 and Entity Framework Core. It provides functionality for managing university-related data, such as students, courses, enrollments, and more. The project is designed with a layered architecture to ensure scalability, maintainability, and separation of concerns.
- Modular architecture with separate layers for core logic, data access, and presentation.
- Support for multiple database providers (SQLite and SQL Server).
- Entity Framework Core for ORM and database migrations.
- Swagger integration for API documentation.
- Built with .NET 8 and C# 12.
- Comprehensive API for managing:
- Students
- Courses
- Enrollments
- Validation to prevent duplicate enrollments.
- Transaction management using the Unit of Work pattern.
The solution is divided into the following projects:
- Contains the core domain entities and business logic.
- Example entities:
StudentCourseEnrollment
- Handles application-level logic, such as services and DTOs.
- Implements validation, mapping, and business rules.
- Example services:
StudentServiceCourseServiceEnrollmentService
- Implements the data access layer using Entity Framework Core.
- Includes
DbContextimplementations for SQLite and SQL Server:UniversityManagementSystemSqLiteDbContextUniversityManagementSystemSqlDbContext
- Repositories for managing database operations:
StudentRepositoryCourseRepositoryEnrollmentRepository
- The entry point of the application.
- Configures services, middleware, and API endpoints.
- Includes controllers for:
- Students
- Courses
- Enrollments
The application supports multiple database providers. Configure the database in the appsettings.json file:
"Database": {
"Provider": "sqlite",
"SqliteConnection": "Data Source=Data/UniversityManagementSystem.db"
}, "Database": {
"Provider": "sqlserver",
"SqlServerConnection": "Server=localhost;Database=UniversityManagementSystemDb;User Id=sa;Password=password*;TrustServerCertificate=True;"
},The database provider is determined by the Database:Provider key in appsettings.json. Supported values:
sqlitesqlserver
- .NET 8 SDK installed.
- SQL Server (if using SQL Server as the database provider).
git clone https://github.com/joanny-benejam/UniversityManagementSystem.git
Restore NuGet packages:
dotnet restore
Update the appsettings.json file with the appropriate database provider and connection string.
Run the following commands to create and apply migrations:
For SQLite:
dotnet ef migrations add Initial -c UniversityManagementSystemSqLiteDbContext
dotnet ef database update -c UniversityManagementSystemSqLiteDbContext
For SQL Server:
dotnet ef migrations add Initial -c UniversityManagementSystemSqlDbContext
dotnet ef database update -c UniversityManagementSystemSqlDbContext
Start the application:
dotnet run --project UniversityManagementSystem.Web
- Access the API documentation at
https://localhost:<7295>/swagger(in development mode). - Use the API endpoints to manage university data.
GET /api/students/withcourses: Get all students with their enrolled courses.POST /api/students: Add a new student.
GET /api/courses/withstudents: Get all courses with their enrolled students.GET /api/courses/student/{email}: Get all courses for a specific student by email.POST /api/courses: Add a new course.
POST /api/enrollments: Enroll a student in a course.GET /api/enrollments/exists: Check if a student is already enrolled in a course.
Id(GUID): Primary key.Name(string): Name of the student.Email(string): Email address of the student.DateOfBirth(DateTime?): Date of birth of the student.
Id(GUID): Primary key.Name(string): Name of the course.Code(string): Unique code for the course.Credits(int?): Number of credits for the course.
Id(GUID): Primary key.StudentId(GUID): Foreign key referencingStudent.CourseId(GUID): Foreign key referencingCourse.EnrollmentDate(DateTime): Date when the student was enrolled.
-
Validation:
- Prevent duplicate enrollments (same student, same course).
- Ensure required fields are provided for all entities.
-
Transaction Management:
- Implemented the Unit of Work pattern to handle database transactions.
-
Enhanced Queries:
- Fetch students with their courses in a single query.
- Fetch courses with their enrolled students in a single query.
- Fetch courses for a specific student by email.
-
Error Handling:
- Return appropriate HTTP status codes for validation errors, conflicts, and not found scenarios.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.