-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new ASP.NET Core project for student management
Introduce a new ASP.NET Core project focused on managing student-related operations and handling global exceptions. Key components include: - Database context and initial migration for `Student` entity. - Configuration for services, OpenAPI/Swagger, and exception handling. - Models and DTOs for `Student` entity. - Service layer with `IStudentService` and `StudentService`. - `StudentController` for CRUD operations. - Global exception handling with `GlobalExceptionHandler`. - Added new solution and project files, including `GlobalExceptions.sln` and `GlobalExceptions.csproj`. - Updated various metadata and configuration files.
- Loading branch information
1 parent
1c6fb48
commit 22744ce
Showing
35 changed files
with
710 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.12.35506.116 d17.12 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GlobalExceptions", "GlobalExceptions\GlobalExceptions.csproj", "{DACC5DD3-A363-4A33-B169-DAF873F7ADC4}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{DACC5DD3-A363-4A33-B169-DAF873F7ADC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{DACC5DD3-A363-4A33-B169-DAF873F7ADC4}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{DACC5DD3-A363-4A33-B169-DAF873F7ADC4}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{DACC5DD3-A363-4A33-B169-DAF873F7ADC4}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="AutoMapper" Version="13.0.1" /> | ||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
</Project> |
50 changes: 50 additions & 0 deletions
50
GlobalExceptions/GlobalExceptions/Migrations/20241205220123_InitialCreate.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
GlobalExceptions/GlobalExceptions/Migrations/20241205220123_InitialCreate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace GlobalExceptions.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class InitialCreate : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "Students", | ||
columns: table => new | ||
{ | ||
Id = table.Column<int>(type: "int", nullable: false) | ||
.Annotation("SqlServer:Identity", "1, 1"), | ||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false), | ||
Biography = table.Column<string>(type: "nvarchar(max)", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Students", x => x.Id); | ||
}); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "Students"); | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
GlobalExceptions/GlobalExceptions/Migrations/20241205222045_Update.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
GlobalExceptions/GlobalExceptions/Migrations/20241205222045_Update.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace GlobalExceptions.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class Update : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
|
||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
|
||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
GlobalExceptions/GlobalExceptions/Migrations/StudentDbContextModelSnapshot.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// <auto-generated /> | ||
using GlobalExceptions.src.Context; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
#nullable disable | ||
|
||
namespace GlobalExceptions.Migrations | ||
{ | ||
[DbContext(typeof(StudentDbContext))] | ||
partial class StudentDbContextModelSnapshot : ModelSnapshot | ||
{ | ||
protected override void BuildModel(ModelBuilder modelBuilder) | ||
{ | ||
#pragma warning disable 612, 618 | ||
modelBuilder | ||
.HasAnnotation("ProductVersion", "9.0.0") | ||
.HasAnnotation("Relational:MaxIdentifierLength", 128); | ||
|
||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); | ||
|
||
modelBuilder.Entity("GlobalExceptions.src.Modles.Student", b => | ||
{ | ||
b.Property<int>("Id") | ||
.ValueGeneratedOnAdd() | ||
.HasColumnType("int"); | ||
|
||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); | ||
|
||
b.Property<string>("Biography") | ||
.IsRequired() | ||
.HasColumnType("nvarchar(max)"); | ||
|
||
b.Property<string>("Name") | ||
.IsRequired() | ||
.HasColumnType("nvarchar(max)"); | ||
|
||
b.HasKey("Id"); | ||
|
||
b.ToTable("Students"); | ||
}); | ||
#pragma warning restore 612, 618 | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
GlobalExceptions/GlobalExceptions/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": false, | ||
"applicationUrl": "http://localhost:5083", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": false, | ||
"applicationUrl": "https://localhost:7236;http://localhost:5083", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
GlobalExceptions/GlobalExceptions/appsettings.Development.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
|
||
"ConnectionStrings": { | ||
"sqlConnection": "Server=localhost;Database=studentDb;Integrated Security=true;TrustServerCertificate=true;" | ||
}, | ||
|
||
"AllowedHosts": "*" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
13 changes: 13 additions & 0 deletions
13
GlobalExceptions/GlobalExceptions/src/Context/StudentDbContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using GlobalExceptions.src.Modles; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace GlobalExceptions.src.Context | ||
{ | ||
public class StudentDbContext : DbContext | ||
{ | ||
public StudentDbContext(DbContextOptions<StudentDbContext> options) : base(options) | ||
{ | ||
} | ||
public DbSet<Student> Students { get; set; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
GlobalExceptions/GlobalExceptions/src/Contracts/ErrorResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace GlobalExceptions.src.Contracts | ||
{ | ||
public class ErrorResponse | ||
{ | ||
public string Title { get; set; } | ||
public int StatusCode { get; set; } | ||
public string Message { get; set; } | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
GlobalExceptions/GlobalExceptions/src/Contracts/StudentDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace GlobalExceptions.src.Contracts | ||
{ | ||
public record CreateStudent(string Name, string Biography); | ||
public record UpdateStudent(int Id, string Name, string Biography); | ||
public record StudentDto(int Id, string Name, string Biography); | ||
} |
Oops, something went wrong.