zinab_elgendy před 6 měsíci
rodič
revize
59b69d365a
26 změnil soubory, kde provedl 7319 přidání a 41 odebrání
  1. 1 1
      MTWorkHR.API/Program.cs
  2. 1 0
      MTWorkHR.Application/Dtos/Identity/CompanyUserDto.cs
  3. 4 0
      MTWorkHR.Application/Dtos/Identity/UserDto.cs
  4. 3 1
      MTWorkHR.Application/Dtos/User/ProjectDto.cs
  5. 17 0
      MTWorkHR.Application/Dtos/User/ProjectTeamDto.cs
  6. 1 0
      MTWorkHR.Application/Mapper/MappingProfile.cs
  7. 2 0
      MTWorkHR.Application/Services/Interfaces/ITeamService.cs
  8. 53 18
      MTWorkHR.Application/Services/Task/ProjectService.cs
  9. 5 0
      MTWorkHR.Application/Services/User/CompanyService.cs
  10. 6 1
      MTWorkHR.Application/Services/User/TeamService.cs
  11. 21 0
      MTWorkHR.Application/Services/User/UserService.cs
  12. 3 0
      MTWorkHR.Core/Entities/User/Project.cs
  13. 22 0
      MTWorkHR.Core/Entities/User/ProjectTeam.cs
  14. 2 2
      MTWorkHR.Core/IRepositories/Task/IProjectRepository.cs
  15. 21 0
      MTWorkHR.Core/IRepositories/User/IProjectTeamRepository.cs
  16. 2 0
      MTWorkHR.Core/IUnitOfWork/IUnitOfWork.cs
  17. 2 1
      MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs
  18. 3426 0
      MTWorkHR.Infrastructure/Migrations/20240718135952_altrProjectTeams.Designer.cs
  19. 63 0
      MTWorkHR.Infrastructure/Migrations/20240718135952_altrProjectTeams.cs
  20. 3424 0
      MTWorkHR.Infrastructure/Migrations/20240722112517_altrProjectTeam.Designer.cs
  21. 98 0
      MTWorkHR.Infrastructure/Migrations/20240722112517_altrProjectTeam.cs
  22. 64 0
      MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs
  23. 0 17
      MTWorkHR.Infrastructure/Repositories/Task/ProjectRepository.cs
  24. 33 0
      MTWorkHR.Infrastructure/Repositories/User/ProjectRepository.cs
  25. 41 0
      MTWorkHR.Infrastructure/Repositories/User/ProjectTeamRepository.cs
  26. 4 0
      MTWorkHR.Infrastructure/UnitOfWork/UnitOfWork.cs

+ 1 - 1
MTWorkHR.API/Program.cs

@@ -20,7 +20,7 @@ var config = new AppSettingsConfiguration();
 // Add services to the container.
 builder.Services.AddDbContext<HRDataContext>(options =>
 {
-    options.UseSqlServer(config.ConnectionStrings.LocalConnectionString);
+    options.UseSqlServer(config.ConnectionStrings.MTWorkHRConnectionString);
   //  options.UseSqlServer(builder.Configuration.GetSection("ConnectionStrings:MTWorkHRConnectionString").Value);
 });
 

+ 1 - 0
MTWorkHR.Application/Dtos/Identity/CompanyUserDto.cs

@@ -34,5 +34,6 @@ namespace MTWorkHR.Application.Models
         public decimal? IncomeTaxValue { get; set; }
         public IList<AttachmentDto>? UserAttachments{ get; set; }
         public UserAddressDto? UserAddress{ get; set; }
+
     }
 }

+ 4 - 0
MTWorkHR.Application/Dtos/Identity/UserDto.cs

@@ -56,6 +56,10 @@ namespace MTWorkHR.Application.Models
         public IFormFile? EduCertificateAttach { get; set; }
         public IFormFile? ExperienceCertificateAttach { get; set; }
         public IFormFile? ProfCertificateAttach { get; set; }
+        //Company attach
+        public IFormFile? CommercialRegAttach { get; set; }
+        public IFormFile? TaxDeclarationAttach { get; set; }
+        public IFormFile? IdAttach { get; set; }
 
         public IList<UserRoleDto>? UserRoles { get; set; }
         public IList<AttachmentDto>? UserAttachments{ get; set; }

+ 3 - 1
MTWorkHR.Application/Dtos/User/ProjectDto.cs

@@ -9,7 +9,9 @@ namespace MTWorkHR.Application.Models
     {
         public string? NameAr { get; set; }
         public string? NameEn { get; set; }
+        public string? Desc { get; set; }
         public string? CreateUser { get; set; }
-
+        public List<long>? ProjectTeamIds { get; set; }
+        public List<ProjectTeamDto>? ProjectTeams { get; set; }
     }
 }

+ 17 - 0
MTWorkHR.Application/Dtos/User/ProjectTeamDto.cs

@@ -0,0 +1,17 @@
+using Microsoft.AspNetCore.Http;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace MTWorkHR.Application.Models
+{
+    public class ProjectTeamDto : EntityDto
+    {
+        public long ProjectId { get; set; }
+        [Required]
+        public long TeamId { get; set; }
+        public string? TeamName { get; set; }
+
+    }
+}

+ 1 - 0
MTWorkHR.Application/Mapper/MappingProfile.cs

@@ -89,6 +89,7 @@ namespace MTWorkHR.Application.Mapper
                 .ForMember(d => d.CreateDate, o => o.Ignore())
                 .ForMember(d => d.CreateUser, o => o.Ignore());
             CreateMap<MeetingUser, MeetingUserDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
+            CreateMap<ProjectTeam, ProjectTeamDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
 
             CreateMap<Attendance, AttendanceDto>().ForMember(d=> d.WeekDay , o=> o.MapFrom(s=> s.AttendanceDate.DayOfWeek)).ReverseMap()
                 .ForMember(d => d.CreateDate, o => o.Ignore());

+ 2 - 0
MTWorkHR.Application/Services/Interfaces/ITeamService.cs

@@ -8,5 +8,7 @@ namespace MTWorkHR.Application.Services.Interfaces
     public interface ITeamService : IService<Team, TeamDto, TeamAllDto>
     {
         Task<bool> AssignAdminManager(TeamUserDto teamUser);
+        Task<string> GetTeamName(long teamId);
+       
     }
 }

+ 53 - 18
MTWorkHR.Application/Services/Task/ProjectService.cs

@@ -21,34 +21,69 @@ namespace MTWorkHR.Application.Services
         private readonly IUnitOfWork _unitOfWork;
         //private readonly AppSettingsConfiguration _configuration;
         //private readonly GlobalInfo _globalInfo;
+        private readonly ITeamService _teamService;
 
-        public ProjectService(IUnitOfWork unitOfWork):base(unitOfWork)
+        public ProjectService(IUnitOfWork unitOfWork, ITeamService teamService) : base(unitOfWork)
         {
             _unitOfWork = unitOfWork;
+            _teamService = teamService;
         }
 
+        public override async Task<ProjectDto> GetById(long id)
+        {
+            var entity = await _unitOfWork.Project.GetByIdWithAllChildren(id);
+            var response = MapperObject.Mapper.Map<ProjectDto>(entity);
+            if (response != null)
+                response.ProjectTeamIds = response.ProjectTeams != null ? response.ProjectTeams?.Select(u => u.TeamId).ToList() : new List<long>();
+            return response;
+        }
+        public override async Task<ProjectDto> Create(ProjectDto input)
+        {
+            var entity = MapperObject.Mapper.Map<Project>(input);
+
+            if (entity is null)
+            {
+                throw new AppException(ExceptionEnum.MapperIssue);
+            }
+            entity.ProjectTeams = input.ProjectTeamIds?.Select(s => new ProjectTeam { TeamId = s, TeamName = _teamService.GetTeamName(s).Result }).ToList();
 
-        //public override async Task<ProjectDto> GetById(long id)
-        //{
-        //    var entity = await _unitOfWork.Project.GetByIdAsync(id);
-        //    var response = MapperObject.Mapper.Map<ProjectDto>(entity);
-        //    return response;
-        //}
+            var Project = await _unitOfWork.Project.AddAsync(entity);
+            await _unitOfWork.CompleteAsync();
 
-        //public override async Task<List<ProjectDto>> GetAll()
-        //{
-        //    var projects = await _unitOfWork.Project.GetAllAsync();
-        //    var response = MapperObject.Mapper.Map<List<ProjectDto>>(projects);
-        //    return response;
-        //}
+            var response = MapperObject.Mapper.Map<ProjectDto>(Project);
+            response.ProjectTeamIds = input.ProjectTeamIds;
+            return response;
+        }
+
+        public override async Task<ProjectDto> Update(ProjectDto input)
+        {
+            var entity = await _unitOfWork.Project.GetByIdWithAllChildren(input.Id);
+            if (entity is null)
+                throw new AppException(ExceptionEnum.RecordNotExist);
+            entity.NameAr = input.NameAr;
+            entity.NameEn = input.NameEn;
+            var oldUsers = entity.ProjectTeams?.Select(s => s.TeamId);
 
-        //public override async Task Delete(long id)
-        //{
-        //    var entity = await _unitOfWork.Project.GetByIdAsync(id);
-        //    await _unitOfWork.Project.DeleteAsync(entity);
-        //}
+            var NewItems = input.ProjectTeamIds?.Where(u => !oldUsers.Contains(u));
+            var newProjectTeams = NewItems?.Select(s => new ProjectTeam { ProjectId = input.Id, TeamId = s, TeamName = _teamService.GetTeamName(s).Result}).ToList();
+            var DeletedItems = oldUsers?.Where(u => !input.ProjectTeamIds.Contains(u));
+            _unitOfWork.BeginTran();
+            foreach (var delUser in DeletedItems)
+            {
+                var removeItem = entity.ProjectTeams?.FirstOrDefault(u => u.TeamId == delUser);
+                if (removeItem != null) await _unitOfWork.ProjectTeam.DeleteAsync(removeItem);
+            }
+            foreach (var newteam in newProjectTeams)
+            {
+                await _unitOfWork.ProjectTeam.AddAsync(newteam);
+            }
 
+            await _unitOfWork.CompleteAsync();
+            _unitOfWork.CommitTran();
 
+            var response = Mapper.MapperObject.Mapper.Map<ProjectDto>(entity);
+            return response;
+        }
 
     }
 }

+ 5 - 0
MTWorkHR.Application/Services/User/CompanyService.cs

@@ -50,6 +50,11 @@ namespace MTWorkHR.Application.Services
                 var entity = await _unitOfWork.Company.GetByIdAsync(_globalInfo.CompanyId.Value);
                 companyResponse = MapperObject.Mapper.Map<CompanyDto>(entity);
                 var userDto = await _userService.GetById(entity.UserId);
+                companyResponse.CommercialRegAttach = userDto.CommercialRegAttach;
+                companyResponse.PassportAttach = userDto.PassportAttach;
+                companyResponse.IdAttach = userDto.IdAttach;
+                companyResponse.ExperienceCertificateAttach = userDto.ExperienceCertificateAttach;
+                companyResponse.TaxDeclarationAttach = userDto.TaxDeclarationAttach;
                 companyResponse.CompanyUser = MapperObject.Mapper.Map<CompanyUserDto>(userDto);
                 companyResponse.UserType = companyResponse.CompanyUser.UserType;
             }

+ 6 - 1
MTWorkHR.Application/Services/User/TeamService.cs

@@ -150,9 +150,14 @@ namespace MTWorkHR.Application.Services
             return result;
         }
 
-       
 
 
+        public async Task<string> GetTeamName(long teamId)
+        {
+            var entity = await _unitOfWork.Team.GetByIdAsync(teamId);
+            var name = entity == null ? "" : GlobalInfo.lang.ToLower() == "ar"?  entity.NameAr: entity.NameEn;
+            return name;
+        }
 
     }
 }

+ 21 - 0
MTWorkHR.Application/Services/User/UserService.cs

@@ -98,6 +98,27 @@ namespace MTWorkHR.Application.Services
                             case 2:
                                 response.PassportAttach = file;
                                 break;
+                            case 3:
+                                response.EduCertificateAttach = file;
+                                break;
+                            case 4:
+                                response.ExperienceCertificateAttach= file;
+                                break;
+                            case 5:
+                                response.ProfCertificateAttach = file;
+                                break;
+                            case 6:
+                                response.CommercialRegAttach = file;
+                                break;
+                            case 7:
+                                response.TaxDeclarationAttach = file;
+                                break;
+                            case 8:
+                                response.IdAttach = file;
+                                break;
+                            case 9:
+                                response.ProfileImage = file;
+                                break;
                         }
                     }
                    

+ 3 - 0
MTWorkHR.Core/Entities/User/Project.cs

@@ -18,7 +18,10 @@ namespace MTWorkHR.Core.Entities
         [MaxLength(250)]
         [Filter]
         public string NameEn { get; set; }
+        public string Desc { get; set; }
         public long CompanyId { get; set; }
+        public List<ProjectTeam>? ProjectTeams { get; set; }
+
 
     }
 }

+ 22 - 0
MTWorkHR.Core/Entities/User/ProjectTeam.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Core.Entities.Base;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class ProjectTeam : AuditEntity
+    {
+
+        public long ProjectId{ get; set; }
+        [ForeignKey("ProjectId")]
+        public Project? Project { get; set; }
+        public long TeamId { get; set; }
+        public string TeamName { get; set; }
+
+    }
+}

+ 2 - 2
MTWorkHR.Core/IRepositories/Task/IProjectRepository.cs

@@ -1,6 +1,4 @@
 using MTWorkHR.Core.Entities;
-using MTWorkHR.Core.Entities;
-using MTWorkHR.Core.IDto;
 using MTWorkHR.Core.IRepositories.Base;
 using System;
 using System.Collections.Generic;
@@ -12,5 +10,7 @@ namespace MTWorkHR.Core.IRepositories
 {
     public interface IProjectRepository : IRepository<Project>
     {
+        Task<Project> GetByIdWithAllChildren(long id);
+        Task<Tuple<IQueryable<Project>, int>> GetAllWithChildrenAsync();
     }
 }

+ 21 - 0
MTWorkHR.Core/IRepositories/User/IProjectTeamRepository.cs

@@ -0,0 +1,21 @@
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IDto;
+using MTWorkHR.Core.IRepositories.Base;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.IRepositories
+{
+    public interface IProjectTeamRepository : IRepository<ProjectTeam>
+    {
+        Task<Tuple<ICollection<ProjectTeam>, int>> GetAllAsync(IPagingInputDto pagingInputDto);
+        Task<ProjectTeam> GetByIdAsync(long id);
+        Task<ProjectTeam> AddAsync(ProjectTeam entity);
+        Task<IList<ProjectTeam>> AddRangeAsync(IList<ProjectTeam> entity);
+        Task DeleteAsync(ProjectTeam entity);
+        Task DeleteAsync(IEnumerable<ProjectTeam> entities);
+    }
+}

+ 2 - 0
MTWorkHR.Core/IUnitOfWork/IUnitOfWork.cs

@@ -10,6 +10,8 @@ namespace MTWorkHR.Core.UnitOfWork
     {
         IPermissionRepository Permission { get; }
         IProjectRepository Project { get; }
+        IProjectTeamRepository ProjectTeam { get; }
+
         IUserTaskRepository UserTask { get; }
         IUserTaskAttachmentRepository UserTaskAttachment { get; }
         ITaskStatusRepository UserTaskStatus { get; }

+ 2 - 1
MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs

@@ -31,7 +31,7 @@ namespace MTWorkHR.Infrastructure
             
             services.AddDbContext<HRDataContext>(options =>
                 options.UseSqlServer(
-                    config.ConnectionStrings.LocalConnectionString  //configuration.GetSection("ConnectionString:MTWorkHRConnectionString").Value
+                    config.ConnectionStrings.MTWorkHRConnectionString  //configuration.GetSection("ConnectionString:MTWorkHRConnectionString").Value
                     ));
            
             services.AddIdentity<ApplicationUser, ApplicationRole>().AddEntityFrameworkStores<HRDataContext>().AddDefaultTokenProviders();
@@ -81,6 +81,7 @@ namespace MTWorkHR.Infrastructure
             services.AddScoped(typeof(IUniversityRepository), typeof(UniversityRepository));
             services.AddScoped(typeof(ILoginOTPRepository), typeof(LoginOTPRepository));
             services.AddScoped(typeof(ICityRepository), typeof(CityRepository));
+            services.AddScoped(typeof(IProjectTeamRepository), typeof(ProjectTeamRepository));
 
 
 

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 3426 - 0
MTWorkHR.Infrastructure/Migrations/20240718135952_altrProjectTeams.Designer.cs


+ 63 - 0
MTWorkHR.Infrastructure/Migrations/20240718135952_altrProjectTeams.cs

@@ -0,0 +1,63 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrProjectTeams : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AddColumn<string>(
+                name: "Desc",
+                table: "Projects",
+                type: "nvarchar(max)",
+                nullable: false,
+                defaultValue: "");
+
+            migrationBuilder.CreateTable(
+                name: "ProjectTeam",
+                columns: table => new
+                {
+                    Id = table.Column<long>(type: "bigint", nullable: false)
+                        .Annotation("SqlServer:Identity", "1, 1"),
+                    CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
+                    UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    ProjectId = table.Column<long>(type: "bigint", nullable: false),
+                    TeamId = table.Column<long>(type: "bigint", nullable: true),
+                    AssignedUserId = table.Column<string>(type: "nvarchar(max)", nullable: false),
+                    AssignedUserName = table.Column<string>(type: "nvarchar(max)", nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_ProjectTeam", x => x.Id);
+                    table.ForeignKey(
+                        name: "FK_ProjectTeam_Projects_TeamId",
+                        column: x => x.TeamId,
+                        principalTable: "Projects",
+                        principalColumn: "Id");
+                });
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ProjectTeam_TeamId",
+                table: "ProjectTeam",
+                column: "TeamId");
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropTable(
+                name: "ProjectTeam");
+
+            migrationBuilder.DropColumn(
+                name: "Desc",
+                table: "Projects");
+        }
+    }
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 3424 - 0
MTWorkHR.Infrastructure/Migrations/20240722112517_altrProjectTeam.Designer.cs


+ 98 - 0
MTWorkHR.Infrastructure/Migrations/20240722112517_altrProjectTeam.cs

@@ -0,0 +1,98 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrProjectTeam : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropForeignKey(
+                name: "FK_ProjectTeam_Projects_TeamId",
+                table: "ProjectTeam");
+
+            migrationBuilder.DropIndex(
+                name: "IX_ProjectTeam_TeamId",
+                table: "ProjectTeam");
+
+            migrationBuilder.DropColumn(
+                name: "AssignedUserId",
+                table: "ProjectTeam");
+
+            migrationBuilder.RenameColumn(
+                name: "AssignedUserName",
+                table: "ProjectTeam",
+                newName: "TeamName");
+
+            migrationBuilder.AlterColumn<long>(
+                name: "TeamId",
+                table: "ProjectTeam",
+                type: "bigint",
+                nullable: false,
+                defaultValue: 0L,
+                oldClrType: typeof(long),
+                oldType: "bigint",
+                oldNullable: true);
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ProjectTeam_ProjectId",
+                table: "ProjectTeam",
+                column: "ProjectId");
+
+            migrationBuilder.AddForeignKey(
+                name: "FK_ProjectTeam_Projects_ProjectId",
+                table: "ProjectTeam",
+                column: "ProjectId",
+                principalTable: "Projects",
+                principalColumn: "Id",
+                onDelete: ReferentialAction.Cascade);
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropForeignKey(
+                name: "FK_ProjectTeam_Projects_ProjectId",
+                table: "ProjectTeam");
+
+            migrationBuilder.DropIndex(
+                name: "IX_ProjectTeam_ProjectId",
+                table: "ProjectTeam");
+
+            migrationBuilder.RenameColumn(
+                name: "TeamName",
+                table: "ProjectTeam",
+                newName: "AssignedUserName");
+
+            migrationBuilder.AlterColumn<long>(
+                name: "TeamId",
+                table: "ProjectTeam",
+                type: "bigint",
+                nullable: true,
+                oldClrType: typeof(long),
+                oldType: "bigint");
+
+            migrationBuilder.AddColumn<string>(
+                name: "AssignedUserId",
+                table: "ProjectTeam",
+                type: "nvarchar(max)",
+                nullable: false,
+                defaultValue: "");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ProjectTeam_TeamId",
+                table: "ProjectTeam",
+                column: "TeamId");
+
+            migrationBuilder.AddForeignKey(
+                name: "FK_ProjectTeam_Projects_TeamId",
+                table: "ProjectTeam",
+                column: "TeamId",
+                principalTable: "Projects",
+                principalColumn: "Id");
+        }
+    }
+}

+ 64 - 0
MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs

@@ -1666,6 +1666,10 @@ namespace MTWorkHR.Infrastructure.Migrations
                         .HasColumnType("nvarchar(450)")
                         .HasColumnOrder(8);
 
+                    b.Property<string>("Desc")
+                        .IsRequired()
+                        .HasColumnType("nvarchar(max)");
+
                     b.Property<bool>("IsDeleted")
                         .HasColumnType("bit")
                         .HasColumnOrder(7);
@@ -1696,6 +1700,50 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.ToTable("Projects");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ProjectTeam", b =>
+                {
+                    b.Property<long>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bigint")
+                        .HasColumnOrder(0);
+
+                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
+
+                    b.Property<DateTime>("CreateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(3);
+
+                    b.Property<string>("CreateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(1);
+
+                    b.Property<long>("ProjectId")
+                        .HasColumnType("bigint");
+
+                    b.Property<long>("TeamId")
+                        .HasColumnType("bigint");
+
+                    b.Property<string>("TeamName")
+                        .IsRequired()
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime?>("UpdateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(4);
+
+                    b.Property<string>("UpdateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(2);
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("ProjectId");
+
+                    b.ToTable("ProjectTeam");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.Qualification", b =>
                 {
                     b.Property<long>("Id")
@@ -3092,6 +3140,17 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Navigation("OrderType");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ProjectTeam", b =>
+                {
+                    b.HasOne("MTWorkHR.Core.Entities.Project", "Project")
+                        .WithMany("ProjectTeams")
+                        .HasForeignKey("ProjectId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("Project");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.TeamUser", b =>
                 {
                     b.HasOne("MTWorkHR.Core.Entities.Team", "Team")
@@ -3327,6 +3386,11 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Navigation("MeetingUsers");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.Project", b =>
+                {
+                    b.Navigation("ProjectTeams");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.Team", b =>
                 {
                     b.Navigation("TeamUsers");

+ 0 - 17
MTWorkHR.Infrastructure/Repositories/Task/ProjectRepository.cs

@@ -1,17 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using MTWorkHR.Core.Entities;
-using MTWorkHR.Core.IDto;
-using MTWorkHR.Infrastructure.Entities;
-using MTWorkHR.Infrastructure.DBContext;
-using MTWorkHR.Core.IRepositories;
-
-namespace MTWorkHR.Infrastructure.Repositories
-{
-    public class ProjectRepository : Repository<Project>, IProjectRepository
-    {
-        public ProjectRepository(HRDataContext context) : base(context)
-        {
-        }
-
-    }
-}

+ 33 - 0
MTWorkHR.Infrastructure/Repositories/User/ProjectRepository.cs

@@ -0,0 +1,33 @@
+using Microsoft.EntityFrameworkCore;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IDto;
+using MTWorkHR.Infrastructure.Entities;
+using MTWorkHR.Infrastructure.DBContext;
+using MTWorkHR.Core.IRepositories;
+
+namespace MTWorkHR.Infrastructure.Repositories
+{
+    public class ProjectRepository : Repository<Project>, IProjectRepository
+    {
+        private readonly DbSet<Project> dbSet;
+
+        public ProjectRepository(HRDataContext context) : base(context)
+        {
+            dbSet = context.Set<Project>();
+        }
+        
+        public async Task<Project> GetByIdWithAllChildren(long id)
+        {
+            return await dbSet
+                .Include(x => x.ProjectTeams)
+                .FirstOrDefaultAsync(x => x.Id == id);
+        }
+        public async Task<Tuple<IQueryable<Project>, int>> GetAllWithChildrenAsync()
+        {
+            var query = dbSet.Include(x => x.ProjectTeams).AsQueryable();
+            var total = await query.CountAsync();
+
+            return new Tuple<IQueryable<Project>, int>(query, total);
+        }
+    }
+}

+ 41 - 0
MTWorkHR.Infrastructure/Repositories/User/ProjectTeamRepository.cs

@@ -0,0 +1,41 @@
+using Microsoft.EntityFrameworkCore;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IDto;
+using MTWorkHR.Core.IRepositories;
+using MTWorkHR.Infrastructure.Entities;
+using MTWorkHR.Infrastructure.DBContext;
+
+namespace MTWorkHR.Infrastructure.Repositories
+{
+    public class ProjectTeamRepository : Repository<ProjectTeam>, IProjectTeamRepository
+    {
+        private readonly DbSet<ProjectTeam> dbSet;
+
+        public ProjectTeamRepository(HRDataContext context) : base(context)
+        {
+            dbSet = context.Set<ProjectTeam>();
+
+        }
+        public virtual async Task<ProjectTeam> AddAsync(ProjectTeam entity)
+        {
+            await dbSet.AddAsync(entity);
+            return entity;
+        }
+
+        public virtual async Task<IList<ProjectTeam>> AddRangeAsync(IList<ProjectTeam> entity)
+        {
+            await dbSet.AddRangeAsync(entity);
+            return entity;
+        }
+
+        public virtual async Task DeleteAsync(ProjectTeam entity)
+        {
+            dbSet.Remove(entity);
+        }
+
+        public virtual async Task DeleteAsync(IEnumerable<ProjectTeam> entities)
+        {
+            dbSet.RemoveRange(entities);
+        }
+    }
+}

+ 4 - 0
MTWorkHR.Infrastructure/UnitOfWork/UnitOfWork.cs

@@ -21,6 +21,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
         public IUserTaskAttachmentRepository UserTaskAttachment { get; }
 
         public IProjectRepository Project { get; }
+        public IProjectTeamRepository ProjectTeam { get; }
         public ITeamRepository Team{ get; }
         public ITeamUserRepository TeamUser { get; }
         public IMeetingRepository Meeting{ get; }
@@ -62,6 +63,8 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             , ICityRepository city
             , ITeamUserRepository teamUser
             , IMeetingUserRepository meetingUser
+,
+IProjectTeamRepository projectTeam
 
             )
         {
@@ -89,6 +92,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             City = city;
             TeamUser = teamUser;
             MeetingUser = meetingUser;
+            ProjectTeam = projectTeam;
         }
 
         public async Task<int> CompleteAsync()