This API, written in C#, is intended as a backend for an Angular website for school administration.
-
A student can take courses, have diplomas and certificates, create studyplans, take an exam and view his(her) results.
-
A person (student, teacher, ...) can have more than one address.
-
With the help of a studyplan, the student can plan a learning period, for example for a specific exam.
-
A teacher can create courses,exams and homework.
-
A teacher can give exam grades for a specific student
-
Schoolmanagement can make invoices.
-
... and more
- Click button Code
- Choose open with Visual Studio
- Click Clone
- Setup the database in SQL-Server
Replace the Connectionstring, AppiSettings-SecretKey , Cors-AllowedOrigins and the AutoMapper-LicenseKey with your settings
-
Start the application in Visual Studio by clicking the Startbutton (choose https)

-
The application start now the Swagger-screen where you can explore the available endpoints.
-
Visual studio 2026 Community Edition
-
Target framework : .NET9.0
-
SQL-Server 2022
-
Database diagram :
Exploring Endpoints.
add new project to solution : xUnit test Project
Installed Packages:
- xunit
- xunit.runner.visualstudio
Right click project SchoolAdministration
Choose Manage Nuget Packages
Search and install Nuget-Packages:
- FluentAssertions
- Moq
Make a reference to SchoolAdministration project:
Right click project SchoolAdministrationTests
choose Project Reference
Cors
Program.cs:
Warning :
- This are my settings for now.
- Will be reviewed later.
- Be carefully with security settings, especially in production environment.
Installed NuGet-packages :
- Serilog.AspNetCore
- Serilog.Sinks.file
Program.cs:
If you choose RollingInterval.Day : You get EVERYDAY DAY a separete log file : Filename = SchoolManagement + date(yyyyMMdd) .log :
StudentController: _logger.LogInformation("Getting all the students.")
Installed NuGet-packages :
- microsoft.entityframeworkcore.sqlserver\9.0.0
- entityframeworkcore.tools\9.0.0
We use code first.
By Migrations we keep our database in SQL-Server in Sync.
example:
Type in Package Manager Console:
Add-Migration InitialMigration
update-Database
Installed Nuget-packages :
- microsoft.aspnetcore.identity.entityframeworkcore\9.0.0\
- microsoft.aspnetcore.authentication.jwtbearer\9.0.3\
extra tables in SQL-Server:
Why we use Dependecy Injection?
Dependency injection aims to separate the concerns of constructing objects and using them, leading to loosely coupled programs.
We use DI for injection from : studentRepository,logger and mapper
public StudentController( IStudentRepository studentRepository, ILogger logger, IMapper mapper)
In program.cs we must configure:
builder.Services.AddScoped<IStudentRepository, StudentRepository>();
Installed NuGet-package :
- automapper
To map entities to DTO's and vice versa.
DTO stands for Data Transfer Objects
Why we need DTO's to communicate with the outside world?
Example : in our database we have fields to store 'insertDate' or 'insertedBy'
If we don't won't to share this fields with the outside world : we make a DTO without these fields.
We use par Controller 3 DTO's : one for update, one for insert, one for read
Why?
Because we do not need always the same data.
Example : for insert we do not need a ID, for a update is ID necessary.
MappingConfig:
CreateMap<Student, StudentDTO>().ReverseMap();
In the Controller we can write some like this to map student to StudentDTO :
_mapper.Map < StudentDTO > (student)
Note : In the latest version of Automapper, you need a license key. Check te website: https://AutoMapper.io
I am considering to switch from automapper to manual mapping. Both have its pros and contras. I Started with the conversion of the CourseController from automapper to manual mapping.
Manual mapping with EXTENSION METHODS :
CourseController.cs:
CourseMappingExtensions.cs :
Installed NuGet-packages :
-
Microsoft.AspNetCore.Mvc.Versioning
-
Microsoft.AspNetCore.Mvc.Versioning.ApiExlorer
Program.cs :
builder.Services.AddApiVersioning(options => { options.AssumeDefaultVersionWhenUnspecified = true; options.DefaultApiVersion = new Microsoft.AspNetCore.Mvc.ApiVersion(1, 0); });
If you want to read more info about this API or the used technology :