From f9a34296eb4b2462c32f74901208b59d30c5719f Mon Sep 17 00:00:00 2001 From: iqbalbaloch8994-spec Date: Thu, 2 Apr 2026 11:48:16 +0500 Subject: [PATCH] Add DTOs, domain models, EF Core setup, and API skeleton - Introduced DTO and domain model classes for User, Project, ProjectRequest, and ProjectAllocation. - Added empty UsersController to APIGateway_Services. - Created IUsers interface and UserRepostory class (empty) in Application_Services. - Implemented ProjectAllocationDbContext with EF Core and SQLite. - Updated Infrastructure_Service.csproj with EF Core dependencies. - Updated APIGateway_Services.csproj with project references and .NET 10.0 target. --- .../APIGateway_Services.csproj | 8 ++++++- .../Controllers/UsersController.cs | 11 ++++++++++ .../DTO/ProjectAllocationDTO.cs | 14 +++++++++++++ Application_Services/DTO/ProjectDTO.cs | 16 ++++++++++++++ Application_Services/DTO/ProjectRequestDTO.cs | 15 +++++++++++++ Application_Services/DTO/UserDTO.cs | 17 +++++++++++++++ Application_Services/Interface/IUsers.cs | 10 +++++++++ .../Repostory/UserRepostory.cs | 10 +++++++++ Domain_Services/Model/Project.cs | 16 ++++++++++++++ Domain_Services/Model/ProjectAllocation.cs | 14 +++++++++++++ Domain_Services/Model/ProjectRequest.cs | 15 +++++++++++++ Domain_Services/Model/User.cs | 21 +++++++++++++++++++ .../ProjectAllocationDbContext.cs | 21 +++++++++++++++++++ .../Infrastructure_Service.csproj | 13 ++++++++++++ 14 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 APIGateway_Services/Controllers/UsersController.cs create mode 100644 Application_Services/DTO/ProjectAllocationDTO.cs create mode 100644 Application_Services/DTO/ProjectDTO.cs create mode 100644 Application_Services/DTO/ProjectRequestDTO.cs create mode 100644 Application_Services/DTO/UserDTO.cs create mode 100644 Application_Services/Interface/IUsers.cs create mode 100644 Application_Services/Repostory/UserRepostory.cs create mode 100644 Domain_Services/Model/Project.cs create mode 100644 Domain_Services/Model/ProjectAllocation.cs create mode 100644 Domain_Services/Model/ProjectRequest.cs create mode 100644 Domain_Services/Model/User.cs create mode 100644 Infrastructure_Service/AppDbContext/ProjectAllocationDbContext.cs diff --git a/APIGateway_Services/APIGateway_Services.csproj b/APIGateway_Services/APIGateway_Services.csproj index 6e13ddb..b7e4a55 100644 --- a/APIGateway_Services/APIGateway_Services.csproj +++ b/APIGateway_Services/APIGateway_Services.csproj @@ -1,4 +1,4 @@ - + net10.0 @@ -10,4 +10,10 @@ + + + + + + diff --git a/APIGateway_Services/Controllers/UsersController.cs b/APIGateway_Services/Controllers/UsersController.cs new file mode 100644 index 0000000..aa922b7 --- /dev/null +++ b/APIGateway_Services/Controllers/UsersController.cs @@ -0,0 +1,11 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace APIGateway_Services.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class UsersController : ControllerBase + { + } +} diff --git a/Application_Services/DTO/ProjectAllocationDTO.cs b/Application_Services/DTO/ProjectAllocationDTO.cs new file mode 100644 index 0000000..721378e --- /dev/null +++ b/Application_Services/DTO/ProjectAllocationDTO.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Application_Services.DTO +{ + public class ProjectAllocationDTO + { + public Guid Id { get; set; } = Guid.NewGuid(); + public Guid StudentId { get; set; } + public Guid ProjectId { get; set; } + public DateTime AllocatedAt { get; set; } = DateTime.UtcNow; + } +} diff --git a/Application_Services/DTO/ProjectDTO.cs b/Application_Services/DTO/ProjectDTO.cs new file mode 100644 index 0000000..0a91ebf --- /dev/null +++ b/Application_Services/DTO/ProjectDTO.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Application_Services.DTO +{ + public class ProjectDTO + { + public Guid Id { get; set; } = Guid.NewGuid(); + public string Title { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public Guid TeacherId { get; set; } + public string Status { get; set; } = "Open"; // Open, Closed + public DateTime CreatedAt { get; set; } = DateTime.UtcNow; + } +} diff --git a/Application_Services/DTO/ProjectRequestDTO.cs b/Application_Services/DTO/ProjectRequestDTO.cs new file mode 100644 index 0000000..1012a1d --- /dev/null +++ b/Application_Services/DTO/ProjectRequestDTO.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Application_Services.DTO +{ + public class ProjectRequestDTO + { + public Guid Id { get; set; } = Guid.NewGuid(); + public Guid StudentId { get; set; } + public Guid ProjectId { get; set; } + public string Status { get; set; } = "Pending"; // Pending, Approved, Rejected + public DateTime RequestedAt { get; set; } = DateTime.UtcNow; + } +} diff --git a/Application_Services/DTO/UserDTO.cs b/Application_Services/DTO/UserDTO.cs new file mode 100644 index 0000000..d200e06 --- /dev/null +++ b/Application_Services/DTO/UserDTO.cs @@ -0,0 +1,17 @@ +namespace Application_Services.DTO +{ + public class UserDTO + { + public Guid Id { get; set; } = Guid.NewGuid(); + public string Name { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; + public string Password { get; set; } = string.Empty; + public string Role { get; set; } = string.Empty; // Admin, Teacher, Student + + // Only for Students + public string? Session { get; set; } // e.g. "2020-24", "2022-26" + public string? Section { get; set; } // e.g. "A", "B", "C" + + public DateTime CreatedAt { get; set; } = DateTime.UtcNow; + } +} diff --git a/Application_Services/Interface/IUsers.cs b/Application_Services/Interface/IUsers.cs new file mode 100644 index 0000000..7022e86 --- /dev/null +++ b/Application_Services/Interface/IUsers.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Application_Services.Interface +{ + internal interface IUsers + { + } +} diff --git a/Application_Services/Repostory/UserRepostory.cs b/Application_Services/Repostory/UserRepostory.cs new file mode 100644 index 0000000..990456d --- /dev/null +++ b/Application_Services/Repostory/UserRepostory.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Application_Services.Repostory +{ + internal class UserRepostory + { + } +} diff --git a/Domain_Services/Model/Project.cs b/Domain_Services/Model/Project.cs new file mode 100644 index 0000000..d9c39fd --- /dev/null +++ b/Domain_Services/Model/Project.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Domain_Services.Model +{ + public class Project + { + public Guid Id { get; set; } = Guid.NewGuid(); + public string Title { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public Guid TeacherId { get; set; } + public string Status { get; set; } = "Open"; // Open, Closed + public DateTime CreatedAt { get; set; } = DateTime.UtcNow; + } +} diff --git a/Domain_Services/Model/ProjectAllocation.cs b/Domain_Services/Model/ProjectAllocation.cs new file mode 100644 index 0000000..299cc00 --- /dev/null +++ b/Domain_Services/Model/ProjectAllocation.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Domain_Services.Model +{ + public class ProjectAllocation + { + public Guid Id { get; set; } = Guid.NewGuid(); + public Guid StudentId { get; set; } + public Guid ProjectId { get; set; } + public DateTime AllocatedAt { get; set; } = DateTime.UtcNow; + } +} diff --git a/Domain_Services/Model/ProjectRequest.cs b/Domain_Services/Model/ProjectRequest.cs new file mode 100644 index 0000000..bdf3960 --- /dev/null +++ b/Domain_Services/Model/ProjectRequest.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Domain_Services.Model +{ + public class ProjectRequest + { + public Guid Id { get; set; } = Guid.NewGuid(); + public Guid StudentId { get; set; } + public Guid ProjectId { get; set; } + public string Status { get; set; } = "Pending"; // Pending, Approved, Rejected + public DateTime RequestedAt { get; set; } = DateTime.UtcNow; + } +} diff --git a/Domain_Services/Model/User.cs b/Domain_Services/Model/User.cs new file mode 100644 index 0000000..f81c836 --- /dev/null +++ b/Domain_Services/Model/User.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Domain_Services.Model +{ + public class User + { + public Guid Id { get; set; } = Guid.NewGuid(); + public string Name { get; set; } = string.Empty; + public string Email { get; set; } = string.Empty; + public string Password { get; set; } = string.Empty; + public string Role { get; set; } = string.Empty; // Admin, Teacher, Student + + // Only for Students + public string? Session { get; set; } // e.g. "2020-24", "2022-26" + public string? Section { get; set; } // e.g. "A", "B", "C" + + public DateTime CreatedAt { get; set; } = DateTime.UtcNow; + } +} diff --git a/Infrastructure_Service/AppDbContext/ProjectAllocationDbContext.cs b/Infrastructure_Service/AppDbContext/ProjectAllocationDbContext.cs new file mode 100644 index 0000000..3a6159d --- /dev/null +++ b/Infrastructure_Service/AppDbContext/ProjectAllocationDbContext.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Infrastructure_Service.AppDbContext +{ + public class ProjectAllocationDbContext : DBcontext + { + public DbSet Users { get; set; } + public DbSet Projects { get; set; } + public DbSet ProjectRequests { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlite("Data Source=project_allocation.db"); + } + + + + } +} diff --git a/Infrastructure_Service/Infrastructure_Service.csproj b/Infrastructure_Service/Infrastructure_Service.csproj index b760144..4fe1718 100644 --- a/Infrastructure_Service/Infrastructure_Service.csproj +++ b/Infrastructure_Service/Infrastructure_Service.csproj @@ -6,4 +6,17 @@ enable + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + +