浏览代码

CompanyId in all

zinab_elgendy 7 月之前
父节点
当前提交
ee5bea4a4a
共有 48 个文件被更改,包括 10980 次插入74 次删除
  1. 2 0
      MTWorkHR.API/Controllers/AttendanceController.cs
  2. 1 0
      MTWorkHR.API/Controllers/AuthController.cs
  3. 2 0
      MTWorkHR.API/Controllers/CompanyController.cs
  4. 8 0
      MTWorkHR.API/Controllers/LookupController.cs
  5. 2 0
      MTWorkHR.API/Controllers/MeetingController.cs
  6. 2 0
      MTWorkHR.API/Controllers/OrderAllocationController.cs
  7. 2 0
      MTWorkHR.API/Controllers/OrderRequestController.cs
  8. 6 2
      MTWorkHR.API/Controllers/ProjectController.cs
  9. 7 0
      MTWorkHR.API/Controllers/TeamController.cs
  10. 8 0
      MTWorkHR.API/Controllers/UserController.cs
  11. 2 0
      MTWorkHR.API/Controllers/UserTaskController.cs
  12. 1 1
      MTWorkHR.API/Swagger/HeaderOperationFilter.cs
  13. 2 2
      MTWorkHR.API/appsettings.json
  14. 4 0
      MTWorkHR.Application/Dtos/Identity/UserAllDto.cs
  15. 2 0
      MTWorkHR.Application/Dtos/Identity/UserDto.cs
  16. 20 0
      MTWorkHR.Application/Dtos/Lookup/UserTaskStatusDto.cs
  17. 2 0
      MTWorkHR.Application/Dtos/User/CompanyDto.cs
  18. 2 0
      MTWorkHR.Application/Dtos/User/MeetingDto.cs
  19. 1 0
      MTWorkHR.Application/Dtos/User/ProjectDto.cs
  20. 2 0
      MTWorkHR.Application/Dtos/User/TeamDto.cs
  21. 1 0
      MTWorkHR.Application/Dtos/User/UserTaskDto.cs
  22. 3 2
      MTWorkHR.Application/Filters/AppAuth.cs
  23. 9 5
      MTWorkHR.Application/Mapper/MappingProfile.cs
  24. 1 0
      MTWorkHR.Application/Services/Auth/AuthService.cs
  25. 2 0
      MTWorkHR.Application/Services/Interfaces/ILookupService.cs
  26. 1 1
      MTWorkHR.Application/Services/Interfaces/IUserService.cs
  27. 7 0
      MTWorkHR.Application/Services/User/LookupService.cs
  28. 11 39
      MTWorkHR.Application/Services/User/UserService.cs
  29. 2 4
      MTWorkHR.Core/Entities/Attendance/Attendance.cs
  30. 2 2
      MTWorkHR.Core/Entities/Attendance/OrderAllocation.cs
  31. 2 2
      MTWorkHR.Core/Entities/Attendance/OrderRequest.cs
  32. 14 0
      MTWorkHR.Core/Entities/Base/IHaveBranch.cs
  33. 2 2
      MTWorkHR.Core/Entities/Contract/Contract.cs
  34. 2 1
      MTWorkHR.Core/Entities/User/Meeting.cs
  35. 3 1
      MTWorkHR.Core/Entities/User/Project.cs
  36. 2 2
      MTWorkHR.Core/Entities/User/Team.cs
  37. 2 3
      MTWorkHR.Core/Entities/User/UserTask.cs
  38. 3 3
      MTWorkHR.Core/Global/GlobalInfo.cs
  39. 269 0
      MTWorkHR.Infrastructure/Configurations/PermissionConfiguration.cs
  40. 18 0
      MTWorkHR.Infrastructure/DBContext/HRDataContext.cs
  41. 1 0
      MTWorkHR.Infrastructure/Entities/ApplicationUser.cs
  42. 3261 0
      MTWorkHR.Infrastructure/Migrations/20240526150638_permissionConfig.Designer.cs
  43. 234 0
      MTWorkHR.Infrastructure/Migrations/20240526150638_permissionConfig.cs
  44. 3264 0
      MTWorkHR.Infrastructure/Migrations/20240528094815_altrUserByCompanyId.Designer.cs
  45. 42 0
      MTWorkHR.Infrastructure/Migrations/20240528094815_altrUserByCompanyId.cs
  46. 3299 0
      MTWorkHR.Infrastructure/Migrations/20240529145339_addCompanyIdAll.Designer.cs
  47. 158 0
      MTWorkHR.Infrastructure/Migrations/20240529145339_addCompanyIdAll.cs
  48. 287 2
      MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs

+ 2 - 0
MTWorkHR.API/Controllers/AttendanceController.cs

@@ -2,6 +2,7 @@
 
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Filters;
 using MTWorkHR.Application.Identity;
 using MTWorkHR.Application.Models;
 using MTWorkHR.Application.Services.Interfaces;
@@ -11,6 +12,7 @@ namespace MTWorkHR.API.Controllers
 {
     [Route("api/[controller]")]
     [ApiController]
+    [AppAuthorize]
     public class AttendanceController : ControllerBase
     {
         private readonly IAttendanceService _AttendanceService;

+ 1 - 0
MTWorkHR.API/Controllers/AuthController.cs

@@ -11,6 +11,7 @@ namespace MTWorkHR.API.Controllers
 {
     [Route("api/[controller]")]
     [ApiController]
+
     public class AuthController : ControllerBase
     {
         private readonly IAuthService _authenticationService;

+ 2 - 0
MTWorkHR.API/Controllers/CompanyController.cs

@@ -2,6 +2,7 @@
 
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Filters;
 using MTWorkHR.Application.Identity;
 using MTWorkHR.Application.Models;
 using MTWorkHR.Application.Services.Interfaces;
@@ -10,6 +11,7 @@ namespace MTWorkHR.API.Controllers
 {
     [Route("api/[controller]")]
     [ApiController]
+    [AppAuthorize]
     public class CompanyController : ControllerBase
     {
         private readonly ICompanyService _companyService;

+ 8 - 0
MTWorkHR.API/Controllers/LookupController.cs

@@ -82,6 +82,14 @@ namespace MTWorkHR.API.Controllers
             return await _LookupService.GetAllQualifications();
         }
 
+        [HttpGet("GetAllUserTaskStatus")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+
+        public async Task<ActionResult<List<UserTaskStatusDto>>> GetAllUserTaskStatus()
+        {
+            return await _LookupService.GetAllUserTaskStatus();
+        }
+
         //[HttpGet("CreateCountries")]
         //[ProducesResponseType(StatusCodes.Status200OK)]
 

+ 2 - 0
MTWorkHR.API/Controllers/MeetingController.cs

@@ -2,6 +2,7 @@
 
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Filters;
 using MTWorkHR.Application.Identity;
 using MTWorkHR.Application.Models;
 using MTWorkHR.Application.Services.Interfaces;
@@ -11,6 +12,7 @@ namespace MTWorkHR.API.Controllers
 {
     [Route("api/[controller]")]
     [ApiController]
+    [AppAuthorize]
     public class MeetingController : ControllerBase
     {
         private readonly IMeetingService _MeetingService;

+ 2 - 0
MTWorkHR.API/Controllers/OrderAllocationController.cs

@@ -2,6 +2,7 @@
 
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Filters;
 using MTWorkHR.Application.Identity;
 using MTWorkHR.Application.Models;
 using MTWorkHR.Application.Services.Interfaces;
@@ -11,6 +12,7 @@ namespace MTWorkHR.API.Controllers
 {
     [Route("api/[controller]")]
     [ApiController]
+    [AppAuthorize]
     public class OrderAllocationController : ControllerBase
     {
         private readonly IOrderAllocationService _OrderAllocationService;

+ 2 - 0
MTWorkHR.API/Controllers/OrderRequestController.cs

@@ -2,6 +2,7 @@
 
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Filters;
 using MTWorkHR.Application.Identity;
 using MTWorkHR.Application.Models;
 using MTWorkHR.Application.Services.Interfaces;
@@ -11,6 +12,7 @@ namespace MTWorkHR.API.Controllers
 {
     [Route("api/[controller]")]
     [ApiController]
+    [AppAuthorize]
     public class OrderRequestController : ControllerBase
     {
         private readonly IOrderRequestService _LeaveRequestService;

+ 6 - 2
MTWorkHR.API/Controllers/ProjectController.cs

@@ -2,6 +2,7 @@
 
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Filters;
 using MTWorkHR.Application.Identity;
 using MTWorkHR.Application.Models;
 using MTWorkHR.Application.Services.Interfaces;
@@ -11,6 +12,7 @@ namespace MTWorkHR.API.Controllers
 {
     [Route("api/[controller]")]
     [ApiController]
+    [AppAuthorize]
     public class ProjectController : ControllerBase
     {
         private readonly IProjectService _ProjectService;
@@ -27,7 +29,7 @@ namespace MTWorkHR.API.Controllers
         }
         [HttpGet("Get")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+  //      [AppAuthorize(Permissions = "Project")]
         public async Task<ActionResult<ProjectDto>> Get(long ProjectId)
         {
             return Ok(await _ProjectService.GetById(ProjectId));
@@ -36,6 +38,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Create")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+ //       [AppAuthorize(Permissions = "Project.Create")]
         public async Task<ActionResult<ProjectDto>> Create([FromBody] ProjectDto input)
         {
             return await _ProjectService.Create(input);
@@ -43,7 +46,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Update")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+      //  [AppAuthorize(Permissions = "Project.Update")]
         public async Task Update([FromBody] ProjectDto input)
         {
             await _ProjectService.Update(input);
@@ -51,6 +54,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+      //  [AppAuthorize(Permissions = "Project.Delete")]
 
         public async Task Delete(long id)
         {

+ 7 - 0
MTWorkHR.API/Controllers/TeamController.cs

@@ -2,6 +2,7 @@
 
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Filters;
 using MTWorkHR.Application.Identity;
 using MTWorkHR.Application.Models;
 using MTWorkHR.Application.Services.Interfaces;
@@ -11,6 +12,7 @@ namespace MTWorkHR.API.Controllers
 {
     [Route("api/[controller]")]
     [ApiController]
+    [AppAuthorize]
     public class TeamController : ControllerBase
     {
         private readonly ITeamService _TeamService;
@@ -27,6 +29,7 @@ namespace MTWorkHR.API.Controllers
         }
         [HttpGet("Get")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+      //  [AppAuthorize(Permissions = "Team")]
 
         public async Task<ActionResult<TeamDto>> Get(long TeamId)
         {
@@ -36,6 +39,8 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Create")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+     //   [AppAuthorize(Permissions = "Team.Create")]
+
         public async Task<ActionResult<TeamDto>> Create([FromBody] TeamDto input)
         {
             return await _TeamService.Create(input);
@@ -43,6 +48,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Update")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+   //     [AppAuthorize(Permissions = "Team.Update")]
 
         public async Task Update([FromBody] TeamDto input)
         {
@@ -51,6 +57,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+      //  [AppAuthorize(Permissions = "Team.Delete")]
 
         public async Task Delete(long id)
         {

+ 8 - 0
MTWorkHR.API/Controllers/UserController.cs

@@ -2,6 +2,7 @@
 
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Filters;
 using MTWorkHR.Application.Identity;
 using MTWorkHR.Application.Models;
 using MTWorkHR.Identity.Services;
@@ -10,6 +11,7 @@ namespace MTWorkHR.API.Controllers
 {
     [Route("api/[controller]")]
     [ApiController]
+    [AppAuthorize]
     public class UserController : ControllerBase
     {
         private readonly IUserService _userService;
@@ -22,6 +24,12 @@ namespace MTWorkHR.API.Controllers
         {
             return Ok( await _userService.GetAll(pagingInput));
         }
+
+        [HttpGet("GetAllCompanyEmployees")]
+        public async Task<ActionResult<List<UserDto>>> GetAllCompanyEmployees()
+        {
+            return Ok(await _userService.GetAllCompanyEmployees());
+        }
         [HttpGet("Get")]
         public async Task<ActionResult<UserDto>> Get(string userId)
         {

+ 2 - 0
MTWorkHR.API/Controllers/UserTaskController.cs

@@ -2,6 +2,7 @@
 
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Filters;
 using MTWorkHR.Application.Identity;
 using MTWorkHR.Application.Models;
 using MTWorkHR.Application.Services.Interfaces;
@@ -11,6 +12,7 @@ namespace MTWorkHR.API.Controllers
 {
     [Route("api/[controller]")]
     [ApiController]
+    [AppAuthorize]
     public class UserTaskController : ControllerBase
     {
         private readonly IUserTaskService _userTaskService;

+ 1 - 1
MTWorkHR.API/Swagger/HeaderOperationFilter.cs

@@ -68,7 +68,7 @@ namespace MTWorkHR.API.Swagger
             {
                 Name = "lang",
                 In = ParameterLocation.Header,
-                Description = "current acive lang",
+                Description = "current active lang",
                 Required = false,
                 Content = new Dictionary<string, OpenApiMediaType>
                         {

+ 2 - 2
MTWorkHR.API/appsettings.json

@@ -14,7 +14,7 @@
     "SecretKey": "dkajsdfhalksjdhfalksdjhfalksdjfhaslkdjfhasdlkfhjasdlkfhasdlkfhjasdfhh",
     "Audience": "http://localhost:28222",
     "Issuer": "https://localhost:44325",
-    "DurationInMinutes": 60
+    "DurationInMinutes": 60000
   },
   "CookieOptions": {
     "SessionCookieExpiryInSeconds": 3600,
@@ -38,7 +38,7 @@
   },
   "OTPSettings": {
     "Length": 6,
-    "ExpirePeriodInMinutes": 30,
+    "ExpirePeriodInMinutes": 3000,
     "SendEmail": true,
     "AllowZeros": true,
     "MessageBody": "Dear User, Your OTP is {0}. Use this passcode to proceed.",

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

@@ -33,5 +33,9 @@ namespace MTWorkHR.Application.Models
         public long? CountryId { get; set; }
         public bool IsStopped { get; set; }
 
+        public long? CompanyId { get; set; }
+        public UserTypeEnum UserType { get; set; }
+
+
     }
 }

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

@@ -43,6 +43,8 @@ namespace MTWorkHR.Application.Models
 
         public decimal TaxNumber { get; set; }
         public decimal IncomeTaxValue { get; set; }
+        public long? CompanyId { get; set; }
+
         public IFormFile? CVAttach { get; set; }
         public IFormFile? PassportAttach { get; set; }
         public IFormFile? EduCertificateAttach { get; set; }

+ 20 - 0
MTWorkHR.Application/Dtos/Lookup/UserTaskStatusDto.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Countries.NET;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Application.Models
+{
+    public class UserTaskStatusDto : EntityDto
+    {
+        public string NameAr { get; set; }
+        public string NameEn { get; set; }
+
+    }
+}

+ 2 - 0
MTWorkHR.Application/Dtos/User/CompanyDto.cs

@@ -23,5 +23,7 @@ namespace MTWorkHR.Application.Models
         public IFormFile? PassportAttach { get; set; }
         public IFormFile? ExperienceCertificateAttach { get; set; }
         public IFormFile? IdAttach { get; set; }
+        public string? CreateUser { get; set; }
+
     }
 }

+ 2 - 0
MTWorkHR.Application/Dtos/User/MeetingDto.cs

@@ -23,5 +23,7 @@ namespace MTWorkHR.Application.Models
         [MaxLength(250)]
         public string? MeetingLink { get; set; }
         public List<MeetingUserDto>? MeetingUsers { get; set; }
+        public string? CreateUser { get; set; }
+
     }
 }

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

@@ -9,6 +9,7 @@ namespace MTWorkHR.Application.Models
     {
         public string? NameAr { get; set; }
         public string? NameEn { get; set; }
+        public string? CreateUser { get; set; }
 
     }
 }

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

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

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

@@ -16,6 +16,7 @@ namespace MTWorkHR.Application.Models
         public long StatusId { get; set; }
         public List<AttachmentDto> TaskAttachments { get; set; }
         public List<UserTaskHistoryDto> UserTaskHistories { get; set; }
+        public string? CreateUser { get; set; }
 
     }
 }

+ 3 - 2
MTWorkHR.Application/Filters/AppAuth.cs

@@ -24,13 +24,14 @@ namespace MTWorkHR.Application.Filters
             var cc2 = cc.Claims.FirstOrDefault(c => c.Type.Contains( "email"));
             var email = cc2 != null ? cc2.Value : "";
             var generatedGuid = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("Jti").Value;
+            var companyId = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("companyId")?.Value;
             var userId = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("uid").Value;
             var userName = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("name").Value;
         //    var email1 = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("emailaddress").Value;
         //    var email2 = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("email").Value;
           //  var hierarchyIds = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("hierarchyIds").Value;
          //   var allowedBranchs = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("branchs").Value;
-            //var branch = context.HttpContext.Request.Headers.FirstOrDefault(x => x.Key == "branch").Value;
+           // var branch = context.HttpContext.Request.Headers.FirstOrDefault(x => x.Key == "branch").Value;
             var lang = context.HttpContext.Request.Headers.FirstOrDefault(x => x.Key == "lang").Value;
            // var tenantLong = string.IsNullOrEmpty(tenant.ToString()) ? (long?)null : long.Parse(tenant);
             //var branchLong = string.IsNullOrEmpty(branch.ToString()) ? (long?)null : long.Parse(branch);
@@ -49,7 +50,7 @@ namespace MTWorkHR.Application.Filters
 
 
             var globalInfo = context.HttpContext.RequestServices.GetService<GlobalInfo>();
-            globalInfo.SetValues( userName, userId, 0, token, lang);
+            globalInfo.SetValues( userName, userId, companyId !=null && companyId != "" ? long.Parse(companyId) : null , token, lang);
 
             var userManager = context.HttpContext.RequestServices.GetService<ApplicationUserManager>();
 

+ 9 - 5
MTWorkHR.Application/Mapper/MappingProfile.cs

@@ -62,14 +62,16 @@ namespace MTWorkHR.Application.Mapper
 
             CreateMap<RolePermissionDto, RolePermission>().ReverseMap();
 
-            CreateMap<ProjectDto, Project>().ForMember(d => d.CreateDate, o => o.Ignore()).ReverseMap();
-            CreateMap<UserTaskDto, UserTask>().ForMember(d => d.CreateDate, o => o.Ignore()).ReverseMap();
+            CreateMap<ProjectDto, Project>().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()).ReverseMap();
+            CreateMap<UserTaskDto, UserTask>().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()).ReverseMap();
             CreateMap<UserTaskAttachment, AttachmentDto>().ReverseMap();
             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<Meeting, MeetingDto>().ReverseMap()
-                .ForMember(d => d.CreateDate, o => o.Ignore());
+            CreateMap<Meeting, MeetingDto>();
+            CreateMap<MeetingDto , Meeting>()
+                .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<Attendance, AttendanceDto>().ForMember(d=> d.WeekDay , o=> o.MapFrom(s=> s.AttendanceDate.DayOfWeek)).ReverseMap()
@@ -79,7 +81,8 @@ namespace MTWorkHR.Application.Mapper
             CreateMap<OrderRequest, OrderRequestDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
             CreateMap<OrderType, OrderTypeDto>().ReverseMap();
             CreateMap<LeaveType, LeaveTypeDto>().ReverseMap();
-            CreateMap<Company, CompanyDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
+            CreateMap<CompanyDto, Company>().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore());
+            CreateMap<Company, CompanyDto>();
             CreateMap<CountryLookup, CountryDto>().ReverseMap();
             CreateMap<Industry, IndustryDto>().ReverseMap();
             CreateMap<JobTitle, JobTitleDto>().ReverseMap();
@@ -96,6 +99,7 @@ namespace MTWorkHR.Application.Mapper
 
             CreateMap<CompanyUserDto, ApplicationUser>().ForMember(m => m.UserName, o => o.MapFrom(s => s.Email));
             CreateMap<ApplicationUser, CompanyUserDto>().ForMember(m => m.Password, op => op.Ignore());
+            CreateMap<UserTaskStatus, UserTaskStatusDto>().ReverseMap();
 
         }
     }

+ 1 - 0
MTWorkHR.Application/Services/Auth/AuthService.cs

@@ -86,6 +86,7 @@ namespace MTWorkHR.Identity.Services
                 new Claim(JwtRegisteredClaimNames.Name, user.UserName),
                 new Claim(JwtRegisteredClaimNames.Email, user.Email),
                 new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
+                new Claim("companyId", user.CompanyId+""),
                 new Claim("uid", user.Id)
             }.Union(userCalims)
             .Union(roleClaims);

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

@@ -19,5 +19,7 @@ namespace MTWorkHR.Application.Services.Interfaces
 
         Task<List<UniversityDto>> GetAllUniversities();
         Task<List<QualificationDto>> GetAllQualifications();
+
+        Task<List<UserTaskStatusDto>> GetAllUserTaskStatus();
     }
 }

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

@@ -26,7 +26,7 @@ namespace MTWorkHR.Application.Identity
         Task<bool> IsExpiredToken(ConfirmEmailDto model);
         Task<bool> VerifyOTP(VerifyOTPDto input);
 
-
+        Task<List<UserAllDto>> GetAllCompanyEmployees();
 
     }
 }

+ 7 - 0
MTWorkHR.Application/Services/User/LookupService.cs

@@ -83,6 +83,13 @@ namespace MTWorkHR.Application.Services
             return response;
         }
 
+        public async Task<List<UserTaskStatusDto>> GetAllUserTaskStatus()
+        {
+            var entity = await _unitOfWork.UserTaskStatus.GetAllAsync();
+            var response = MapperObject.Mapper.Map<List<UserTaskStatusDto>>(entity.Item1);
+            return response;
+        }
+
         public async Task<List<CountryDto>> CreateCountries()
         {
             // init the service

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

@@ -142,6 +142,16 @@ namespace MTWorkHR.Application.Services
             }).ToList();
         }
 
+
+        public async Task<List<UserAllDto>> GetAllCompanyEmployees()
+        {
+            var employees = await _userManager.GetUsersInRoleAsync("Employee");
+            var res = employees.Where(e => _globalInfo.CompanyId == null || e.CompanyId == _globalInfo.CompanyId).ToList();
+            var response = MapperObject.Mapper.Map<List<UserAllDto>>(res);
+
+            return response;
+        }
+
         public async Task Delete(string id)
         {
             var user = await _userManager.FindByIdAsync(id);
@@ -363,15 +373,6 @@ namespace MTWorkHR.Application.Services
             var result = await _userManager.VerifyUserTokenAsync(user, "Default", purpose, input.Token);
             return !result;
         }
-        public async Task<bool> ForgetPasswordxxxxxxxxxxxxxx(ConfirmEmailDto model)
-        {
-            var user = await _userManager.Users.IgnoreQueryFilters().FirstOrDefaultAsync(x => x.Id == model.UserId);
-            if (user == null)
-                throw new AppException(ExceptionEnum.RecordNotExist);
-
-            var result = await _userManager.ResetPasswordAsync(user, model.Token, model.Password);
-            return result.Succeeded;
-        }
 
         public async Task<bool> ResetPassword(ResetPasswordDto input)
         {
@@ -391,36 +392,7 @@ namespace MTWorkHR.Application.Services
 
             return true;
         }
-        public async Task ForgetPasswordMailxxxxxxxxxxxx(string email)
-        {
-
-            var foundUser = await _userManager.FindByEmailAsync(email);
-            if (foundUser != null)
-            {
-                var user = await _userManager.Users.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id.Equals(foundUser.Id));
-                if (user == null)
-                    throw new AppException(ExceptionEnum.RecordNotExist);
-
-                string resetToken = await _userManager.GeneratePasswordResetTokenAsync(user);
-
-              //  var resultPassReset = await GetResetPasswordURL(foundUser.Id);
-
-                await _emailSender.SendEmail(new EmailMessage
-                {
-                    Subject = "Register Confirmation",
-                    To = foundUser.Email,
-                    Body = "Forget Your Password, your OTP is " + "1111" ,
-                    url = "",
-                    userId = foundUser.Id
-                });
-            }
-            else
-            {
-                throw new AppException(ExceptionEnum.RecordNotExist);
-            }
-        }
-
-
+     
         public async Task<ForgetPasswordResponseDto> ForgetPasswordMail(string email) //Begin forget password
         {
             var foundUser = await _userManager.FindByEmailAsync(email);

+ 2 - 4
MTWorkHR.Core/Entities/Attendance/Attendance.cs

@@ -9,7 +9,7 @@ using MTWorkHR.Core.Global;
 
 namespace MTWorkHR.Core.Entities
 {
-    public class Attendance : FullAuditEntity
+    public class Attendance : FullAuditEntity, IHaveCompany
     {
         [Required]
         [Filter]
@@ -23,8 +23,6 @@ namespace MTWorkHR.Core.Entities
 
         [MaxLength(250)]
         public string? LeaveReason { get; set; }
-        
-
-
+        public long CompanyId { get; set; }
     }
 }

+ 2 - 2
MTWorkHR.Core/Entities/Attendance/OrderAllocation.cs

@@ -9,7 +9,7 @@ using MTWorkHR.Core.Entities.Base;
 
 namespace MTWorkHR.Core.Entities
 {
-    public class OrderAllocation : AuditEntity
+    public class OrderAllocation : AuditEntity, IHaveCompany
     {
         public int NumberOfDays { get; set; }
         [ForeignKey("OrderTypeId")]
@@ -22,6 +22,6 @@ namespace MTWorkHR.Core.Entities
         public int Period { get; set; }
         [Filter]
         public string EmployeeId { get; set; }
-
+        public long CompanyId { get; set; }
     }
 }

+ 2 - 2
MTWorkHR.Core/Entities/Attendance/OrderRequest.cs

@@ -10,7 +10,7 @@ using System.Threading.Tasks;
 
 namespace MTWorkHR.Core.Entities.User
 {
-    public class OrderRequest : FullAuditEntity
+    public class OrderRequest : FullAuditEntity, IHaveCompany
     {
         public DateTime StartDate { get; set; }
         public DateTime? EndDate { get; set; }
@@ -28,6 +28,6 @@ namespace MTWorkHR.Core.Entities.User
         public string RequestingEmployeeId { get; set; }
         public int? CountryId{ get; set; }
         public int? CityId { get; set; }
-
+        public long CompanyId { get ; set ; }
     }
 }

+ 14 - 0
MTWorkHR.Core/Entities/Base/IHaveBranch.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Entities.Base
+{
+    public interface IHaveCompany
+    {
+        public long CompanyId { get; set; }
+    }
+}

+ 2 - 2
MTWorkHR.Core/Entities/Contract/Contract.cs

@@ -8,7 +8,7 @@ using System.Threading.Tasks;
 
 namespace MTWorkHR.Infrastructure.Entities
 {
-    public class Contract : FullAuditEntity
+    public class Contract : FullAuditEntity, IHaveCompany
     {
         public string FirstName { get; set; }
         public string MiddleName { get; set; }
@@ -53,6 +53,6 @@ namespace MTWorkHR.Infrastructure.Entities
 
 
         public bool IsSkilled { get; set; }
-
+        public long CompanyId { get ; set; }
     }
 }

+ 2 - 1
MTWorkHR.Core/Entities/User/Meeting.cs

@@ -8,7 +8,7 @@ using MTWorkHR.Core.Entities.Base;
 
 namespace MTWorkHR.Core.Entities
 {
-    public class Meeting : FullAuditEntity
+    public class Meeting : FullAuditEntity, IHaveCompany
     {
         [Required]
         [MaxLength(250)]
@@ -25,6 +25,7 @@ namespace MTWorkHR.Core.Entities
         public string? Location { get; set; }
         [MaxLength(250)]
         public string? MeetingLink { get; set; }
+        public long CompanyId { get; set; }
         public List<MeetingUser>? MeetingUsers{ get; set; }
     }
 }

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

@@ -8,7 +8,7 @@ using MTWorkHR.Core.Entities.Base;
 
 namespace MTWorkHR.Core.Entities
 {
-    public class Project : FullAuditEntity
+    public class Project : FullAuditEntity, IHaveCompany
     {
         [Required]
         [MaxLength(250)]
@@ -18,5 +18,7 @@ namespace MTWorkHR.Core.Entities
         [MaxLength(250)]
         [Filter]
         public string NameEn { get; set; }
+        public long CompanyId { get; set; }
+
     }
 }

+ 2 - 2
MTWorkHR.Core/Entities/User/Team.cs

@@ -8,7 +8,7 @@ using MTWorkHR.Core.Entities.Base;
 
 namespace MTWorkHR.Core.Entities
 {
-    public class Team : FullAuditEntity
+    public class Team : FullAuditEntity, IHaveCompany
     {
         [Required]
         [MaxLength(250)]
@@ -19,6 +19,6 @@ namespace MTWorkHR.Core.Entities
         [Filter]
         public string NameEn { get; set; }
         public List<TeamUser>? TeamUsers { get; set; }
-
+        public long CompanyId { get ; set; }
     }
 }

+ 2 - 3
MTWorkHR.Core/Entities/User/UserTask.cs

@@ -9,7 +9,7 @@ using System.Threading.Tasks;
 
 namespace MTWorkHR.Core.Entities
 {
-    public class UserTask : FullAuditEntity
+    public class UserTask : FullAuditEntity, IHaveCompany
     {
         public long AssignedUserId { get; set; }
         [Filter]
@@ -28,7 +28,6 @@ namespace MTWorkHR.Core.Entities
         public UserTaskStatus TaskStatus { get; set; }
         public List<UserTaskAttachment> TaskAttachments { get; set; }
         public List<UserTaskHistory> UserTaskHistories { get; set; }
-
-
+        public long CompanyId { get ; set ; }
     }
 }

+ 3 - 3
MTWorkHR.Core/Global/GlobalInfo.cs

@@ -10,15 +10,15 @@ namespace MTWorkHR.Core.Global
     {
         public string UserName { get; set; }
         public string UserId { get; set; }
-        public long? BranchId { get; set; }
+        public long? CompanyId { get; set; }
         public static string lang { get; set; }
         public string Token { get; set; }
 
-        public void SetValues(string UserName, string UserId, long? BranchId, string token, string lang)
+        public void SetValues(string UserName, string UserId, long? CompanyId, string token, string lang)
         {
             this.UserName = UserName;
             this.UserId = UserId;
-            this.BranchId = BranchId;
+            this.CompanyId = CompanyId;
             GlobalInfo.lang = lang;
             this.Token = token;
         }

+ 269 - 0
MTWorkHR.Infrastructure/Configurations/PermissionConfiguration.cs

@@ -0,0 +1,269 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using MTWorkHR.Core.Entities;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Infrastructure.Configurations
+{
+        public class PermissionConfiguration : IEntityTypeConfiguration<Permission>
+        {
+            public void Configure(EntityTypeBuilder<Permission> builder)
+            {
+                builder.HasData
+                (
+                #region Project
+                    new Permission()
+                    {
+                        Id = 1,
+                        Name = "Project",
+                        Desc = "Project",
+                        Show = true,
+                        CategoryName = "User"
+                    },
+                    new Permission()
+                    {
+                        Id = 2,
+                        Name = "Project.Create",
+                        Desc = "Project.Create",
+                        CategoryName = "User"
+
+                    },
+                    new Permission()
+                    {
+                        Id = 3,
+                        Name = "Project.Update",
+                        Desc = "Project.Update",
+                        CategoryName = "User"
+
+                    },
+                    new Permission()
+                    {
+                        Id = 4,
+                        Name = "Project.Delete",
+                        Desc = "Project.Delete",
+                        CategoryName = "User"
+
+                    },
+                #endregion
+                #region Meeting
+                    new Permission()
+                    {
+                        Id = 5,
+                        Name = "Meeting",
+                        Desc = "Meeting",
+                        Show = true,
+                        CategoryName = "User"
+
+                    },
+                    new Permission()
+                    {
+                        Id = 6,
+                        Name = "Meeting.Create",
+                        Desc = "Meeting.Create",
+                        CategoryName = "User"
+
+                    },
+                    new Permission()
+                    {
+                        Id = 7,
+                        Name = "Meeting.Update",
+                        Desc = "Meeting.Update",
+                        CategoryName = "User"
+
+                    },
+                    new Permission()
+                    {
+                        Id = 8,
+                        Name = "Meeting.Delete",
+                        Desc = "Meeting.Delete",
+                        CategoryName = "User"
+
+                    },
+                #endregion
+                #region Team
+                    new Permission()
+                    {
+                        Id = 9,
+                        Name = "Team",
+                        Desc = "Team",
+                        Show = true,
+                        CategoryName = "User"
+
+                    },
+                    new Permission()
+                    {
+                        Id = 10,
+                        Name = "Team.Create",
+                        Desc = "Team.Create",
+                        CategoryName = "User"
+
+                    },
+                    new Permission()
+                    {
+                        Id = 11,
+                        Name = "Team.Update",
+                        Desc = "Team.Update",
+                        CategoryName = "User"
+
+                    },
+                    new Permission()
+                    {
+                        Id = 12,
+                        Name = "Team.Delete",
+                        Desc = "Team.Delete",
+                        CategoryName = "User"
+
+                    },
+                #endregion
+                #region UserTask
+                    new Permission()
+                    {
+                        Id = 13,
+                        Name = "UserTask",
+                        Desc = "UserTask",
+                        Show = true,
+                        CategoryName = "Sales"
+
+                    },
+                    new Permission()
+                    {
+                        Id = 14,
+                        Name = "UserTask.Create",
+                        Desc = "UserTask.Create",
+                        CategoryName = "Sales"
+
+                    },
+                    new Permission()
+                    {
+                        Id = 15,
+                        Name = "UserTask.Update",
+                        Desc = "UserTask.Update",
+                        CategoryName = "Sales"
+
+                    },
+                    new Permission()
+                    {
+                        Id = 16,
+                        Name = "UserTask.Delete",
+                        Desc = "UserTask.Delete",
+                        CategoryName = "User"
+
+                    },
+                #endregion
+
+                #region Company
+                new Permission()
+                {
+                    Id = 17,
+                    Name = "Company",
+                    Desc = "Company",
+                    Show = true,
+                    CategoryName = "User"
+
+                },
+                new Permission()
+                {
+                    Id = 18,
+                    Name = "Company.Create",
+                    Desc = "Company.Create",
+                    CategoryName = "User"
+
+                },
+                new Permission()
+                {
+                    Id = 19,
+                    Name = "Company.Update",
+                    Desc = "Company.Update",
+                    CategoryName = "User"
+
+                },
+                new Permission()
+                {
+                    Id = 20,
+                    Name = "Company.Delete",
+                    Desc = "Company.Delete",
+                    CategoryName = "User"
+
+                },
+            #endregion
+            #region User
+                new Permission()
+                {
+                    Id = 21,
+                    Name = "User",
+                    Desc = "User",
+                    Show = true,
+                    CategoryName = "Adminstration"
+
+                },
+                new Permission()
+                {
+                    Id = 22,
+                    Name = "User.Create",
+                    Desc = "User.Create",
+                    CategoryName = "Adminstration"
+
+                },
+                new Permission()
+                {
+                    Id = 23,
+                    Name = "User.Update",
+                    Desc = "User.Update",
+                    CategoryName = "Adminstration"
+
+                },
+                new Permission()
+                {
+                    Id = 24,
+                    Name = "User.Delete",
+                    Desc = "User.Delete",
+                    CategoryName = "Adminstration"
+
+                },
+            #endregion
+
+            #region Role
+                new Permission()
+                {
+                    Id = 25,
+                    Name = "Role",
+                    Desc = "Role",
+                    Show = true,
+                    CategoryName = "Adminstration"
+
+                },
+                new Permission()
+                {
+                    Id = 26,
+                    Name = "Role.Create",
+                    Desc = "Role.Create",
+                    CategoryName = "Adminstration"
+
+                },
+                new Permission()
+                {
+                    Id = 27,
+                    Name = "Role.Update",
+                    Desc = "Role.Update",
+                    CategoryName = "Adminstration"
+
+                },
+                new Permission()
+                {
+                    Id = 28,
+                    Name = "Role.Delete",
+                    Desc = "Role.Delete",
+                    CategoryName = "Adminstration"
+
+                }
+                #endregion
+                );
+
+            }
+        }
+    
+}

+ 18 - 0
MTWorkHR.Infrastructure/DBContext/HRDataContext.cs

@@ -67,11 +67,14 @@ namespace MTWorkHR.Infrastructure.DBContext
             base.OnModelCreating(builder);
             SetGlobalFilters(builder);
             builder.ApplyConfigurationsFromAssembly(typeof(HRDataContext).Assembly);
+            CreateGlobalIndexes(builder);
         }
 
         private void SetGlobalFilters(ModelBuilder builder)
         {
             builder.SetQueryFilterOnAllEntities<ISoftDelete>(p => !p.IsDeleted);
+            builder.SetQueryFilterOnAllEntities<IHaveCompany>(b => b.CompanyId == _globalInfo.CompanyId);
+
         }
         #region SaveChanges 
         public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
@@ -110,9 +113,20 @@ namespace MTWorkHR.Infrastructure.DBContext
                         ((IAudit)change.Entity).CreateUser = _globalInfo.UserId;
                         ((IAudit)change.Entity).CreateDate = DateTime.Now;
                     }
+                    if ( _globalInfo.CompanyId > 0 && change.Entity is IHaveCompany)
+                    {
+                        ((IHaveCompany)change.Entity).CompanyId = (long)_globalInfo.CompanyId;
+                    }
                 }
                 else if (change.State == EntityState.Modified)
                 {
+                    if (_globalInfo.CompanyId > 0 && change.Entity is IHaveCompany)
+                    {
+                        var originalValues = this.Entry(change.Entity).OriginalValues;
+                        var original = (long)originalValues["CompanyId"];
+                        if (original != (long)_globalInfo.CompanyId)
+                            throw new AppException(ExceptionEnum.NotAuthorized);
+                    }
 
                     if (change.Entity is IAudit
                         && ((change.Entity is IFullAudit && !((IFullAudit)change.Entity).IsDeleted) || change.Entity is not IFullAudit))
@@ -133,6 +147,10 @@ namespace MTWorkHR.Infrastructure.DBContext
                 }
             }
         }
+        private void CreateGlobalIndexes(ModelBuilder builder)
+        {
+            builder.HasIndexOnAllEntities<IHaveCompany>(p => p.CompanyId);
+        }
         #endregion       
     }
 }

+ 1 - 0
MTWorkHR.Infrastructure/Entities/ApplicationUser.cs

@@ -55,6 +55,7 @@ namespace MTWorkHR.Infrastructure.Entities
         public bool IsDeleted { get; set; }
         public string? DeleteUserId { get; set; }
         public string? LinkedInLink { get; set; }
+        public long? CompanyId { get; set; }
 
         public ICollection<ApplicationRole> UserRoles { get; set; }
         public ICollection<UserAttachment> UserAttachments { get; set; }

文件差异内容过多而无法显示
+ 3261 - 0
MTWorkHR.Infrastructure/Migrations/20240526150638_permissionConfig.Designer.cs


+ 234 - 0
MTWorkHR.Infrastructure/Migrations/20240526150638_permissionConfig.cs

@@ -0,0 +1,234 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class permissionConfig : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.UpdateData(
+                table: "AttachmentTypes",
+                keyColumn: "Id",
+                keyValue: 2L,
+                columns: new[] { "NameAr", "NameEn" },
+                values: new object[] { "جواز السفر", "Passport" });
+
+            migrationBuilder.InsertData(
+                table: "AttachmentTypes",
+                columns: new[] { "Id", "IsRequired", "NameAr", "NameEn" },
+                values: new object[,]
+                {
+                    { 6L, false, "شهادة الاحتراف", "Commercial Regestration" },
+                    { 7L, false, "البطاقة الضريبية", "Tax Declaration" },
+                    { 8L, false, "الهوية", "Identification" }
+                });
+
+            migrationBuilder.InsertData(
+                table: "Permissions",
+                columns: new[] { "Id", "CategoryName", "Desc", "Name", "Show" },
+                values: new object[,]
+                {
+                    { 1L, "User", "Project", "Project", true },
+                    { 2L, "User", "Project.Create", "Project.Create", false },
+                    { 3L, "User", "Project.Update", "Project.Update", false },
+                    { 4L, "User", "Project.Delete", "Project.Delete", false },
+                    { 5L, "User", "Meeting", "Meeting", true },
+                    { 6L, "User", "Meeting.Create", "Meeting.Create", false },
+                    { 7L, "User", "Meeting.Update", "Meeting.Update", false },
+                    { 8L, "User", "Meeting.Delete", "Meeting.Delete", false },
+                    { 9L, "User", "Team", "Team", true },
+                    { 10L, "User", "Team.Create", "Team.Create", false },
+                    { 11L, "User", "Team.Update", "Team.Update", false },
+                    { 12L, "User", "Team.Delete", "Team.Delete", false },
+                    { 13L, "Sales", "UserTask", "UserTask", true },
+                    { 14L, "Sales", "UserTask.Create", "UserTask.Create", false },
+                    { 15L, "Sales", "UserTask.Update", "UserTask.Update", false },
+                    { 16L, "User", "UserTask.Delete", "UserTask.Delete", false },
+                    { 17L, "User", "Company", "Company", true },
+                    { 18L, "User", "Company.Create", "Company.Create", false },
+                    { 19L, "User", "Company.Update", "Company.Update", false },
+                    { 20L, "User", "Company.Delete", "Company.Delete", false },
+                    { 21L, "Adminstration", "User", "User", true },
+                    { 22L, "Adminstration", "User.Create", "User.Create", false },
+                    { 23L, "Adminstration", "User.Update", "User.Update", false },
+                    { 24L, "Adminstration", "User.Delete", "User.Delete", false },
+                    { 25L, "Adminstration", "Role", "Role", true },
+                    { 26L, "Adminstration", "Role.Create", "Role.Create", false },
+                    { 27L, "Adminstration", "Role.Update", "Role.Update", false },
+                    { 28L, "Adminstration", "Role.Delete", "Role.Delete", false }
+                });
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DeleteData(
+                table: "AttachmentTypes",
+                keyColumn: "Id",
+                keyValue: 6L);
+
+            migrationBuilder.DeleteData(
+                table: "AttachmentTypes",
+                keyColumn: "Id",
+                keyValue: 7L);
+
+            migrationBuilder.DeleteData(
+                table: "AttachmentTypes",
+                keyColumn: "Id",
+                keyValue: 8L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 1L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 2L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 3L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 4L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 5L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 6L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 7L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 8L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 9L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 10L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 11L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 12L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 13L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 14L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 15L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 16L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 17L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 18L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 19L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 20L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 21L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 22L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 23L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 24L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 25L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 26L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 27L);
+
+            migrationBuilder.DeleteData(
+                table: "Permissions",
+                keyColumn: "Id",
+                keyValue: 28L);
+
+            migrationBuilder.UpdateData(
+                table: "AttachmentTypes",
+                keyColumn: "Id",
+                keyValue: 2L,
+                columns: new[] { "NameAr", "NameEn" },
+                values: new object[] { "الهوية", "Identification" });
+        }
+    }
+}

文件差异内容过多而无法显示
+ 3264 - 0
MTWorkHR.Infrastructure/Migrations/20240528094815_altrUserByCompanyId.Designer.cs


+ 42 - 0
MTWorkHR.Infrastructure/Migrations/20240528094815_altrUserByCompanyId.cs

@@ -0,0 +1,42 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrUserByCompanyId : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AddColumn<long>(
+                name: "CompanyId",
+                table: "AspNetUsers",
+                type: "bigint",
+                nullable: true);
+
+            migrationBuilder.UpdateData(
+                table: "AspNetUsers",
+                keyColumn: "Id",
+                keyValue: "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA",
+                column: "CompanyId",
+                value: null);
+
+            migrationBuilder.UpdateData(
+                table: "AspNetUsers",
+                keyColumn: "Id",
+                keyValue: "AL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB",
+                column: "CompanyId",
+                value: null);
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropColumn(
+                name: "CompanyId",
+                table: "AspNetUsers");
+        }
+    }
+}

文件差异内容过多而无法显示
+ 3299 - 0
MTWorkHR.Infrastructure/Migrations/20240529145339_addCompanyIdAll.Designer.cs


+ 158 - 0
MTWorkHR.Infrastructure/Migrations/20240529145339_addCompanyIdAll.cs

@@ -0,0 +1,158 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class addCompanyIdAll : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AddColumn<long>(
+                name: "CompanyId",
+                table: "UserTasks",
+                type: "bigint",
+                nullable: false,
+                defaultValue: 0L);
+
+            migrationBuilder.AddColumn<long>(
+                name: "CompanyId",
+                table: "Teams",
+                type: "bigint",
+                nullable: false,
+                defaultValue: 0L);
+
+            migrationBuilder.AddColumn<long>(
+                name: "CompanyId",
+                table: "Projects",
+                type: "bigint",
+                nullable: false,
+                defaultValue: 0L);
+
+            migrationBuilder.AddColumn<long>(
+                name: "CompanyId",
+                table: "OrderRequests",
+                type: "bigint",
+                nullable: false,
+                defaultValue: 0L);
+
+            migrationBuilder.AddColumn<long>(
+                name: "CompanyId",
+                table: "OrderAllocations",
+                type: "bigint",
+                nullable: false,
+                defaultValue: 0L);
+
+            migrationBuilder.AddColumn<long>(
+                name: "CompanyId",
+                table: "Meetings",
+                type: "bigint",
+                nullable: false,
+                defaultValue: 0L);
+
+            migrationBuilder.AddColumn<long>(
+                name: "CompanyId",
+                table: "Attendances",
+                type: "bigint",
+                nullable: false,
+                defaultValue: 0L);
+
+            migrationBuilder.CreateIndex(
+                name: "IX_UserTasks_CompanyId",
+                table: "UserTasks",
+                column: "CompanyId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_Teams_CompanyId",
+                table: "Teams",
+                column: "CompanyId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_Projects_CompanyId",
+                table: "Projects",
+                column: "CompanyId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_OrderRequests_CompanyId",
+                table: "OrderRequests",
+                column: "CompanyId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_OrderAllocations_CompanyId",
+                table: "OrderAllocations",
+                column: "CompanyId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_Meetings_CompanyId",
+                table: "Meetings",
+                column: "CompanyId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_Attendances_CompanyId",
+                table: "Attendances",
+                column: "CompanyId");
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropIndex(
+                name: "IX_UserTasks_CompanyId",
+                table: "UserTasks");
+
+            migrationBuilder.DropIndex(
+                name: "IX_Teams_CompanyId",
+                table: "Teams");
+
+            migrationBuilder.DropIndex(
+                name: "IX_Projects_CompanyId",
+                table: "Projects");
+
+            migrationBuilder.DropIndex(
+                name: "IX_OrderRequests_CompanyId",
+                table: "OrderRequests");
+
+            migrationBuilder.DropIndex(
+                name: "IX_OrderAllocations_CompanyId",
+                table: "OrderAllocations");
+
+            migrationBuilder.DropIndex(
+                name: "IX_Meetings_CompanyId",
+                table: "Meetings");
+
+            migrationBuilder.DropIndex(
+                name: "IX_Attendances_CompanyId",
+                table: "Attendances");
+
+            migrationBuilder.DropColumn(
+                name: "CompanyId",
+                table: "UserTasks");
+
+            migrationBuilder.DropColumn(
+                name: "CompanyId",
+                table: "Teams");
+
+            migrationBuilder.DropColumn(
+                name: "CompanyId",
+                table: "Projects");
+
+            migrationBuilder.DropColumn(
+                name: "CompanyId",
+                table: "OrderRequests");
+
+            migrationBuilder.DropColumn(
+                name: "CompanyId",
+                table: "OrderAllocations");
+
+            migrationBuilder.DropColumn(
+                name: "CompanyId",
+                table: "Meetings");
+
+            migrationBuilder.DropColumn(
+                name: "CompanyId",
+                table: "Attendances");
+        }
+    }
+}

+ 287 - 2
MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs

@@ -55,6 +55,9 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Property<DateTime?>("CheckOutTime")
                         .HasColumnType("datetime2");
 
+                    b.Property<long>("CompanyId")
+                        .HasColumnType("bigint");
+
                     b.Property<DateTime>("CreateDate")
                         .HasColumnType("datetime2")
                         .HasColumnOrder(3);
@@ -98,6 +101,8 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
+                    b.HasIndex("CompanyId");
+
                     b.ToTable("Attendances");
                 });
 
@@ -255,8 +260,8 @@ namespace MTWorkHR.Infrastructure.Migrations
                         {
                             Id = 2L,
                             IsRequired = false,
-                            NameAr = "الهوية",
-                            NameEn = "Identification"
+                            NameAr = "جواز السفر",
+                            NameEn = "Passport"
                         },
                         new
                         {
@@ -278,6 +283,27 @@ namespace MTWorkHR.Infrastructure.Migrations
                             IsRequired = false,
                             NameAr = "شهادة الاحتراف",
                             NameEn = "Professional Certification"
+                        },
+                        new
+                        {
+                            Id = 6L,
+                            IsRequired = false,
+                            NameAr = "شهادة الاحتراف",
+                            NameEn = "Commercial Regestration"
+                        },
+                        new
+                        {
+                            Id = 7L,
+                            IsRequired = false,
+                            NameAr = "البطاقة الضريبية",
+                            NameEn = "Tax Declaration"
+                        },
+                        new
+                        {
+                            Id = 8L,
+                            IsRequired = false,
+                            NameAr = "الهوية",
+                            NameEn = "Identification"
                         });
                 });
 
@@ -1059,6 +1085,9 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
 
+                    b.Property<long>("CompanyId")
+                        .HasColumnType("bigint");
+
                     b.Property<DateTime>("CreateDate")
                         .HasColumnType("datetime2")
                         .HasColumnOrder(3);
@@ -1111,6 +1140,8 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
+                    b.HasIndex("CompanyId");
+
                     b.ToTable("Meetings");
                 });
 
@@ -1222,6 +1253,9 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
 
+                    b.Property<long>("CompanyId")
+                        .HasColumnType("bigint");
+
                     b.Property<DateTime>("CreateDate")
                         .HasColumnType("datetime2")
                         .HasColumnOrder(3);
@@ -1258,6 +1292,8 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
+                    b.HasIndex("CompanyId");
+
                     b.HasIndex("LeaveTypeId");
 
                     b.HasIndex("OrderTypeId");
@@ -1357,6 +1393,232 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.HasKey("Id");
 
                     b.ToTable("Permissions");
+
+                    b.HasData(
+                        new
+                        {
+                            Id = 1L,
+                            CategoryName = "User",
+                            Desc = "Project",
+                            Name = "Project",
+                            Show = true
+                        },
+                        new
+                        {
+                            Id = 2L,
+                            CategoryName = "User",
+                            Desc = "Project.Create",
+                            Name = "Project.Create",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 3L,
+                            CategoryName = "User",
+                            Desc = "Project.Update",
+                            Name = "Project.Update",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 4L,
+                            CategoryName = "User",
+                            Desc = "Project.Delete",
+                            Name = "Project.Delete",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 5L,
+                            CategoryName = "User",
+                            Desc = "Meeting",
+                            Name = "Meeting",
+                            Show = true
+                        },
+                        new
+                        {
+                            Id = 6L,
+                            CategoryName = "User",
+                            Desc = "Meeting.Create",
+                            Name = "Meeting.Create",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 7L,
+                            CategoryName = "User",
+                            Desc = "Meeting.Update",
+                            Name = "Meeting.Update",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 8L,
+                            CategoryName = "User",
+                            Desc = "Meeting.Delete",
+                            Name = "Meeting.Delete",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 9L,
+                            CategoryName = "User",
+                            Desc = "Team",
+                            Name = "Team",
+                            Show = true
+                        },
+                        new
+                        {
+                            Id = 10L,
+                            CategoryName = "User",
+                            Desc = "Team.Create",
+                            Name = "Team.Create",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 11L,
+                            CategoryName = "User",
+                            Desc = "Team.Update",
+                            Name = "Team.Update",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 12L,
+                            CategoryName = "User",
+                            Desc = "Team.Delete",
+                            Name = "Team.Delete",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 13L,
+                            CategoryName = "Sales",
+                            Desc = "UserTask",
+                            Name = "UserTask",
+                            Show = true
+                        },
+                        new
+                        {
+                            Id = 14L,
+                            CategoryName = "Sales",
+                            Desc = "UserTask.Create",
+                            Name = "UserTask.Create",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 15L,
+                            CategoryName = "Sales",
+                            Desc = "UserTask.Update",
+                            Name = "UserTask.Update",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 16L,
+                            CategoryName = "User",
+                            Desc = "UserTask.Delete",
+                            Name = "UserTask.Delete",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 17L,
+                            CategoryName = "User",
+                            Desc = "Company",
+                            Name = "Company",
+                            Show = true
+                        },
+                        new
+                        {
+                            Id = 18L,
+                            CategoryName = "User",
+                            Desc = "Company.Create",
+                            Name = "Company.Create",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 19L,
+                            CategoryName = "User",
+                            Desc = "Company.Update",
+                            Name = "Company.Update",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 20L,
+                            CategoryName = "User",
+                            Desc = "Company.Delete",
+                            Name = "Company.Delete",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 21L,
+                            CategoryName = "Adminstration",
+                            Desc = "User",
+                            Name = "User",
+                            Show = true
+                        },
+                        new
+                        {
+                            Id = 22L,
+                            CategoryName = "Adminstration",
+                            Desc = "User.Create",
+                            Name = "User.Create",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 23L,
+                            CategoryName = "Adminstration",
+                            Desc = "User.Update",
+                            Name = "User.Update",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 24L,
+                            CategoryName = "Adminstration",
+                            Desc = "User.Delete",
+                            Name = "User.Delete",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 25L,
+                            CategoryName = "Adminstration",
+                            Desc = "Role",
+                            Name = "Role",
+                            Show = true
+                        },
+                        new
+                        {
+                            Id = 26L,
+                            CategoryName = "Adminstration",
+                            Desc = "Role.Create",
+                            Name = "Role.Create",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 27L,
+                            CategoryName = "Adminstration",
+                            Desc = "Role.Update",
+                            Name = "Role.Update",
+                            Show = false
+                        },
+                        new
+                        {
+                            Id = 28L,
+                            CategoryName = "Adminstration",
+                            Desc = "Role.Delete",
+                            Name = "Role.Delete",
+                            Show = false
+                        });
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.Project", b =>
@@ -1368,6 +1630,9 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
 
+                    b.Property<long>("CompanyId")
+                        .HasColumnType("bigint");
+
                     b.Property<DateTime>("CreateDate")
                         .HasColumnType("datetime2")
                         .HasColumnOrder(3);
@@ -1407,6 +1672,8 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
+                    b.HasIndex("CompanyId");
+
                     b.ToTable("Projects");
                 });
 
@@ -1579,6 +1846,9 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
 
+                    b.Property<long>("CompanyId")
+                        .HasColumnType("bigint");
+
                     b.Property<DateTime>("CreateDate")
                         .HasColumnType("datetime2")
                         .HasColumnOrder(3);
@@ -1618,6 +1888,8 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
+                    b.HasIndex("CompanyId");
+
                     b.ToTable("Teams");
                 });
 
@@ -1779,6 +2051,9 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Property<int?>("CityId")
                         .HasColumnType("int");
 
+                    b.Property<long>("CompanyId")
+                        .HasColumnType("bigint");
+
                     b.Property<int?>("CountryId")
                         .HasColumnType("int");
 
@@ -1833,6 +2108,8 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
+                    b.HasIndex("CompanyId");
+
                     b.HasIndex("LeaveTypeId");
 
                     b.HasIndex("OrderTypeId");
@@ -1910,6 +2187,9 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Property<long>("AssignedUserId")
                         .HasColumnType("bigint");
 
+                    b.Property<long>("CompanyId")
+                        .HasColumnType("bigint");
+
                     b.Property<DateTime>("CreateDate")
                         .HasColumnType("datetime2")
                         .HasColumnOrder(3);
@@ -1959,6 +2239,8 @@ namespace MTWorkHR.Infrastructure.Migrations
 
                     b.HasKey("Id");
 
+                    b.HasIndex("CompanyId");
+
                     b.HasIndex("ProjectId");
 
                     b.HasIndex("StatusId");
@@ -2261,6 +2543,9 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Property<int>("AccessFailedCount")
                         .HasColumnType("int");
 
+                    b.Property<long?>("CompanyId")
+                        .HasColumnType("bigint");
+
                     b.Property<string>("ConcurrencyStamp")
                         .IsConcurrencyToken()
                         .HasColumnType("nvarchar(max)");