ソースを参照

TeamUserListIds

zinab_elgendy 7 ヶ月 前
コミット
51300f3e91

+ 41 - 1
MTWorkHR.API/appsettings.Development.json

@@ -4,5 +4,45 @@
       "Default": "Information",
       "Microsoft.AspNetCore": "Warning"
     }
-  }
+  },
+  "ConnectionStrings": {
+    "LocalConnectionString": "Server=.;Database=MTWorkHRDB;User=sa;Password=p@ssw0rd;MultipleActiveResultSets=true;Integrated Security=True;Encrypt=False"
+    // "HRIdentityDB": "Server=localhost;Database=HRIdentityDB;User=sa;Password=p@ssw0rd;MultipleActiveResultSets=true"
+    //Data Source=.;Initial Catalog=CBQ_VIVR;Integrated Security=True;Encrypt=False
+  },
+  "JwtSettings": {
+    "SecretKey": "dkajsdfhalksjdhfalksdjhfalksdjfhaslkdjfhasdlkfhjasdlkfhasdlkfhjasdfhh",
+    "Audience": "http://localhost:28222",
+    "Issuer": "https://localhost:44325",
+    "DurationInMinutes": 60000
+  },
+  "CookieOptions": {
+    "SessionCookieExpiryInSeconds": 3600,
+    "SurveyCookieExpiryInSeconds": 1800
+  },
+  "DbConfig": {
+    "RunMigrations": true
+  },
+  "AttachmentSettings": {
+    "TempAttachment": "C:\\Attachment\\Temp",
+    "ActualAttachment": "C:\\Attachment\\Actual"
+  },
+  "MailSettings": {
+    "ApiKey": "SendGrid-Key",
+    "FromAddress": "eng_z@live.com",
+    "FromName": "Hr Management System",
+    "Password": "111111111111",
+    "Host": "smtp-mail.outlook.com",
+    "Port": 587,
+    "TemplatePath": "C:\\Attachment\\MailTemp\\EmailTemplate.html"
+  },
+  "OTPSettings": {
+    "Length": 6,
+    "ExpirePeriodInMinutes": 3000,
+    "SendEmail": true,
+    "AllowZeros": true,
+    "MessageBody": "Dear User, Your OTP is {0}. Use this passcode to proceed.",
+    "MessageSubject": "OTP"
+  },
+  "AllowedHosts": "*"
 }

+ 3 - 2
MTWorkHR.API/appsettings.json

@@ -6,8 +6,9 @@
     }
   },
   "ConnectionStrings": {
-    "MTWorkHRConnectionString": "Server=tcp:mtworksqlserver.database.windows.net,1433;Initial Catalog=MTWorkHRDB;Persist Security Info=False;User ID=MTWorkHR;Password=MTWork@12345;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
-  //  "MTWorkHRConString": "Server=.;Database=MTWorkHRDB;User=sa;Password=p@ssw0rd;MultipleActiveResultSets=true;Integrated Security=True;Encrypt=False"
+    "MTWorkHRConnectionString": "Server=tcp:mtworksqlserver.database.windows.net,1433;Initial Catalog=MTWorkHRDB;Persist Security Info=False;User ID=MTWorkHR;Password=MTWork@12345;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
+    "LocalConnectionString": "Server=.;Database=MTWorkHRDB;User=sa;Password=p@ssw0rd;MultipleActiveResultSets=true;Integrated Security=True;Encrypt=False",
+    "BlobConnectionString": "DefaultEndpointsProtocol=https;AccountName=mtworkhrstorage;AccountKey=8EfjO3+4jHmf6QSnW5PCFDWry8oXSAM4pGtlIviImd5yCo6lxWDUpnzfT6ppHJqhKztuGU9IL4Ai+ASt16oHZA==;EndpointSuffix=core.windows.net"
     // "HRIdentityDB": "Server=localhost;Database=HRIdentityDB;User=sa;Password=p@ssw0rd;MultipleActiveResultSets=true"
     //Data Source=.;Initial Catalog=CBQ_VIVR;Integrated Security=True;Encrypt=False
   },

+ 25 - 0
MTWorkHR.Application/Dtos/User/TeamAllDto.cs

@@ -0,0 +1,25 @@
+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 TeamAllDto 
+    {
+        public long Id { get; set; }
+
+        [Required]
+        [MaxLength(250)]
+        [Filter]
+        public string NameAr { get; set; }
+        [Required]
+        [MaxLength(250)]
+        [Filter]
+        public string NameEn { get; set; }
+        public int TeamUserCount { get; set; }
+        public string? CreateUser { get; set; }
+
+    }
+}

+ 1 - 0
MTWorkHR.Application/Dtos/User/TeamDto.cs

@@ -17,6 +17,7 @@ namespace MTWorkHR.Application.Models
         [Filter]
         public string NameEn { get; set; }
         public List<string>? TeamUserIds { get; set; }
+        public List<TeamUserDto>? TeamUsers { get; set; }
         public string? CreateUser { get; set; }
 
     }

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

@@ -79,6 +79,10 @@ namespace MTWorkHR.Application.Mapper
             CreateMap<UserTaskHistoryDto, UserTaskHistory>().ForMember(d => d.CreateDate, o => o.Ignore()).ReverseMap();
             CreateMap<Team, TeamDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
             CreateMap<TeamUserDto, TeamUser>().ForMember(d => d.CreateDate, o => o.Ignore()).ReverseMap();
+            CreateMap<Team, TeamAllDto>()
+             .ForMember(s => s.TeamUserCount, o => o.MapFrom(s => s.TeamUsers == null ? 0 :  s.TeamUsers.Count));
+
+
             CreateMap<Meeting, MeetingDto>();
             CreateMap<MeetingDto , Meeting>()
                 .ForMember(d => d.CreateDate, o => o.Ignore())

+ 1 - 1
MTWorkHR.Application/Services/Interfaces/ITeamService.cs

@@ -5,7 +5,7 @@ using System.Threading.Tasks;
 
 namespace MTWorkHR.Application.Services.Interfaces
 {
-    public interface ITeamService : IService<Team, TeamDto, TeamDto>
+    public interface ITeamService : IService<Team, TeamDto, TeamAllDto>
     {
         Task<bool> AssignAdminManager(TeamUserDto teamUser);
     }

+ 1 - 1
MTWorkHR.Application/Services/Interfaces/IUserService.cs

@@ -14,7 +14,7 @@ namespace MTWorkHR.Application.Identity
         Task<UserDto> GetById(string userId);
         Task<List<UserDto>> GetAllEmployees();
 
-
+        Task<UserDto> GetUserById(string id);
         Task Delete(string id);
         Task<UserDto> Create(UserDto input);
         Task<UserDto> Update(UserDto input);

+ 47 - 8
MTWorkHR.Application/Services/User/TeamService.cs

@@ -14,23 +14,54 @@ using MTWorkHR.Core.Email;
 using MTWorkHR.Core.Entities;
 using MTWorkHR.Infrastructure.UnitOfWorks;
 using System.Linq;
+using System.Linq.Dynamic.Core;
 
 namespace MTWorkHR.Application.Services
 {
-    public class TeamService : BaseService<Team, TeamDto, TeamDto>, ITeamService
+    public class TeamService : BaseService<Team, TeamDto, TeamAllDto>, ITeamService
     {
         private readonly IUnitOfWork _unitOfWork;
+        private readonly IUserService _userService;
       
-        public TeamService(IUnitOfWork unitOfWork):base(unitOfWork)
+        public TeamService(IUnitOfWork unitOfWork, IUserService userService) : base(unitOfWork)
         {
             _unitOfWork = unitOfWork;
+            _userService = userService;
         }
 
+        public override  async Task<PagingResultDto<TeamAllDto>> GetAll(PagingInputDto PagingInputDto)
+        {
+            var res = await _unitOfWork.Team.GetAllWithChildrenAsync();
+            var query = res.Item1;
+            if (PagingInputDto.Filter != null)
+            {
+                var filter = PagingInputDto.Filter;
+                query = query.Where(u => u.NameAr.Contains(filter) );
+            }
+           
+            var order = query.OrderBy(PagingInputDto.OrderByField + " " + PagingInputDto.OrderType);
+
+            var page = order.Skip((PagingInputDto.PageNumber * PagingInputDto.PageSize) - PagingInputDto.PageSize).Take(PagingInputDto.PageSize);
 
+            var total = await query.CountAsync();
+
+            var list = MapperObject.Mapper
+                .Map<IList<TeamAllDto>>(await page.ToListAsync());
+
+            var response = new PagingResultDto<TeamAllDto>
+            {
+                Result = list,
+                Total = total
+            };
+
+            return response;
+        }
         public override async Task<TeamDto> GetById(long id)
         {
             var entity = await _unitOfWork.Team.GetByIdWithAllChildren(id);
             var response = MapperObject.Mapper.Map<TeamDto>(entity);
+            if(response != null)
+                response.TeamUserIds = response.TeamUsers != null ? response.TeamUsers?.Select(u => u.AssignedUserId).ToList() : new List<string>();
             return response;
         }
         public override async Task<TeamDto> Create(TeamDto input)
@@ -41,18 +72,24 @@ namespace MTWorkHR.Application.Services
             {
                 throw new AppException(ExceptionEnum.MapperIssue);
             }
-            entity.TeamUsers = input.TeamUserIds?.Select(s => new TeamUser { AssignedUserId = s, IsAdmin = false }).ToList();
+            entity.TeamUsers = input.TeamUserIds?.Select(s => new TeamUser { AssignedUserId = s,AssignedUserName = GetUserName(s).Result, IsAdmin = false }).ToList();
             
             var team = await _unitOfWork.Team.AddAsync(entity);
             await _unitOfWork.CompleteAsync();
 
             var response = MapperObject.Mapper.Map<TeamDto>(team);
+            response.TeamUserIds = input.TeamUserIds;
             return response;
         }
-
+        private async Task<string> GetUserName(string userId)
+        {
+            var entity = await _userService.GetUserById(userId);
+            var name = entity == null ? "" : entity.FirstName + " " + entity.LastName;
+            return name;
+        }
         public override async Task<TeamDto> Update(TeamDto input)
         {
-            var entity = await _unitOfWork.Team.GetByIdAsync(input.Id);
+            var entity = await _unitOfWork.Team.GetByIdWithAllChildren(input.Id);
             if (entity is null)
                 throw new AppException(ExceptionEnum.RecordNotExist);
             entity.NameAr = input.NameAr;
@@ -60,19 +97,21 @@ namespace MTWorkHR.Application.Services
             var oldUsers = entity.TeamUsers?.Select(s => s.AssignedUserId);
 
             var NewItems = input.TeamUserIds?.Where(u => !oldUsers.Contains(u));
-            var newTeamUsers = NewItems?.Select(s => new TeamUser { AssignedUserId = s, IsAdmin = false }).ToList();
+            var newTeamUsers = NewItems?.Select(s => new TeamUser {TeamId = input.Id, AssignedUserId = s, AssignedUserName = GetUserName(s).Result, IsAdmin = false }).ToList();
             var DeletedItems = oldUsers?.Where(u => !input.TeamUserIds.Contains(u));
+            _unitOfWork.BeginTran();
             foreach (var delUser in DeletedItems)
             {
                 var removeItem = entity.TeamUsers?.FirstOrDefault(u => u.AssignedUserId == delUser);
-                if(removeItem != null) entity.TeamUsers.Remove(removeItem);
+                if(removeItem != null) _unitOfWork.TeamUser.DeleteAsync(removeItem);
             }
             foreach (var newUsr in newTeamUsers)
             {
-                entity.TeamUsers.Add(newUsr);
+                _unitOfWork.TeamUser.AddAsync(newUsr);
             }
 
             await _unitOfWork.CompleteAsync();
+            _unitOfWork.CommitTran();
 
             var response = Mapper.MapperObject.Mapper.Map<TeamDto>(entity);
             return response;

+ 44 - 11
MTWorkHR.Application/Services/User/UserService.cs

@@ -69,6 +69,14 @@ namespace MTWorkHR.Application.Services
 
             return response;
         }
+        public async Task<UserDto> GetUserById(string id)
+        {
+            var entity = await _userManager.Users
+                .FirstOrDefaultAsync(x => x.Id == id);
+            var response = MapperObject.Mapper.Map<UserDto>(entity);
+
+            return response;
+        }
 
         //public async Task<List<UserDto>> GetAll(PagingInputDto pagingInput)
         //{
@@ -330,6 +338,31 @@ namespace MTWorkHR.Application.Services
 
                 if (entity == null)
                     throw new AppException(ExceptionEnum.RecordNotExist);
+                if (input.UserAttachments == null)
+                    input.UserAttachments = new List<AttachmentDto>();
+                if (input.CVAttach != null)
+                {
+                    input.UserAttachments.Add(new AttachmentDto { FileData = input.CVAttach, OriginalName = input.CVAttach?.Name, FileName = input.CVAttach?.FileName, AttachmentTypeId = 1 });
+                }
+                if (input.PassportAttach != null)
+                {
+                    input.UserAttachments.Add(new AttachmentDto { FileData = input.PassportAttach, OriginalName = input.PassportAttach?.Name, FileName = input.PassportAttach?.FileName, AttachmentTypeId = 2 });
+                }
+                if (input.EduCertificateAttach != null)
+                {
+                    input.UserAttachments.Add(new AttachmentDto { FileData = input.EduCertificateAttach, OriginalName = input.EduCertificateAttach?.Name, FileName = input.EduCertificateAttach?.FileName, AttachmentTypeId = 3 });
+                }
+                if (input.ExperienceCertificateAttach != null)
+                {
+                    input.UserAttachments.Add(new AttachmentDto { FileData = input.ExperienceCertificateAttach, OriginalName = input.ExperienceCertificateAttach?.Name, FileName = input.ExperienceCertificateAttach?.FileName, AttachmentTypeId = 4 });
+                }
+                if (input.ProfCertificateAttach != null)
+                {
+                    input.UserAttachments.Add(new AttachmentDto { FileData = input.ProfCertificateAttach, OriginalName = input.ProfCertificateAttach?.Name, FileName = input.ProfCertificateAttach?.FileName, AttachmentTypeId = 5 });
+                }
+                if (!await _fileService.CopyFileToActualFolder(input.UserAttachments.ToList()))
+                    throw new AppException(ExceptionEnum.CouldNotMoveFiles);
+
 
                 MapperObject.Mapper.Map(input, entity);
 
@@ -343,17 +376,17 @@ namespace MTWorkHR.Application.Services
                 //**saving userRoles
 
                 //add new user roles
-                var exsitedRolesIds = await _userRole.GetUserRoleIdsByUserID(input.Id);
-                if (input.UserRoles == null)
-                    input.UserRoles = new List<UserRoleDto>();
-                var newAddedRoles = MapperObject.Mapper.Map<List<IdentityUserRole<string>>>(input.UserRoles.Where(x => !exsitedRolesIds.Contains(x.RoleId)));
-                newAddedRoles.ForEach(x => x.UserId = input.Id);
-                await _userRole.AddRangeAsync(newAddedRoles);
-
-                //delete removed roles
-                var rolesIds = input.UserRoles.Select(x => x.RoleId).ToArray();
-                var removedRoles = await _userRole.GetRemovedUserRoleIdsByUserID(input.Id, rolesIds);
-                await _userRole.DeleteAsync(removedRoles.AsEnumerable());
+                //var exsitedRolesIds = await _userRole.GetUserRoleIdsByUserID(input.Id);
+                //if (input.UserRoles == null)
+                //    input.UserRoles = new List<UserRoleDto>();
+                //var newAddedRoles = MapperObject.Mapper.Map<List<IdentityUserRole<string>>>(input.UserRoles.Where(x => !exsitedRolesIds.Contains(x.RoleId)));
+                //newAddedRoles.ForEach(x => x.UserId = input.Id);
+                //await _userRole.AddRangeAsync(newAddedRoles);
+
+                ////delete removed roles
+                //var rolesIds = input.UserRoles.Select(x => x.RoleId).ToArray();
+                //var removedRoles = await _userRole.GetRemovedUserRoleIdsByUserID(input.Id, rolesIds);
+                //await _userRole.DeleteAsync(removedRoles.AsEnumerable());
 
 
                 await _unitOfWork.CompleteAsync();

+ 1 - 0
MTWorkHR.Core/Entities/User/TeamUser.cs

@@ -17,6 +17,7 @@ namespace MTWorkHR.Core.Entities
         public Team? Team { get; set; }
         [Required]
         public string AssignedUserId { get; set; }
+        public string AssignedUserName { get; set; }
         public bool IsAdmin { get; set; }
 
     }

+ 3 - 0
MTWorkHR.Core/Global/AppSettingsConfiguration.cs

@@ -22,6 +22,9 @@ namespace MTWorkHR.Core.Global
     public class ConnectionStrings
     {
         public string MTWorkHRConnectionString { get; set; }
+        public string LocalConnectionString { get; set; }
+        public string BlobConnectionString { get; set; }
+        
 
     }
     public class AttachmentSettings

+ 2 - 2
MTWorkHR.Core/IRepositories/User/ITeamRepository.cs

@@ -11,7 +11,7 @@ namespace MTWorkHR.Core.IRepositories
     public interface ITeamRepository : IRepository<Team>
     {
         Task<Team> GetByIdWithAllChildren(long id);
-       // Task<bool> AssignAdminManager(string userId, long teamId, bool isAdmin);
-
+        // Task<bool> AssignAdminManager(string userId, long teamId, bool isAdmin);
+        Task<Tuple<IQueryable<Team>, int>> GetAllWithChildrenAsync();
     }
 }

+ 21 - 0
MTWorkHR.Core/IRepositories/User/ITeamUserRepository.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 ITeamUserRepository : IRepository<TeamUser>
+    {
+        Task<Tuple<ICollection<TeamUser>, int>> GetAllAsync(IPagingInputDto pagingInputDto);
+        Task<TeamUser> GetByIdAsync(long id);
+        Task<TeamUser> AddAsync(TeamUser entity);
+        Task<IList<TeamUser>> AddRangeAsync(IList<TeamUser> entity);
+        Task DeleteAsync(TeamUser entity);
+        Task DeleteAsync(IEnumerable<TeamUser> entities);
+    }
+}

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

@@ -15,7 +15,8 @@ namespace MTWorkHR.Core.UnitOfWork
         ITaskStatusRepository UserTaskStatus { get; }
         IUserTaskHistoryRepository UserTaskHistory { get; }
         ICompanyRepository Company { get; }
-        ITeamRepository Team{ get; }
+        ITeamUserRepository TeamUser{ get; }
+        ITeamRepository Team { get; }
         IMeetingRepository Meeting{ get; }
         IAttendanceRepository Attendance { get; }
         IOrderTypeRepository OrderType { get; }

+ 6 - 4
MTWorkHR.Infrastructure/Configurations/UserConfiguration.cs

@@ -22,11 +22,11 @@ namespace MTWorkHR.Infrastructure.Configurations
                     Id = "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA",
                     FirstName = "Zinab",
                     LastName ="Elgendy",
-                    UserName = "Admin",
+                    UserName = "A@b.com",
                     Email = "a@b.com",
                     NormalizedEmail = "A@B.COM",
                     EmailConfirmed = true,
-                    NormalizedUserName = "ADMIN",
+                    NormalizedUserName = "A@B.COM",
                     PhoneNumber = "1234567890",
                     PhoneNumberConfirmed = true,
                     IsDeleted = false,
@@ -38,6 +38,7 @@ namespace MTWorkHR.Infrastructure.Configurations
                     TaxNumber = 111,
                     IncomeTaxValue = 1,QualificationId = null,
                     IdNumber = "123", DateOfBirth = new DateTime(2000,2,10), 
+                    CompanyId = 1,
                     PasswordHash = "AQAAAAIAAYagAAAAEPg+ASbciPFxtyxQq8Wx5ilBUQ0RbAoITXXkOQm1PzC5BzySX0sn/wUmOjBKPDGV9w==" //hasher.HashPassword(null, "P@ssword1")
                 },
                 new ApplicationUser
@@ -45,11 +46,11 @@ namespace MTWorkHR.Infrastructure.Configurations
                     Id = "AL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB",
                     FirstName = "Ali",
                     LastName = "Farok",
-                    UserName = "ali",
+                    UserName = "Ali@b.com",
                     Email = "ali@b.com",
                     NormalizedEmail = "ALI@B.COM",
                     EmailConfirmed = true,
-                    NormalizedUserName = "ALI",
+                    NormalizedUserName = "ALI@B.COM",
                     PhoneNumber = "1234567888",
                     PhoneNumberConfirmed = true,
                     DeleteUserId = null,
@@ -65,6 +66,7 @@ namespace MTWorkHR.Infrastructure.Configurations
                     QualificationId = null,
                     IdNumber = "343434",
                     DateOfBirth = new DateTime(2001, 5, 13),
+                    CompanyId = 1,
                     PasswordHash = "AQAAAAIAAYagAAAAEI3QJkcZjCH4Y8Db4rEgL8Mmll5oCvYcWiXZjQSN9bGW4SMcjHe3ZPMnkN/l9DmJeQ=="// hasher.HashPassword(null, "P@ssword1")
                 }) ;
         }

+ 1 - 0
MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs

@@ -66,6 +66,7 @@ namespace MTWorkHR.Infrastructure
             services.AddScoped(typeof(IUserTaskHistoryRepository), typeof(UserTaskHistoryRepository));
             
             services.AddScoped(typeof(ITeamRepository), typeof(TeamRepository));
+            services.AddScoped(typeof(ITeamUserRepository), typeof(TeamUserRepository));
             services.AddScoped(typeof(IMeetingRepository), typeof(MeetingRepository));
             services.AddScoped(typeof(IAttendanceRepository), typeof(AttendanceRepository));
             services.AddScoped(typeof(IOrderAllocationRepository), typeof(OrderAllocationRepository));

ファイルの差分が大きいため隠しています
+ 3328 - 0
MTWorkHR.Infrastructure/Migrations/20240611104022_altrTeamUser.Designer.cs


+ 54 - 0
MTWorkHR.Infrastructure/Migrations/20240611104022_altrTeamUser.cs

@@ -0,0 +1,54 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrTeamUser : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AddColumn<string>(
+                name: "AssignedUserName",
+                table: "TeamUser",
+                type: "nvarchar(max)",
+                nullable: false,
+                defaultValue: "");
+
+            migrationBuilder.InsertData(
+                table: "AspNetRoles",
+                columns: new[] { "Id", "ConcurrencyStamp", "CreateDate", "CreateUser", "DeleteUserId", "IsAdmin", "IsDeleted", "Name", "NormalizedName", "UpdateDate", "UpdateUser" },
+                values: new object[] { "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), null, null, false, false, "Contractor", "CONTRACTOR", null, null });
+
+            migrationBuilder.UpdateData(
+                table: "AttachmentTypes",
+                keyColumn: "Id",
+                keyValue: 6L,
+                column: "NameAr",
+                value: "التسجيل التجارى");
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DeleteData(
+                table: "AspNetRoles",
+                keyColumn: "Id",
+                keyValue: "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R");
+
+            migrationBuilder.DropColumn(
+                name: "AssignedUserName",
+                table: "TeamUser");
+
+            migrationBuilder.UpdateData(
+                table: "AttachmentTypes",
+                keyColumn: "Id",
+                keyValue: 6L,
+                column: "NameAr",
+                value: "شهادة الاحتراف");
+        }
+    }
+}

+ 14 - 1
MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs

@@ -288,7 +288,7 @@ namespace MTWorkHR.Infrastructure.Migrations
                         {
                             Id = 6L,
                             IsRequired = false,
-                            NameAr = "شهادة الاحتراف",
+                            NameAr = "التسجيل التجارى",
                             NameEn = "Commercial Regestration"
                         },
                         new
@@ -1964,6 +1964,10 @@ namespace MTWorkHR.Infrastructure.Migrations
                         .IsRequired()
                         .HasColumnType("nvarchar(max)");
 
+                    b.Property<string>("AssignedUserName")
+                        .IsRequired()
+                        .HasColumnType("nvarchar(max)");
+
                     b.Property<DateTime>("CreateDate")
                         .HasColumnType("datetime2")
                         .HasColumnOrder(3);
@@ -2532,6 +2536,15 @@ namespace MTWorkHR.Infrastructure.Migrations
                             IsDeleted = false,
                             Name = "Employee",
                             NormalizedName = "EMPLOYEE"
+                        },
+                        new
+                        {
+                            Id = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R",
+                            CreateDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
+                            IsAdmin = false,
+                            IsDeleted = false,
+                            Name = "Contractor",
+                            NormalizedName = "CONTRACTOR"
                         });
                 });
 

+ 7 - 0
MTWorkHR.Infrastructure/Repositories/User/TeamRepository.cs

@@ -22,5 +22,12 @@ namespace MTWorkHR.Infrastructure.Repositories
                 .Include(x => x.TeamUsers)
                 .FirstOrDefaultAsync(x => x.Id == id);
         }
+        public  async  Task<Tuple<IQueryable<Team>, int>> GetAllWithChildrenAsync()
+        {
+            var query = dbSet.Include(x => x.TeamUsers).AsQueryable();
+            var total = await query.CountAsync();
+
+            return new Tuple<IQueryable<Team>, int>(query, total);
+        }
     }
 }

+ 41 - 0
MTWorkHR.Infrastructure/Repositories/User/TeamUserRepository.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 TeamUserRepository : Repository<TeamUser>, ITeamUserRepository
+    {
+        private readonly DbSet<TeamUser> dbSet;
+
+        public TeamUserRepository(HRDataContext context) : base(context)
+        {
+            dbSet = context.Set<TeamUser>();
+
+        }
+        public virtual async Task<TeamUser> AddAsync(TeamUser entity)
+        {
+            await dbSet.AddAsync(entity);
+            return entity;
+        }
+
+        public virtual async Task<IList<TeamUser>> AddRangeAsync(IList<TeamUser> entity)
+        {
+            await dbSet.AddRangeAsync(entity);
+            return entity;
+        }
+
+        public virtual async Task DeleteAsync(TeamUser entity)
+        {
+            dbSet.Remove(entity);
+        }
+
+        public virtual async Task DeleteAsync(IEnumerable<TeamUser> entities)
+        {
+            dbSet.RemoveRange(entities);
+        }
+    }
+}

+ 3 - 1
MTWorkHR.Infrastructure/UnitOfWork/UnitOfWork.cs

@@ -22,6 +22,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
 
         public IProjectRepository Project { get; }
         public ITeamRepository Team{ get; }
+        public ITeamUserRepository TeamUser { get; }
         public IMeetingRepository Meeting{ get; }
         public IAttendanceRepository Attendance { get; }
         public IOrderTypeRepository OrderType { get; }
@@ -58,7 +59,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             , IUniversityRepository university
             , ILoginOTPRepository loginOTP
             , ICityRepository city
-
+            , ITeamUserRepository teamUser
             )
         {
             context = _context;
@@ -83,6 +84,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             this.University = university;
             LoginOTP = loginOTP;
             City = city;
+            TeamUser = teamUser;
         }
 
         public async Task<int> CompleteAsync()