25 Commits c678e86012 ... 8cc8882b30

Auteur SHA1 Bericht Datum
  zinab_elgendy 8cc8882b30 HR: ProfileImagePath 3 dagen geleden
  zinab_elgendy 3064566d84 user_update employee permission 4 dagen geleden
  zinab_elgendy 940f69782f fill position with jobTitle if empty, in OrderList 6 dagen geleden
  zinab_elgendy 8125d9c8c3 Contract itext7 generator 1 week geleden
  zinab_elgendy 7aaed744a1 OrderRequest creation return 1 maand geleden
  zinab_elgendy e7bbcbdc2b Course/Service/other requests 1 maand geleden
  zinab_elgendy 8f3edcc56b EmployeeDto for OrderRequest 1 maand geleden
  zinab_elgendy 7a77ba4f09 OrderRequest:OverTime,BusinessTrip 1 maand geleden
  zinab_elgendy 844e671eee OrderRequestHRDto 2 maanden geleden
  zinab_elgendy 57e397848b ContractAll : start/end 2 maanden geleden
  zinab_elgendy d589d8a197 HR_vacations 2 maanden geleden
  zinab_elgendy 1a87e57644 merge payment branch 2 maanden geleden
  zinab_elgendy 2fba8b6ef1 ContractTypeEnum: fix value as front 2 maanden geleden
  zinab_elgendy 9b5c5e5641 enhancement 2 maanden geleden
  zinab_elgendy 3bb37b4241 attendance distplay all employees 2 maanden geleden
  zinab_elgendy 6844a22526 progressPerc : fix divide by 0 2 maanden geleden
  zinab_elgendy b78a536ba8 Project progressPerc 2 maanden geleden
  zinab_elgendy 4dbd51027d HR invoices and next salary date 2 maanden geleden
  zinab_elgendy 0b1e4a6fe5 HRDetails 2 maanden geleden
  zinab_elgendy dd49d221f1 HR list 2 maanden geleden
  zinab_elgendy 4d6dd20f90 merge master 2 maanden geleden
  zinab_elgendy bfe193613e AllocationBalance 2 maanden geleden
  zinab_elgendy 2946ef22a8 Company : AddRole after create 2 maanden geleden
  zinab_elgendy 18143dcd0b test 2 maanden geleden
  zinab_elgendy 2a3bf82ea0 Permissions 2 maanden geleden
100 gewijzigde bestanden met toevoegingen van 16568 en 538 verwijderingen
  1. 7 6
      MTWorkHR.API/Controllers/AttendanceController.cs
  2. 8 1
      MTWorkHR.API/Controllers/CompanyController.cs
  3. 39 9
      MTWorkHR.API/Controllers/ContractController.cs
  4. 39 0
      MTWorkHR.API/Controllers/HRController.cs
  5. 5 4
      MTWorkHR.API/Controllers/MeetingController.cs
  6. 7 6
      MTWorkHR.API/Controllers/OrderAllocationController.cs
  7. 89 8
      MTWorkHR.API/Controllers/OrderRequestController.cs
  8. 7 7
      MTWorkHR.API/Controllers/ProjectController.cs
  9. 14 6
      MTWorkHR.API/Controllers/TeamController.cs
  10. 10 0
      MTWorkHR.API/Controllers/UserController.cs
  11. 16 7
      MTWorkHR.API/Controllers/UserTaskController.cs
  12. 4 12
      MTWorkHR.API/MTWorkHR.API.csproj
  13. 26 1
      MTWorkHR.API/Program.cs
  14. 113 0
      MTWorkHR.API/Properties/ServiceDependencies/mtwork - FTP1/profile.arm.json
  15. 1 1
      MTWorkHR.API/Reports/ContractReport.Designer.cs
  16. 21 33
      MTWorkHR.API/Reports/ReportStorageWebExtension.cs
  17. BIN
      MTWorkHR.API/contract.pdf
  18. 1 0
      MTWorkHR.Application/ApplicationServiceRegistration.cs
  19. 23 7
      MTWorkHR.Application/Chat/ChatHub.cs
  20. 1 0
      MTWorkHR.Application/Dtos/Attendance/AttendancePagingInputDto.cs
  21. 19 0
      MTWorkHR.Application/Dtos/Attendance/BusinessTripDto.cs
  22. 29 0
      MTWorkHR.Application/Dtos/Attendance/BusinessTripExpensesDto.cs
  23. 1 0
      MTWorkHR.Application/Dtos/Attendance/OrderAllocationDto.cs
  24. 20 0
      MTWorkHR.Application/Dtos/Attendance/OrderAttachmentDto.cs
  25. 13 9
      MTWorkHR.Application/Dtos/Attendance/OrderRequestDto.cs
  26. 26 0
      MTWorkHR.Application/Dtos/Attendance/OrderRequestHRDto.cs
  27. 24 0
      MTWorkHR.Application/Dtos/Attendance/OverTimeDayDto.cs
  28. 17 0
      MTWorkHR.Application/Dtos/Attendance/OverTimeDto.cs
  29. 24 0
      MTWorkHR.Application/Dtos/Attendance/ServiceCertificateDto.cs
  30. 19 0
      MTWorkHR.Application/Dtos/Attendance/ServiceCertificateRequestDto.cs
  31. 48 0
      MTWorkHR.Application/Dtos/Contract/ContractAllHRDto.cs
  32. 8 1
      MTWorkHR.Application/Dtos/Contract/ContractDto.cs
  33. 78 0
      MTWorkHR.Application/Dtos/Contract/ContractHRDto.cs
  34. 1 0
      MTWorkHR.Application/Dtos/Contract/ContractPagingInputDto.cs
  35. 1 0
      MTWorkHR.Application/Dtos/Identity/UserDto.cs
  36. 1 1
      MTWorkHR.Application/Dtos/PagingDto.cs
  37. 23 0
      MTWorkHR.Application/Dtos/Payment/InvoiceDto.cs
  38. 22 0
      MTWorkHR.Application/Dtos/User/EmployeeDto.cs
  39. 2 0
      MTWorkHR.Application/Dtos/User/IOrderPagingInputDto.cs
  40. 1 0
      MTWorkHR.Application/Dtos/User/ProjectDto.cs
  41. 1 3
      MTWorkHR.Application/Filters/AppAuth.cs
  42. 31 4
      MTWorkHR.Application/Mapper/MappingProfile.cs
  43. 13 0
      MTWorkHR.Application/Services/Auth/AuthService.cs
  44. 41 1
      MTWorkHR.Application/Services/Base/BlobFileService.cs
  45. 5 0
      MTWorkHR.Application/Services/Base/FileService.cs
  46. 73 0
      MTWorkHR.Application/Services/Contract/ContractPdfService.cs
  47. 309 7
      MTWorkHR.Application/Services/Contract/ContractService.cs
  48. 12 0
      MTWorkHR.Application/Services/Interfaces/IContractPdfService.cs
  49. 9 0
      MTWorkHR.Application/Services/Interfaces/IContractService.cs
  50. 1 0
      MTWorkHR.Application/Services/Interfaces/IFileService.cs
  51. 2 0
      MTWorkHR.Application/Services/Interfaces/ILeaveAllocationService.cs
  52. 3 0
      MTWorkHR.Application/Services/Interfaces/IOrderRequestService.cs
  53. 1 1
      MTWorkHR.Application/Services/Interfaces/ITeamService.cs
  54. 3 0
      MTWorkHR.Application/Services/Interfaces/IUserService.cs
  55. 15 0
      MTWorkHR.Application/Services/Task/ProjectService.cs
  56. 110 74
      MTWorkHR.Application/Services/User/AttendanceService.cs
  57. 29 18
      MTWorkHR.Application/Services/User/CompanyService.cs
  58. 2 2
      MTWorkHR.Application/Services/User/OrderAllocationService.cs
  59. 191 60
      MTWorkHR.Application/Services/User/OrderRequestService.cs
  60. 10 0
      MTWorkHR.Application/Services/User/TeamService.cs
  61. 75 21
      MTWorkHR.Application/Services/User/UserService.cs
  62. 24 0
      MTWorkHR.Core/Entities/Attendance/BusinessTripAttachment.cs
  63. 27 0
      MTWorkHR.Core/Entities/Attendance/BusinessTripExpences.cs
  64. 2 0
      MTWorkHR.Core/Entities/Attendance/OrderAllocation.cs
  65. 24 0
      MTWorkHR.Core/Entities/Attendance/OrderAttachment.cs
  66. 15 6
      MTWorkHR.Core/Entities/Attendance/OrderRequest.cs
  67. 26 0
      MTWorkHR.Core/Entities/Attendance/OverTimeDay.cs
  68. 24 0
      MTWorkHR.Core/Entities/Attendance/OverTimeDayAttachment.cs
  69. 25 0
      MTWorkHR.Core/Entities/Attendance/ServiceCertificate.cs
  70. 2 1
      MTWorkHR.Core/Entities/Contract/Contract.cs
  71. 90 0
      MTWorkHR.Core/Entities/Contract/ContractDetail.cs
  72. 24 0
      MTWorkHR.Core/Entities/Payment/Invoice.cs
  73. 0 0
      MTWorkHR.Core/Entities/Payment/SubscriptionConfiguration.cs
  74. 2 2
      MTWorkHR.Core/Global/Enum/ContractTypeEnum.cs
  75. 4 1
      MTWorkHR.Core/Global/Enum/WorkingHours.cs
  76. 1 0
      MTWorkHR.Core/IDto/IAttendancePagingInputDto.cs
  77. 1 0
      MTWorkHR.Core/IDto/IContractPagingInputDto.cs
  78. 4 1
      MTWorkHR.Core/IDto/IOrderPagingInputDto.cs
  79. 1 0
      MTWorkHR.Core/IRepositories/Contract/IContractRepository.cs
  80. 15 0
      MTWorkHR.Core/IRepositories/Payment/IInvoiceRepository.cs
  81. 2 2
      MTWorkHR.Core/IRepositories/User/IOrderAllocationRepository.cs
  82. 2 0
      MTWorkHR.Core/IRepositories/User/IOrderRequestRepository.cs
  83. 3 0
      MTWorkHR.Core/IRepositories/User/ITeamUserRepository.cs
  84. 1 0
      MTWorkHR.Core/IUnitOfWork/IUnitOfWork.cs
  85. 26 1
      MTWorkHR.Infrastructure/Configurations/AttachmentTypeConfiguration.cs
  86. 13 5
      MTWorkHR.Infrastructure/Configurations/LeaveTypeConfiguration.cs
  87. 20 10
      MTWorkHR.Infrastructure/Configurations/OrderTypeConfiguration.cs
  88. 291 166
      MTWorkHR.Infrastructure/Configurations/PermissionConfiguration.cs
  89. 1 1
      MTWorkHR.Infrastructure/Configurations/RoleConfiguration.cs
  90. 226 0
      MTWorkHR.Infrastructure/Configurations/RolePermissionConfiguration.cs
  91. 28 27
      MTWorkHR.Infrastructure/Configurations/UserConfiguration.cs
  92. 1 0
      MTWorkHR.Infrastructure/DBContext/HRDataContext.cs
  93. 97 0
      MTWorkHR.Infrastructure/Entities/ContractDetail.cs
  94. 2 1
      MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs
  95. 2 4
      MTWorkHR.Infrastructure/MTWorkHR.Infrastructure.csproj
  96. 5825 0
      MTWorkHR.Infrastructure/Migrations/20250113145938_altrUserAdmin.Designer.cs
  97. 32 0
      MTWorkHR.Infrastructure/Migrations/20250113145938_altrUserAdmin.cs
  98. 6895 0
      MTWorkHR.Infrastructure/Migrations/20250119103851_rolePermissions.Designer.cs
  99. 1046 0
      MTWorkHR.Infrastructure/Migrations/20250119103851_rolePermissions.cs
  100. 0 0
      MTWorkHR.Infrastructure/Migrations/20250120121744_altrAdminRole.Designer.cs

+ 7 - 6
MTWorkHR.API/Controllers/AttendanceController.cs

@@ -22,14 +22,14 @@ namespace MTWorkHR.API.Controllers
         }
         [HttpGet("GetAll")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "Attendance")]
         public async Task<ActionResult<List<AttendanceDto>>> GetAll([FromQuery] AttendancePagingInputDto pagingInput)
         {
             return Ok(await _AttendanceService.GetAll(pagingInput));
         }
         [HttpGet("Get")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "Attendance")]
         public async Task<ActionResult<AttendanceDto>> Get(long AttendanceId)
         {
             return Ok(await _AttendanceService.GetById(AttendanceId));
@@ -38,6 +38,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Create")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "Attendance.Create")]
         public async Task<ActionResult<AttendanceDto>> Create([FromBody] AttendanceDto input)
         {
             return await _AttendanceService.Create(input);
@@ -45,15 +46,15 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Update")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
-        public async Task Update([FromBody] AttendanceDto input)
+        [AppAuthorize(Permissions = "Attendance.Update")]
+        public async Task<ActionResult<AttendanceDto>> Update([FromBody] AttendanceDto input)
         {
-            await _AttendanceService.Update(input);
+            return await _AttendanceService.Update(input);
         }
 
         [HttpDelete("Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "Attendance.Delete")]
         public async Task Delete([FromQuery] long id)
         {
             await _AttendanceService.Delete(id);

+ 8 - 1
MTWorkHR.API/Controllers/CompanyController.cs

@@ -21,17 +21,20 @@ namespace MTWorkHR.API.Controllers
             this._companyService = CompanyService;
         }
         [HttpGet("GetAll")]
+        [Authorize(Policy = "SuperAdminOnly")]
+        [AppAuthorize(Permissions = "Company")]
         public async Task<ActionResult<List<CompanyDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
         {
             return Ok( await _companyService.GetAll(pagingInput));
         }
         [HttpGet("Get")]
-
+        [AppAuthorize(Permissions = "Company")]
         public async Task<ActionResult<CompanyDto>> Get()
         {
             return Ok(await _companyService.GetById());
         }
         [HttpGet("GetById")]
+        [AppAuthorize(Permissions = "Company")]
         public async Task<ActionResult<CompanyDto>> GetById(long companyId)
         {
             return Ok(await _companyService.GetById(companyId));
@@ -41,6 +44,7 @@ namespace MTWorkHR.API.Controllers
         [ProducesResponseType(StatusCodes.Status200OK)]
         [Consumes("multipart/form-data")]
         [AllowAnonymous]
+        [AppAuthorize(Permissions = "Company.Create")]
         public async Task<ActionResult<CompanyDto>> Create([FromForm] CompanyDto input)
         {
             return await _companyService.Create(input);
@@ -49,6 +53,7 @@ namespace MTWorkHR.API.Controllers
         [HttpPost("Update")]
         [ProducesResponseType(StatusCodes.Status200OK)]
         [Consumes("multipart/form-data")]
+        [AppAuthorize(Permissions = "Company.Update")]
         public async Task<ActionResult<CompanyDto>> Update([FromForm] CompanyDto input)
         {
             return await _companyService.Update(input);
@@ -58,6 +63,7 @@ namespace MTWorkHR.API.Controllers
         [ProducesResponseType(StatusCodes.Status200OK)]
         // [AppAuthorize(Permissions = "Company.Delete")]
         [Authorize(Policy = "SuperAdminOnly")]
+        [AppAuthorize(Permissions = "Company.Delete")]
         public async Task Delete([FromQuery] long id)
         {
             await _companyService.Delete(id);
@@ -67,6 +73,7 @@ namespace MTWorkHR.API.Controllers
         [ProducesResponseType(StatusCodes.Status200OK)]
         //[AppAuthorize(Permissions = "Company.Suspend")]
         [Authorize(Policy = "SuperAdminOnly")]
+        [AppAuthorize(Permissions = "Company.Suspend")]
         public async Task Suspend([FromQuery] long id)
         {
             await _companyService.Suspend(id);

+ 39 - 9
MTWorkHR.API/Controllers/ContractController.cs

@@ -6,6 +6,7 @@ using MTWorkHR.Application.Filters;
 using MTWorkHR.Application.Models;
 using MTWorkHR.Application.Services;
 using MTWorkHR.Application.Services.Interfaces;
+using System.IO;
 
 namespace MTWorkHR.API.Controllers
 {
@@ -15,14 +16,14 @@ namespace MTWorkHR.API.Controllers
     public class ContractController : ControllerBase
     {
         private readonly IContractService _ContractService;
-        private readonly IContractTaskAttachmentService _ContractTaskAttachmentService;
-        private readonly IProjectStageAttachmentService _ProjectStageAttachmentService;
         private readonly IFileService _fileService;
+      //  private readonly IContractPdfService _pdfService;
 
-        public ContractController(IContractService UserContractService, IFileService fileService)
+        public ContractController(IContractService UserContractService, IFileService fileService/*, IContractPdfService pdfService*/)
         {
             _ContractService = UserContractService;
             _fileService = fileService;
+      //      _pdfService = pdfService;
         }
         [HttpGet("GetAll")]
         [ProducesResponseType(StatusCodes.Status200OK)]
@@ -33,7 +34,7 @@ namespace MTWorkHR.API.Controllers
         }
         [HttpGet("Get")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-       // [AppAuthorize(Permissions = "Contract")]
+        [AppAuthorize(Permissions = "Contract")]
         public async Task<ActionResult<ContractDto>> Get(long ContractId)
         {
             return Ok(await _ContractService.GetById(ContractId));
@@ -42,7 +43,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Create")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-       // [AppAuthorize(Permissions = "Contract.Create")]
+        [AppAuthorize(Permissions = "Contract.Create")]
         public async Task<ActionResult<ContractDto>> Create([FromBody] ContractDto input)
         {
             return await _ContractService.Create(input);
@@ -50,7 +51,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Update")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-       // [AppAuthorize(Permissions = "Contract.Update")]
+        [AppAuthorize(Permissions = "Contract.Update")]
         public async Task Update([FromBody] ContractDto input)
         {
             await _ContractService.Update(input);
@@ -58,7 +59,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpDelete("Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-       // [AppAuthorize(Permissions = "Contract.Delete")]
+        [AppAuthorize(Permissions = "Contract.Delete")]
 
         public async Task Delete([FromQuery] long id)
         {
@@ -67,13 +68,42 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("ChangeStatus")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "Contract.Update")]
         public async Task<bool> ChangeStatus([FromBody] ContractStatusDto input)
         {
             return await _ContractService.ChangeStatus(input.ContractId, input.StatusId);
         }
 
-       
+
+        [HttpPost("generate")]
+        public async Task <AttachmentResponseDto> GenerateContract([FromQuery] long contractId)
+        {
+            string outputPath = Path.Combine(Directory.GetCurrentDirectory(), "contract.pdf");
+           var response = await _ContractService.GenerateContractPdf(outputPath, contractId);
+         //   return File(stream, "application/pdf", "example.pdf");
+
+            //string blobUrl = _pdfService.GenerateContractPdf(contractData);
+
+            //// Return the URL to the client
+            return (response);
+
+            //return  PhysicalFile(outputPath, "application/pdf", "contract.pdf");
+        }
+
+        [HttpGet("generate-pdf")]
+        public IActionResult GeneratePdf()
+        {
+            try
+            {
+                var stream = _ContractService.generatePdfTest();
+                return File(stream, "application/pdf", "example.pdf");
+            }
+            catch (Exception ex)
+            {
+                throw;
+            }
+        }
+
         //[HttpPost("CreateTaskAttachment")]
         //[ProducesResponseType(StatusCodes.Status200OK)]
         //[Consumes("multipart/form-data")]

+ 39 - 0
MTWorkHR.API/Controllers/HRController.cs

@@ -0,0 +1,39 @@
+using Microsoft.AspNetCore.Authorization;
+
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Filters;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Application.Services;
+using MTWorkHR.Application.Services.Interfaces;
+
+namespace MTWorkHR.API.Controllers
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    [AppAuthorize]
+    public class HRController : ControllerBase
+    {
+        private readonly IContractService _ContractService;
+
+        public HRController(IContractService UserContractService, IFileService fileService)
+        {
+            _ContractService = UserContractService;
+        }
+        [HttpGet("GetAll")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+
+        public async Task<ActionResult<List<ContractAllHRDto>>> GetAll([FromQuery] ContractPagingInputDto pagingInput)
+        {
+            return Ok(await _ContractService.GetAllForHr(pagingInput));
+        }
+
+        [HttpGet("GetByIdHRDetails")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        public async Task<ActionResult<ContractHRDto>> GetByIdHRDetails([FromQuery] long contractId)
+        {
+            return Ok(await _ContractService.GetByIdHRDetails(contractId));
+        }
+
+    }
+}

+ 5 - 4
MTWorkHR.API/Controllers/MeetingController.cs

@@ -22,14 +22,14 @@ namespace MTWorkHR.API.Controllers
         }
         [HttpGet("GetAll")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "Meeting")]
         public async Task<ActionResult<List<MeetingDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
         {
             return Ok(await _MeetingService.GetAll(pagingInput));
         }
         [HttpGet("Get")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "Meeting")]
         public async Task<ActionResult<MeetingDto>> Get(long MeetingId)
         {
             return Ok(await _MeetingService.GetById(MeetingId));
@@ -38,6 +38,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Create")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "Meeting.Create")]
         public async Task<ActionResult<MeetingDto>> Create([FromBody] MeetingDto input)
         {
             return await _MeetingService.Create(input);
@@ -45,7 +46,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Update")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "Meeting.Update")]
         public async Task<ActionResult<MeetingDto>> Update([FromBody] MeetingDto input)
         {
             return await _MeetingService.Update(input);
@@ -53,7 +54,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpDelete("Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "Meeting.Delete")]
         public async Task Delete([FromQuery]long id)
         {
             await _MeetingService.Delete(id);

+ 7 - 6
MTWorkHR.API/Controllers/OrderAllocationController.cs

@@ -22,14 +22,14 @@ namespace MTWorkHR.API.Controllers
         }
         [HttpGet("GetAll")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "OrderAllocation")]
         public async Task<ActionResult<List<OrderAllocationDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
         {
             return Ok(await _OrderAllocationService.GetAll(pagingInput));
         }
         [HttpGet("Get")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "OrderAllocation")]
         public async Task<ActionResult<OrderAllocationDto>> Get(long OrderAllocationId)
         {
             return Ok(await _OrderAllocationService.GetById(OrderAllocationId));
@@ -38,6 +38,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Create")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "OrderAllocation.Create")]
         public async Task<ActionResult<OrderAllocationDto>> Create([FromBody] OrderAllocationDto input)
         {
             return await _OrderAllocationService.Create(input);
@@ -45,15 +46,15 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Update")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
-        public async Task Update([FromBody] OrderAllocationDto input)
+        [AppAuthorize(Permissions = "OrderAllocation.Update")]
+        public async Task<ActionResult<OrderAllocationDto>> Update([FromBody] OrderAllocationDto input)
         {
-            await _OrderAllocationService.Update(input);
+            return await _OrderAllocationService.Update(input);
         }
 
         [HttpDelete("Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "OrderAllocation.Delete")]
         public async Task Delete([FromQuery]long id)
         {
             await _OrderAllocationService.Delete(id);

+ 89 - 8
MTWorkHR.API/Controllers/OrderRequestController.cs

@@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc;
 using MTWorkHR.Application.Filters;
 using MTWorkHR.Application.Identity;
 using MTWorkHR.Application.Models;
+using MTWorkHR.Application.Services;
 using MTWorkHR.Application.Services.Interfaces;
 using MTWorkHR.Identity.Services;
 
@@ -22,30 +23,110 @@ namespace MTWorkHR.API.Controllers
         }
         [HttpGet("GetAll")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "OrderRequest")]
         public async Task<ActionResult<List<OrderRequestDto>>> GetAll([FromQuery] OrderPagingInputDto pagingInput)
         {
             return Ok(await _LeaveRequestService.GetAll(pagingInput));
         }
         [HttpGet("Get")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "OrderRequest")]
         public async Task<ActionResult<OrderRequestDto>> Get(long OrderRequestId)
         {
             return Ok(await _LeaveRequestService.GetById(OrderRequestId));
         }
 
+        [HttpGet("GetOverTime")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "OrderRequest")]
+        public async Task<ActionResult<OverTimeDto>> GetOverTime(long OrderRequestId)
+        {
+            return Ok(await _LeaveRequestService.GetOverTime(OrderRequestId));
+        }
+
+        [HttpGet("GetBusinessTrip")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "OrderRequest")]
+        public async Task<ActionResult<BusinessTripDto>> GetBusinessTrip(long OrderRequestId)
+        {
+            return Ok(await _LeaveRequestService.GetBusinessTrip(OrderRequestId));
+        }
+        [HttpGet("GetCourse")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "OrderRequest")]
+        public async Task<ActionResult<OrderRequestDto>> GetCourse(long OrderRequestId)
+        {
+            return Ok(await _LeaveRequestService.GetById(OrderRequestId));
+        }
+
+        [HttpGet("GetServiceCertificate")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "OrderRequest")]
+        public async Task<ActionResult<ServiceCertificateRequestDto>> GetServiceCertificate(long OrderRequestId)
+        {
+            return Ok(await _LeaveRequestService.GetServiceCertificate(OrderRequestId));
+        }
+
+        [HttpGet("GetOther")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "OrderRequest")]
+        public async Task<ActionResult<OrderRequestDto>> GetOther(long OrderRequestId)
+        {
+            return Ok(await _LeaveRequestService.GetById(OrderRequestId));
+        }
 
-        [HttpPost("Create")]
+        [HttpPost("CreateLeave")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "OrderRequest.Create")]
         public async Task<ActionResult<OrderRequestDto>> Create([FromBody] OrderRequestDto input)
         {
             return await _LeaveRequestService.Create(input);
         }
 
-        [HttpPost("Update")]
+
+        [HttpPost("CreateOverTime")]
+        public async Task<ActionResult<OrderRequestDto>> CreateOverTime([FromBody] OverTimeDto overtimeDto)
+        {
+            var orderRequest = await _LeaveRequestService.Create(overtimeDto);
+            return orderRequest;
+        }
+
+        [HttpPost("CreateBusinessTrip")]
+        public async Task<ActionResult<OrderRequestDto>> CreateBusinessTrip([FromBody] BusinessTripDto businessTripDto)
+        {
+            var orderRequest = await _LeaveRequestService.Create(businessTripDto);
+            return orderRequest;
+
+        }
+
+        [HttpPost("CreateCourse")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "OrderRequest.Create")]
+        public async Task<ActionResult<OrderRequestDto>> CreateCourse([FromBody] OrderRequestDto input)
+        {
+            return await _LeaveRequestService.Create(input);
+        }
+
+
+        [HttpPost("CreateServiceCertificate")]
+        public async Task<ActionResult<OrderRequestDto>> CreateServiceCertificate([FromBody] ServiceCertificateRequestDto serviceCertificate)
+        {
+            var orderRequest = await _LeaveRequestService.Create(serviceCertificate);
+            return orderRequest;
+
+        }
+
+        [HttpPost("CreateOther")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "OrderRequest.Create")]
+        public async Task<ActionResult<OrderRequestDto>> CreateOther([FromBody] OrderRequestDto input)
+        {
+            return await _LeaveRequestService.Create(input);
+        }
 
+        [HttpPost("Update")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "OrderRequest.Update")]
         public async Task<ActionResult<OrderRequestDto>> Update([FromBody] OrderRequestDto input)
         {
             return await _LeaveRequestService.Update(input);
@@ -53,17 +134,17 @@ namespace MTWorkHR.API.Controllers
 
         [HttpDelete("Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "OrderRequest.Delete")]
         public async Task Delete([FromQuery]long id)
         {
             await _LeaveRequestService.Delete(id);
         }
         [HttpPost("ChangeStatus")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
-        public async Task ChangeStatus([FromBody] OrderStatusDto input)
+        [AppAuthorize(Permissions = "OrderRequest.Update")]
+        public async Task<ActionResult<OrderRequestDto>> ChangeStatus([FromBody] OrderStatusDto input)
         {
-            await _LeaveRequestService.ChangeStatus(input.OrderId, input.StatusId);
+            return await _LeaveRequestService.ChangeStatus(input.OrderId, input.StatusId);
         }
 
 

+ 7 - 7
MTWorkHR.API/Controllers/ProjectController.cs

@@ -22,14 +22,14 @@ namespace MTWorkHR.API.Controllers
         }
         [HttpGet("GetAll")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "Project")]
         public async Task<ActionResult<List<ProjectDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
         {
             return Ok(await _ProjectService.GetAll(pagingInput));
         }
         [HttpGet("Get")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-  //      [AppAuthorize(Permissions = "Project")]
+        [AppAuthorize(Permissions = "Project")]
         public async Task<ActionResult<ProjectDto>> Get(long ProjectId)
         {
             return Ok(await _ProjectService.GetById(ProjectId));
@@ -38,7 +38,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Create")]
         [ProducesResponseType(StatusCodes.Status200OK)]
- //       [AppAuthorize(Permissions = "Project.Create")]
+        [AppAuthorize(Permissions = "Project.Create")]
         public async Task<ActionResult<ProjectDto>> Create([FromBody] ProjectDto input)
         {
             return await _ProjectService.Create(input);
@@ -46,15 +46,15 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Update")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-      //  [AppAuthorize(Permissions = "Project.Update")]
-        public async Task Update([FromBody] ProjectDto input)
+        [AppAuthorize(Permissions = "Project.Update")]
+        public async Task<ActionResult<ProjectDto>> Update([FromBody] ProjectDto input)
         {
-            await _ProjectService.Update(input);
+            return await _ProjectService.Update(input);
         }
 
         [HttpDelete("Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-      //  [AppAuthorize(Permissions = "Project.Delete")]
+        [AppAuthorize(Permissions = "Project.Delete")]
 
         public async Task Delete([FromQuery] long id)
         {

+ 14 - 6
MTWorkHR.API/Controllers/TeamController.cs

@@ -22,14 +22,14 @@ namespace MTWorkHR.API.Controllers
         }
         [HttpGet("GetAll")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "Team")]
         public async Task<ActionResult<List<TeamDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
         {
             return Ok(await _TeamService.GetAll(pagingInput));
         }
         [HttpGet("Get")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-      //  [AppAuthorize(Permissions = "Team")]
+        [AppAuthorize(Permissions = "Team")]
 
         public async Task<ActionResult<TeamDto>> Get(long TeamId)
         {
@@ -39,7 +39,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Create")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-     //   [AppAuthorize(Permissions = "Team.Create")]
+        [AppAuthorize(Permissions = "Team.Create")]
 
         public async Task<ActionResult<TeamDto>> Create([FromBody] TeamDto input)
         {
@@ -48,7 +48,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Update")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-   //     [AppAuthorize(Permissions = "Team.Update")]
+        [AppAuthorize(Permissions = "Team.Update")]
 
         public async Task<ActionResult<TeamDto>> Update([FromBody] TeamDto input)
         {
@@ -57,7 +57,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpDelete("Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-      //  [AppAuthorize(Permissions = "Team.Delete")]
+          [AppAuthorize(Permissions = "Team.Delete")]
 
         public async Task Delete([FromQuery] long id)
         {
@@ -66,13 +66,21 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("AssignAdminManager")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "Team.Update")]
         public async Task<bool> AssignAdminManager([FromBody] TeamUserDto teamUser)
         {
             return await _TeamService.AssignAdminManager(teamUser);
         }
 
+        [HttpGet("GetTeamListForUser")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "Team.Update")]
+        public async Task<IList<TeamDto>> GetTeamListForUser(string userId)
+        {
+            return await _TeamService.GetTeamListForUser(userId);
+        }
 
+        
 
     }
 }

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

@@ -21,28 +21,33 @@ namespace MTWorkHR.API.Controllers
             this._userService = userService;
         }
         [HttpPost("GetAll")]
+        [AppAuthorize(Permissions = "User")]
         public async Task<ActionResult<List<UserAllDto>>> GetAll([FromBody] UserPagingInputDto pagingInput)
         {
             return Ok( await _userService.GetAll(pagingInput));
         }
 
         [HttpGet("GetAllCompanyEmployees")]
+        [AppAuthorize(Permissions = "User")]
         public async Task<ActionResult<List<UserDto>>> GetAllCompanyEmployees()
         {
             return Ok(await _userService.GetAllCompanyEmployees());
         }
         [HttpGet("Get")]
+        [AppAuthorize(Permissions = "User")]
         public async Task<ActionResult<UserDto>> Get()
         {
             return Ok(await _userService.GetById());
         }
         [HttpGet("GetById")]
+        [AppAuthorize(Permissions = "User")]
         public async Task<ActionResult<UserDto>> GetById([FromQuery] string userId)
         {
             return Ok(await _userService.GetById(userId));
         }
 
         [HttpGet("GetByEmail")]
+        [AppAuthorize(Permissions = "User")]
         public async Task<ActionResult<UserDto>> GetByEmail(string userId)
         {
             return Ok(await _userService.GetByEmail(userId));
@@ -51,6 +56,7 @@ namespace MTWorkHR.API.Controllers
         [HttpPost("Create")]
         [ProducesResponseType(StatusCodes.Status200OK)]
         [Consumes("multipart/form-data")]
+        [AppAuthorize(Permissions = "User.Create")]
         public async Task<ActionResult<UserDto>> Create([FromForm] UserDto input)
         {
             return await _userService.Create(input);
@@ -59,6 +65,7 @@ namespace MTWorkHR.API.Controllers
         [HttpPost("Update")]
         [Consumes("multipart/form-data")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "User.Update")]
         public async Task<ActionResult<UserDto>> Update([FromForm] UserUpdateDto input)
         {
             return Ok(await _userService.Update(input));
@@ -66,6 +73,7 @@ namespace MTWorkHR.API.Controllers
 
         [Authorize(Policy = "SuperAdminOnly")]
         [HttpDelete("Delete")]
+        [AppAuthorize(Permissions = "User.Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
 
         public async Task Delete([FromQuery] string id)
@@ -75,6 +83,7 @@ namespace MTWorkHR.API.Controllers
 
         [Authorize(Policy = "SuperAdminOnly")]
         [HttpDelete("Suspend")]
+        [AppAuthorize(Permissions = "User.Suspend")]
         [ProducesResponseType(StatusCodes.Status200OK)]
 
         public async Task Suspend([FromQuery] string id)
@@ -84,6 +93,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("ResetPassword")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "User.ResetPassword")]
         public async Task<bool> ResetPassword([FromBody] ResetPasswordDto input)
         {
             return await _userService.ResetPassword(input);

+ 16 - 7
MTWorkHR.API/Controllers/UserTaskController.cs

@@ -25,11 +25,13 @@ namespace MTWorkHR.API.Controllers
             _taskHistoryService = taskHistoryService;
         }
         [HttpGet("GetAll")]
+        [AppAuthorize(Permissions = "UserTask")]
         public async Task<ActionResult<List<UserTaskAllDto>>> GetAll([FromQuery]UserTaskPagingInputDto pagingInput)
         {
             return Ok(await _userTaskService.GetAll(pagingInput));
         }
         [HttpGet("Get")]
+        [AppAuthorize(Permissions = "UserTask")]
         public async Task<ActionResult<UserTaskDto>> Get(long UserTaskId)
         {
             return Ok(await _userTaskService.GetById(UserTaskId));
@@ -38,6 +40,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Create")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "UserTask.Create")]
         public async Task<ActionResult<UserTaskDto>> Create([FromBody] UserTaskDto input)
         {
             return await _userTaskService.Create(input);
@@ -45,7 +48,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("Update")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "UserTask.Update")]
         public async Task<ActionResult<UserTaskDto>> Update([FromBody] UserTaskDto input)
         {
             return await _userTaskService.Update(input);
@@ -53,7 +56,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpDelete("Delete")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "UserTask.Delete")]
         public async Task Delete([FromQuery] long id)
         {
             await _userTaskService.Delete(id);
@@ -63,6 +66,7 @@ namespace MTWorkHR.API.Controllers
         [HttpPost("CreateAttachment")]
         [ProducesResponseType(StatusCodes.Status200OK)]
         [Consumes("multipart/form-data")]
+        [AppAuthorize(Permissions = "UserTask.Create")]
         public async Task<ActionResult<AttachmentDto>> CreateAttachment([FromForm] AttachmentDto input)
         {
             return await _attachmentService.Create(input);
@@ -70,13 +74,15 @@ namespace MTWorkHR.API.Controllers
         [HttpPost("UpdateAttachment")]
         [ProducesResponseType(StatusCodes.Status200OK)]
         [Consumes("multipart/form-data")]
-        public async Task UpdateAttachment([FromForm] AttachmentDto input)
+        [AppAuthorize(Permissions = "UserTask.Update")]
+        public async Task<ActionResult<AttachmentDto>> UpdateAttachment([FromForm] AttachmentDto input)
         {
-            await _attachmentService.Update(input);
+            return await _attachmentService.Update(input);
         }
 
         [HttpDelete("DeleteAttachment")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "UserTask.Delete")]
         public async Task DeleteAttachment([FromQuery] long id)
         {
             await _attachmentService.Delete(id);
@@ -87,6 +93,7 @@ namespace MTWorkHR.API.Controllers
         #region History
         [HttpPost("CreateTaskHistory")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "UserTask.Create")]
         public async Task<ActionResult<UserTaskHistoryDto>> CreateTaskHistory([FromBody] UserTaskHistoryDto input)
         {
             return await _taskHistoryService.Create(input);
@@ -94,19 +101,21 @@ namespace MTWorkHR.API.Controllers
 
         [HttpPost("UpdateTaskHistory")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-        public async Task UpdateTaskHistory([FromBody] UserTaskHistoryDto input)
+        [AppAuthorize(Permissions = "UserTask.Update")]
+        public async Task<ActionResult<UserTaskHistoryDto>> UpdateTaskHistory([FromBody] UserTaskHistoryDto input)
         {
-            await _taskHistoryService.Update(input);
+            return await _taskHistoryService.Update(input);
         }
         [HttpDelete("DeleteTaskHistory")]
         [ProducesResponseType(StatusCodes.Status200OK)]
+        [AppAuthorize(Permissions = "UserTask.Delete")]
         public async Task DeleteTaskHistory([FromQuery]long id)
         {
             await _taskHistoryService.Delete(id);
         }
         [HttpPost("ChangeStatus")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-
+        [AppAuthorize(Permissions = "UserTask.Update")]
         public async Task ChangeStatus([FromBody] TaskStatusDto input)
         {
             await _userTaskService.ChangeStatus(input.TaskId, input.StatusId);

+ 4 - 12
MTWorkHR.API/MTWorkHR.API.csproj

@@ -30,18 +30,10 @@
   </ItemGroup>
 
   <ItemGroup>
-    <Compile Update="Reports\ProjectStages.cs">
-      <SubType>XtraReport</SubType>
-    </Compile>
-    <Compile Update="Reports\ContractTasks.cs">
-      <SubType>XtraReport</SubType>
-    </Compile>
-    <Compile Update="Reports\ContractReport.cs">
-      <SubType>XtraReport</SubType>
-    </Compile>
-    <Compile Update="Reports\ContractAllowances.cs">
-      <SubType>XtraReport</SubType>
-    </Compile>
+    <Compile Update="Reports\ProjectStages.cs" />
+    <Compile Update="Reports\ContractTasks.cs" />
+    <Compile Update="Reports\ContractReport.cs" />
+    <Compile Update="Reports\ContractAllowances.cs" />
   </ItemGroup>
 
 </Project>

+ 26 - 1
MTWorkHR.API/Program.cs

@@ -25,6 +25,8 @@ using MTWorkHR.Infrastructure.Reports;
 using MTWorkHR.API.Chat;
 using Microsoft.AspNetCore.SignalR;
 using MTWorkHR.Application.Services.Payment;
+using Microsoft.AspNetCore.Diagnostics;
+using DevExpress.DataAccess.Native.Web;
 
 var builder = WebApplication.CreateBuilder(args);
 
@@ -39,7 +41,7 @@ var config = new AppSettingsConfiguration();
 // Add services to the container.
 builder.Services.AddDbContext<HRDataContext>(options =>
 {
-    options.UseSqlServer(config.ConnectionStrings.LocalConnectionString);
+    options.UseSqlServer(config.ConnectionStrings.MTWorkHRConnectionString);
     //  options.UseSqlServer(builder.Configuration.GetSection("ConnectionStrings:MTWorkHRConnectionString").Value);
 });
 
@@ -95,6 +97,10 @@ builder.Services.AddSingleton<MatchMoveService>();
 //Reporting
 
 
+
+
+
+
 builder.Services.AddScoped<ReportStorageWebExtension, CustomReportStorageWebExtension>();
 
 builder.Services.ConfigureReportingServices(configurator => {
@@ -173,6 +179,25 @@ var app = builder.Build();
 // if (app.Environment.IsDevelopment())
 // {
 app.UseDevExpressControls(); // Required for DevExpress Reporting
+
+
+app.UseExceptionHandler(errorApp =>
+{
+    errorApp.Run(async context =>
+    {
+        var exceptionHandlerPathFeature = context.Features.Get<IExceptionHandlerPathFeature>();
+        if (exceptionHandlerPathFeature?.Error is FaultException faultException)
+        {
+            var logger = context.RequestServices.GetRequiredService<ILogger<Program>>();
+            logger.LogError("DevExpress Report Error: {Message}", faultException.Message);
+        }
+
+        context.Response.StatusCode = 500;
+        await context.Response.WriteAsync("An error occurred while generating the report.");
+    });
+});
+
+
 app.UseSwagger();
 //app.UseSwaggerUI();
 app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MTWorkHR.API v1"));

+ 113 - 0
MTWorkHR.API/Properties/ServiceDependencies/mtwork - FTP1/profile.arm.json

@@ -0,0 +1,113 @@
+{
+  "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
+  "contentVersion": "1.0.0.0",
+  "metadata": {
+    "_dependencyType": "compute.appService.windows"
+  },
+  "parameters": {
+    "resourceGroupName": {
+      "type": "string",
+      "defaultValue": "WepResourceGrp",
+      "metadata": {
+        "description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
+      }
+    },
+    "resourceGroupLocation": {
+      "type": "string",
+      "defaultValue": "",
+      "metadata": {
+        "description": "Location of the resource group. Resource groups could have different location than resources, however by default we use API versions from latest hybrid profile which support all locations for resource types we support."
+      }
+    },
+    "resourceName": {
+      "type": "string",
+      "defaultValue": "mtwork",
+      "metadata": {
+        "description": "Name of the main resource to be created by this template."
+      }
+    },
+    "resourceLocation": {
+      "type": "string",
+      "defaultValue": "[parameters('resourceGroupLocation')]",
+      "metadata": {
+        "description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
+      }
+    }
+  },
+  "variables": {
+    "appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
+    "appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]"
+  },
+  "resources": [
+    {
+      "type": "Microsoft.Resources/resourceGroups",
+      "name": "[parameters('resourceGroupName')]",
+      "location": "[parameters('resourceGroupLocation')]",
+      "apiVersion": "2019-10-01"
+    },
+    {
+      "type": "Microsoft.Resources/deployments",
+      "name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
+      "resourceGroup": "[parameters('resourceGroupName')]",
+      "apiVersion": "2019-10-01",
+      "dependsOn": [
+        "[parameters('resourceGroupName')]"
+      ],
+      "properties": {
+        "mode": "Incremental",
+        "template": {
+          "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
+          "contentVersion": "1.0.0.0",
+          "resources": [
+            {
+              "location": "[parameters('resourceLocation')]",
+              "name": "[parameters('resourceName')]",
+              "type": "Microsoft.Web/sites",
+              "apiVersion": "2015-08-01",
+              "tags": {
+                "[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty"
+              },
+              "dependsOn": [
+                "[variables('appServicePlan_ResourceId')]"
+              ],
+              "kind": "app",
+              "properties": {
+                "name": "[parameters('resourceName')]",
+                "kind": "app",
+                "httpsOnly": true,
+                "reserved": false,
+                "serverFarmId": "[variables('appServicePlan_ResourceId')]",
+                "siteConfig": {
+                  "metadata": [
+                    {
+                      "name": "CURRENT_STACK",
+                      "value": "dotnetcore"
+                    }
+                  ]
+                }
+              },
+              "identity": {
+                "type": "SystemAssigned"
+              }
+            },
+            {
+              "location": "[parameters('resourceLocation')]",
+              "name": "[variables('appServicePlan_name')]",
+              "type": "Microsoft.Web/serverFarms",
+              "apiVersion": "2015-08-01",
+              "sku": {
+                "name": "S1",
+                "tier": "Standard",
+                "family": "S",
+                "size": "S1"
+              },
+              "properties": {
+                "name": "[variables('appServicePlan_name')]"
+              }
+            }
+          ]
+        }
+      }
+    }
+  ]
+}

+ 1 - 1
MTWorkHR.API/Reports/ContractReport.Designer.cs

@@ -1053,7 +1053,7 @@
             // 
             // sqlDataSource1
             // 
-            this.sqlDataSource1.ConnectionName = "LocalConnectionString";
+            this.sqlDataSource1.ConnectionName = "MTWorkHRConnectionString";
             this.sqlDataSource1.Name = "sqlDataSource1";
             columnExpression1.ColumnName = "CompanyName";
             table1.MetaSerializable = "<Meta X=\"185\" Y=\"30\" Width=\"125\" Height=\"385\" />";

+ 21 - 33
MTWorkHR.API/Reports/ReportStorageWebExtension.cs

@@ -21,59 +21,47 @@ namespace MTWorkHR.Infrastructure.Reports
         {
             try
             {
-                // Parse the string with the report name and parameter values.
                 string[] parts = url.Split('?');
                 string reportName = parts[0];
-                string parametersQueryString = parts.Length > 1 ? parts[1] : String.Empty;
+                string parametersQueryString = parts.Length > 1 ? parts[1] : string.Empty;
 
-                // Create a report instance.
-
-                XtraReport report= getReport(reportName);
-              
-                if (report != null)
+                XtraReport report = getReport(reportName);
+                if (report == null)
                 {
-                    // Apply the parameter values to the report.
-                    var parameters = HttpUtility.ParseQueryString(parametersQueryString);
-
-                    foreach (string parameterName in parameters.AllKeys)
-                    {
-                        if (parameters.Get(parameterName) != "null"&& parameters.Get(parameterName) != null)
-                        {
-                                report.Parameters[parameterName].Value = Convert.ChangeType(
-                            parameters.Get(parameterName), report.Parameters[parameterName].Type);
-                        }
-                    }
+                    throw new DevExpress.XtraReports.Web.ClientControls.FaultException($"Could not find report '{url}'.");
+                }
 
-                    // Disable the Visible property for all report parameters
-                    // to hide the Parameters Panel in the viewer.
-                    foreach (var parameter in report.Parameters)
+                // Apply report parameters
+                var parameters = HttpUtility.ParseQueryString(parametersQueryString);
+                foreach (string parameterName in parameters.AllKeys)
+                {
+                    if (!string.IsNullOrEmpty(parameters.Get(parameterName)) && parameters.Get(parameterName) != "null")
                     {
-                        parameter.Visible = false;
+                        report.Parameters[parameterName].Value = Convert.ChangeType(parameters.Get(parameterName), report.Parameters[parameterName].Type);
                     }
+                }
 
-                    // If you do not hide the panel, disable the report's RequestParameters property.
-                    // report.RequestParameters = false;
+                report.CreateDocument(); // Ensure the report document is created
 
-                    using (MemoryStream ms = new MemoryStream())
-                    {
-                        report.SaveLayoutToXml(ms);
-                        return ms.ToArray();
-                    }
+                using (MemoryStream ms = new MemoryStream())
+                {
+                    report.ExportToPdf(ms);  // Export to PDF
+                    return ms.ToArray();
                 }
             }
             catch (Exception ex)
             {
-                throw new DevExpress.XtraReports.Web.ClientControls.FaultException(
-                    "Could not get report data.", ex);
+                throw new DevExpress.XtraReports.Web.ClientControls.FaultException($"Error generating report '{url}': {ex.Message}", ex);
             }
-            throw new DevExpress.XtraReports.Web.ClientControls.FaultException(
-                string.Format("Could not find report '{0}'.", url));
         }
+
         private XtraReport getReport(string reportName)
         {
             switch (reportName)
             {
                 case "ContractReport":
+                case "contractreport":
+                case "contractReport":
                     return new ContractReport();
                 case "ContractAllowance":
                     return new ContractAllowances();

BIN
MTWorkHR.API/contract.pdf


+ 1 - 0
MTWorkHR.Application/ApplicationServiceRegistration.cs

@@ -44,6 +44,7 @@ namespace MTWorkHR.Application
             services.AddScoped<ISubscriptionService, SubscriptionService>();
             services.AddScoped<IMatchMoveService, MatchMoveService>();
             services.AddScoped<IAmazonPayService, AmazonPayService>();
+           // services.AddScoped<IContractPdfService, ContractPdfService>();
 
             services.AddHttpClient<AmazonPayService>();
 

+ 23 - 7
MTWorkHR.Application/Chat/ChatHub.cs

@@ -38,16 +38,16 @@ namespace MTWorkHR.API.Chat
             _logger = logger;
         }
 
-        public async Task GetUsers()
+        public async Task GetUsers(bool internalUsers)
         {
-            var myCompanyUsers = await GetAllCompanyEmployees();
+            var myCompanyUsers = await GetAllCompanyEmployees(internalUsers);
 
             await Clients.Caller.SendAsync("UpdateUserList", myCompanyUsers);
         }
 
 
 
-        public async Task<List<ChatUserDto>> GetAllCompanyEmployees()
+        public async Task<List<ChatUserDto>> GetAllCompanyEmployees(bool internalUsers)
         {
             var response = new List<ChatUserDto>();
 
@@ -71,11 +71,27 @@ namespace MTWorkHR.API.Chat
                     .Distinct()
                     .ToHashSet();
 
-                // Filter all employees by CompanyId or if they have messaged the user
+
                 var employeesToChat = allEmployees
-                    .Where(e => e.Id != userId &&
-                               (e.CompanyId == CompanyId || companyUserIds.Contains(e.Id)))
-                    .ToList();
+                       .Where(e => e.Id != userId && (e.CompanyId == CompanyId || companyUserIds.Contains(e.Id)));
+                if (internalUsers)
+                {
+                    // Filter all employees by inside Company or if they have messaged the user
+                    employeesToChat = employeesToChat
+                        .Where(e => e.CompanyId == CompanyId)
+                        .ToList();
+                }
+                else
+                {// Filter all employees outside  user Company or if they have messaged the user
+                    employeesToChat = employeesToChat
+                      .Where(e => e.CompanyId != CompanyId)
+                      .ToList();
+                }
+                // Filter all employees by CompanyId or if they have messaged the user
+                //var employeesToChat = allEmployees
+                //    .Where(e => e.Id != userId &&
+                //               (e.CompanyId == CompanyId || companyUserIds.Contains(e.Id)))
+                //    .ToList();
 
                 // Get online users and map to a dictionary for faster lookups
                 var allConnections = await _unitOfWork.HubConnection.GetAllAsync();

+ 1 - 0
MTWorkHR.Application/Dtos/Attendance/AttendancePagingInputDto.cs

@@ -11,6 +11,7 @@ namespace MTWorkHR.Application.Models
     {
         public DateTime? SearchDate { get; set; }
         public string? UserId { get; set; }
+        public string? UserName { get; set; }
 
 
     }

+ 19 - 0
MTWorkHR.Application/Dtos/Attendance/BusinessTripDto.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Application.Models
+{
+    public class BusinessTripDto : OrderRequestDto
+    {
+        public BusinessTripExpensesDto? BusinessTripExpenses { get; set; }
+
+    }
+}

+ 29 - 0
MTWorkHR.Application/Dtos/Attendance/BusinessTripExpensesDto.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Application.Models
+{
+    public class BusinessTripExpensesDto : EntityDto
+    {
+        public decimal? TicketCost{ get; set; }
+        public decimal? TransportationCost { get; set; }
+        public decimal? AccommodationCost { get; set; }
+        public decimal? OtherCost { get; set; }
+        public decimal? TotalCost { get; set; }
+        //public OrderAttachmentDto? TicketAttachment { get; set; }
+        //public OrderAttachmentDto? TransportationAttachment { get; set; }
+        //public OrderAttachmentDto? AccommodationAttachment { get; set; }
+        public List<OrderAttachmentDto>? Attachments { get; set; }
+
+
+    }
+}

+ 1 - 0
MTWorkHR.Application/Dtos/Attendance/OrderAllocationDto.cs

@@ -14,6 +14,7 @@ namespace MTWorkHR.Application.Models
     public class OrderAllocationDto : EntityDto
     {
         public int? NumberOfDays { get; set; }
+        public long ContractId { get; set; }
         public int OrderTypeId { get; set; }
         public string? EmployeeId { get; set; }
         public int? LeaveTypeId { get; set; }

+ 20 - 0
MTWorkHR.Application/Dtos/Attendance/OrderAttachmentDto.cs

@@ -0,0 +1,20 @@
+using Microsoft.AspNetCore.Http;
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace MTWorkHR.Application.Models
+{
+    public class OrderAttachmentDto : EntityDto
+    {
+        //public long OrderRequestId { get; set; }
+
+        public string? FileName { get; set; }
+        
+        public string? CreateDateStr { get; set; }
+        public string? OriginalName { get; set; }
+        public string? FilePath { get; set; }
+        public string? ContentType { get; set; }
+
+    }
+}

+ 13 - 9
MTWorkHR.Application/Dtos/Attendance/OrderRequestDto.cs

@@ -4,9 +4,7 @@ using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
-using MTWorkHR.Application.Models;
-using MTWorkHR.Core.Entities;
-using MTWorkHR.Core.Entities.Base;
+
 using MTWorkHR.Core.Global;
 
 namespace MTWorkHR.Application.Models
@@ -18,14 +16,20 @@ namespace MTWorkHR.Application.Models
         public string? RequestingEmployeeId { get; set; }
         public int OrderTypeId { get; set; }
         public int? LeaveTypeId { get; set; }
+        public string? RequestTitle { get; set; }
         public string? RequestComments { get; set; }
-        public ApprovalStatusEnum OrderStatus { get; set; }
-        public int? CountryId { get; set; }
-        public int? CityId { get; set; }
+        public ApprovalStatusEnum? OrderStatus { get; set; }
+ 
         public OrderTypeDto? OrderType { get; set; }
         public LeaveTypeDto? LeaveType { get; set; }
-        public UserDto? Employee { get; set; }
-        public string? StartTime { get; set; }
-        public string? EndTime { get; set; }
+        public EmployeeDto? Employee { get; set; }
+       
+        public long ContractId { get; set; }
+        public decimal? CourseNumberOfHours { get; set; }//Course hours
+        public decimal? CourseCost { get; set; }
+        public decimal? TotalDays { get; set; }
+
+        public List<OrderAttachmentDto>? OrderAttachments { get; set; }
+        public DateTime? CreateDate { get; set; }
     }
 }

+ 26 - 0
MTWorkHR.Application/Dtos/Attendance/OrderRequestHRDto.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Application.Models
+{
+    public class OrderRequestHRDto : EntityDto
+    {
+        public DateTime StartDate { get; set; }
+        public DateTime EndDate { get; set; }
+        public int OrderTypeId { get; set; }
+        public int? LeaveTypeId { get; set; }
+        public string? RequestComments { get; set; }
+        public ApprovalStatusEnum OrderStatus { get; set; }
+        public string? OrderTypeName { get; set; }
+        public string? LeaveTypeName { get; set; }
+
+    }
+}

+ 24 - 0
MTWorkHR.Application/Dtos/Attendance/OverTimeDayDto.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Application.Models
+{
+    public class OverTimeDayDto : EntityDto
+    {
+        public DateTime? OverTimeDate { get; set; }
+        public string? StartTime { get; set; }
+        public string? EndTime { get; set; }
+        public decimal? TotalHours { get; set; }
+        public string? OverTimeDetail { get; set; }
+
+        public OrderAttachmentDto? OverTimeAttachment { get; set; }
+    }
+}

+ 17 - 0
MTWorkHR.Application/Dtos/Attendance/OverTimeDto.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Application.Models
+{
+    public class OverTimeDto : OrderRequestDto
+    {
+        public List<OverTimeDayDto>? OverTimeDays { get; set; }
+        
+    }
+}

+ 24 - 0
MTWorkHR.Application/Dtos/Attendance/ServiceCertificateDto.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Application.Models
+{
+    public class ServiceCertificateDto : EntityDto
+    {
+        public string? ToWhom{ get; set; }
+        public string? Name { get; set; }
+        public string? Salary { get; set; }
+        public DateTime? JoiningDate { get; set; }
+        public DateTime? ToDate { get; set; }
+        public string? Position { get; set; }
+
+    }
+}

+ 19 - 0
MTWorkHR.Application/Dtos/Attendance/ServiceCertificateRequestDto.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Application.Models
+{
+    public class ServiceCertificateRequestDto : OrderRequestDto
+    {
+        public ServiceCertificateDto? ServiceCertificate { get; set; }
+
+    }
+}

+ 48 - 0
MTWorkHR.Application/Dtos/Contract/ContractAllHRDto.cs

@@ -0,0 +1,48 @@
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Application.Models
+{
+    public class ContractAllHRDto : EntityDto
+    {
+        public ContractTypeEnum ContractTypeId { get; set; }
+        public ContractStatusEnum ContractStatusId { get; set; }
+        public TypeOfWork? TypeOfWork { get; set; } //: :   اختيار: عقد بدوام كامل -  عقد دوام جزئي   
+        public DateTime? StartDate { get; set; }
+        public DateTime? EndDate { get; set; }
+
+        public long CompanyId { get; set; }
+        
+        public string UserId { get; set; }
+        public string? EmployeeName { get; set; }
+        public string? EmployeeEmail { get; set; }
+        public string? ProfileImagePath { get; set; }
+
+        public int? JobId { get; set; }
+        //-------------------Scope of work-----------
+        public string? JobTitleName { get; set; }
+        public string? JobDescription{ get; set; }
+
+        //----------Salary-----------------
+        [MaxLength(50)]
+        public string? Currency { get; set; }
+        public decimal? Salary{ get; set; }
+        public DateTime? LastInvoiceDate { get; set; }
+        //------------------------Fixed Pay----------------
+        public string? Teams{ get; set; }
+        public int? RestVacations{ get; set; }
+        public int? SpentVacations { get; set; }
+        public int? VacationDays { get; set; } //اختيار: بدون – سنويا (رقم)
+
+    }
+}

+ 8 - 1
MTWorkHR.Application/Dtos/Contract/ContractDto.cs

@@ -1,4 +1,5 @@
 using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
 using MTWorkHR.Core.Entities.Base;
 using MTWorkHR.Core.Global;
 using Newtonsoft.Json;
@@ -55,7 +56,7 @@ namespace MTWorkHR.Application.Models
 
         //------Working time---------------
         [JsonProperty(Required = Required.AllowNull)]
-        public List<ContractWorkingDayDto>? WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
+        public List<string>? WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
         public WorkingHours WorkingHours { get; set; } //	يومي/ اسبوعي  
         public int? WorkingHoursNum { get; set; } // عدد الساعات
         public DateTime? StartDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
@@ -74,7 +75,13 @@ namespace MTWorkHR.Application.Models
         public DateTime? LastPatchDateFrom { get; set; } //
         public DateTime? LastPatchDateTo { get; set; } // 
         public decimal? LastPatchAmount { get; set; }
+        public string? Teams{ get; set; }
+        public string? Vacations{ get; set; }
+        public string? FilePath { get; set; }// on cloud
 
+        //__________________HR data_________-
+        public List<TeamDto>? TeamList { get; set; }
+        public List<OrderRequestDto>? OrderList { get; set; }
 
 
         //---------Allowances----------------------

+ 78 - 0
MTWorkHR.Application/Dtos/Contract/ContractHRDto.cs

@@ -0,0 +1,78 @@
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Application.Models
+{
+    public class ContractHRDto : EntityDto
+    {
+        public ContractTypeEnum ContractTypeId { get; set; }
+        public ContractStatusEnum ContractStatusId { get; set; } 
+
+        public long CompanyId { get; set; }
+        
+        public string UserId { get; set; }
+        public string? EmployeeName { get; set; }
+        public string? EmployeeEmail { get; set; }
+        public string? ProfileImagePath { get; set; }
+        public int? JobId { get; set; }
+        public int? AcademicQualificationId { get; set; }
+        public int? SpecializationId { get; set; }
+        public int WorkCountryId { get; set; }
+        public int WorkStateId { get; set; }
+        //-------------------Scope of work-----------
+        public string? JobTitleName { get; set; }
+        public string? JobDescription{ get; set; }
+        [MaxLength(150)]
+        public string? JobNumber { get; set; } //ثابت و مأخوذ من المنصة
+        //----------------Contract data -------------------------
+        public DateTime? StartDate { get; set; }
+        public DateTime? EndDate { get; set; }
+
+        public ContractDurationEnum? ContractDurationId { get; set; } //:  اختيار: شهري – ربعي – نصف سنوي – 3 ارباع – سنوي
+        public TypeOfWork? TypeOfWork { get; set; } //: :   اختيار: عقد بدوام كامل -  عقد دوام جزئي   
+
+        //------Working time---------------
+        public List<string>? WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
+        public WorkingHours WorkingHours { get; set; } //	يومي/ اسبوعي  
+        public int? WorkingHoursNum { get; set; } // عدد الساعات
+        public DateTime? StartDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
+        public DateTime? EndDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
+
+        //----------Salary-----------------
+        [MaxLength(50)]
+        public string? Currency { get; set; }
+        public decimal? Salary{ get; set; }
+        public string? BillingCycle { get; set; }// 2 fortnightly, 4 Monthly
+        public DateTime? NextSalaryDate { get; set; }// 2 fortnightly, 4 Monthly
+        //------------------------Fixed Pay----------------
+        public DateTime? FirstPatchDateFrom { get; set; }
+        public DateTime? FirstPatchDateTo { get; set; } //
+        public decimal? FirstPatchAmount { get; set; }
+
+        public DateTime? LastPatchDateFrom { get; set; } //
+        public DateTime? LastPatchDateTo { get; set; } // 
+        public decimal? LastPatchAmount { get; set; }
+        public string? Teams{ get; set; }
+        public int? SpentVacations{ get; set; }
+        public int? RestVacations { get; set; }
+        public int? VacationDays { get; set; } //اختيار: بدون – سنويا (رقم)
+
+        //__________________HR data_________-
+        public List<TeamDto>? TeamList { get; set; }
+        public List<OrderRequestHRDto>? OrderList { get; set; }
+        //-------------------------------
+        public List<ContractTaskDto>? ContractTasks { get; set; }
+        public List<ProjectStageDto>? ProjectStages { get; set; }
+        public List<InvoiceDto>? InvoiceList { get; set; }
+    }
+}

+ 1 - 0
MTWorkHR.Application/Dtos/Contract/ContractPagingInputDto.cs

@@ -11,6 +11,7 @@ namespace MTWorkHR.Application.Models
     {
         public long? ContractStatusId { get; set; }
         public long? ContractTypeId { get; set; }
+        public string? UserName { get; set; }
 
 
     }

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

@@ -55,6 +55,7 @@ namespace MTWorkHR.Application.Models
         public long? CompanyId { get; set; }
         public bool IsCheckedIn { get; set; }
         public bool IsCheckedOut { get; set; }
+        public string? ProfileImagePath { get; set; }
         public IFormFile? ProfileImage { get; set; }
         public IFormFile? CVAttach { get; set; }
         public IFormFile? PassportAttach { get; set; }

+ 1 - 1
MTWorkHR.Application/Dtos/PagingDto.cs

@@ -29,7 +29,7 @@ namespace MTWorkHR.Application.Models
         public int PageNumber { get => pageNumber ==0 ? 1 : pageNumber; set => pageNumber = value; }
         public int PageSize { get => pageSize==0?10: pageSize; set => pageSize = value; }
         public string? OrderByField { get => string.IsNullOrEmpty(orderByField)?"Id": orderByField; set => orderByField = value; }
-        public string? OrderType { get => string.IsNullOrEmpty(orderType) ? "asc" : orderType; set => orderType = value; }
+        public string? OrderType { get => string.IsNullOrEmpty(orderType) ? "desc" : orderType; set => orderType = value; }
         public string? Filter { get; set; }
         public string? HiddenFilter { get ; set; }
     }

+ 23 - 0
MTWorkHR.Application/Dtos/Payment/InvoiceDto.cs

@@ -0,0 +1,23 @@
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class InvoiceDto : FullAuditEntity
+    {
+        public string? InvoiceNumber { get; set; }
+        public DateTime? InvoiceDate{ get; set; }
+        public decimal? Amount{ get; set; }
+        public int? Status{ get; set; }
+        public int? ContractId{ get; set; }
+        public int? UserId { get; set; }
+
+    }
+}

+ 22 - 0
MTWorkHR.Application/Dtos/User/EmployeeDto.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Application.Models
+{
+    public class EmployeeDto 
+    {
+        public string? Id { get; set; }
+        public string? EmployeeName { get; set; }
+        public string? FirstName { get; set; }
+
+        public string? LastName { get; set; }
+        public string? Email { get; set; }
+        public string? Position { get; set; }
+        public string? ProfileImagePath { get; set; }
+    }
+}

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

@@ -10,6 +10,8 @@ namespace MTWorkHR.Application.Models
     public class OrderPagingInputDto : PagingInputDto, IOrderPagingInputDto
     {
         public DateTime? SearchDate { get; set; }
+        public string? UserName { get; set; }
+
         public string? AssignedUserId { get; set; }
         public long? OrderTypeId { get; set; }
         public long? LeaveTypeId { get; set; }

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

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

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

@@ -18,9 +18,7 @@ namespace MTWorkHR.Application.Filters
             //The below line can be used if you are reading permissions from token
             //var permissionsFromToken=context.HttpContext.User.Claims.Where(x=>x.Type=="Permissions").Select(x=>x.Value).ToList()
 
-            //Identity.Name will have windows logged in user id, in case of Windows Authentication
-            //Indentity.Name will have user name passed from token, in case of JWT Authenntication and having claim type "ClaimTypes.Name"
-            // var userName = context.HttpContext.User.Identity.Name;
+            //var userNamex = context.HttpContext.User.Identity.Name;
             var cc = context.HttpContext.User.Identities.FirstOrDefault();
             var cc2 = cc.Claims.FirstOrDefault(c => c.Type.Contains( "email"));
             var email = cc2 != null ? cc2.Value : "";

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

@@ -109,8 +109,28 @@ namespace MTWorkHR.Application.Mapper
                 .ForMember(d => d.TotalHours, o => o.MapFrom(s =>(s.CheckInTime.HasValue && s.CheckOutTime.HasValue) ? (s.CheckOutTime.Value - s.CheckInTime.Value).TotalHours:0));
 
             CreateMap<AttendanceDto, Attendance>().ForMember(d => d.CreateDate, o => o.Ignore());
+            CreateMap<OrderAttachmentDto, OrderAttachment>().ReverseMap()
+                .ForMember(d => d.CreateDateStr, o => o.Ignore());
+            CreateMap<OverTimeDayAttachment, OrderAttachmentDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
+            CreateMap<BusinessTripAttachment, OrderAttachmentDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
+            
             CreateMap<OrderAllocation, OrderAllocationDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
-            CreateMap<OrderRequest, OrderRequestDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore());
+
+            CreateMap<OrderRequestDto, OrderRequest>().ForMember(d => d.CreateDate, o => o.Ignore())
+                .ForMember(d => d.OrderAttachments, opt => opt.MapFrom(src => src.OrderAttachments ?? new List<OrderAttachmentDto>()));
+            CreateMap<OrderRequest, OrderRequestDto>();
+            
+            CreateMap<OrderRequest, OrderRequestHRDto>().ForMember(d => d.LeaveTypeName, o=> o.MapFrom(s=> s.LeaveType != null ? GlobalInfo.lang == "ar" ? s.LeaveType.NameAr: s.LeaveType.NameEn:""))
+                .ForMember(d => d.OrderTypeName, o => o.MapFrom(s => s.OrderType != null ? GlobalInfo.lang == "ar" ? s.OrderType.NameAr : s.OrderType.NameEn:""));
+            
+            CreateMap<OverTimeDay, OverTimeDayDto>().ReverseMap();
+            CreateMap<BusinessTripDto, OrderRequest>().ReverseMap();
+            CreateMap<OverTimeDto, OrderRequest>().ReverseMap();
+            CreateMap<ServiceCertificateRequestDto, OrderRequest>().ReverseMap();
+            CreateMap<BusinessTripExpensesDto, BusinessTripExpenses>().ReverseMap();
+            CreateMap<ServiceCertificate, ServiceCertificateDto>().ReverseMap();
+
+
             CreateMap<OrderType, OrderTypeDto>().ReverseMap();
             CreateMap<LeaveType, LeaveTypeDto>().ReverseMap();
             CreateMap<CompanyDto, Company>().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore());
@@ -138,19 +158,26 @@ namespace MTWorkHR.Application.Mapper
             CreateMap<ChatMessageDto, ChatMessage>().ReverseMap();
             
             //-----------Contract----
-            CreateMap<Contract, ContractDto>();
+            CreateMap<Invoice, InvoiceDto>().ReverseMap();
+            CreateMap<Contract, ContractDto>().ForMember(d => d.WorkingDays, o => o.Ignore());
+            CreateMap<Contract, ContractHRDto>().ForMember(d => d.WorkingDays, o => o.Ignore());
+            CreateMap<Contract, ContractAllHRDto>();
+            
             CreateMap<ContractDto, Contract>()
                 .ForMember(d => d.CreateDate, o => o.Ignore())
                 .ForMember(d => d.CreateUser, o => o.Ignore());
             CreateMap<ContractAllowance, ContractAllowanceDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
             CreateMap<ContractTask, ContractTaskDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
-            CreateMap<ContractWorkingDay, ContractWorkingDayDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
+            //CreateMap<ContractWorkingDay, ContractWorkingDayDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
             CreateMap<ContractTaskAttachment, ContractTaskAttachmentDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
             CreateMap<ProjectStage, ProjectStageDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
             CreateMap<ProjectStageAttachment, ProjectStageAttachmentDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
             CreateMap<SubscriptionConfiguration, SubscriptionConfigurationDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
 
-
+            CreateMap<ContractDetail, Contract>();
+            CreateMap<Contract, ContractDetail>();
+            //.ForMember(s => s.ContractDuration, o => o.MapFrom(s => s.ContractDurationId == null ? "" : ((ContractDurationEnum)s.ContractDurationId).ToString()));
+            //.ForMember(s => s.WorkCountry, o => o.MapFrom(s => s.WorkCountryId == null ? "" : s.WorkCountryId));
         }
     }
 }

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

@@ -38,6 +38,19 @@ namespace MTWorkHR.Identity.Services
             {
                 throw new AppException(ExceptionEnum.EmailNotExist);
             }
+            var roles = await _userManager.GetRolesAsync(user);
+            if (roles.Any(r => r == "Admin"))
+            {
+                throw new AppException(ExceptionEnum.NotAuthorized);
+            }
+            if (user.IsStopped == true)
+            {
+                throw new AppException(ExceptionEnum.AccountLocked);
+            }
+            if (user.IsDeleted == true)
+            {
+                throw new AppException(ExceptionEnum.UserNotExist);
+            }
             var result = await _signInManager.CheckPasswordSignInAsync(user, request.Password, false);
             if(!result.Succeeded)
             {

+ 41 - 1
MTWorkHR.Application/Services/Base/BlobFileService.cs

@@ -4,6 +4,7 @@ using Azure.Storage.Blobs.Models;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.StaticFiles;
+using Microsoft.Extensions.Logging;
 using MTWorkHR.Application.Models;
 using MTWorkHR.Application.Services.Interfaces;
 using MTWorkHR.Core.Global;
@@ -20,12 +21,14 @@ namespace MTWorkHR.Application.Services
         public const string ErrorMessageKey = "ErrorMessage";
         private readonly BlobServiceClient _blobServiceClient;
         private readonly BlobContainerClient _containerClient;
+        private readonly ILogger<BlobFileService> _logger;
 
-        public BlobFileService(BlobServiceClient blobServiceClient)
+        public BlobFileService(BlobServiceClient blobServiceClient, ILogger<BlobFileService> logger)
         {
             _blobServiceClient = blobServiceClient;
             _containerClient = _blobServiceClient.GetBlobContainerClient(ContainerName);
             _containerClient.CreateIfNotExists();
+            _logger = logger;
         }
         public async Task<AttachmentResponseDto> UploadFile(IFormFile file)
         {
@@ -80,7 +83,44 @@ namespace MTWorkHR.Application.Services
                 return "";
             }
         }
+        public async Task<AttachmentResponseDto> UploadFile(byte[] pdfBytes, string fileName)
+        {
+            AttachmentResponseDto result = new AttachmentResponseDto();
+            try
+            {
+                // Get a reference to the container
+                //BlobContainerClient containerClient = _blobServiceClient.GetBlobContainerClient("Contracts");
+
+                // Create the container if it doesn’t exist
+                //containerClient.CreateIfNotExists();
+                var blobClient = _containerClient.GetBlobClient(fileName);
+                if (blobClient != null)
+                {
+                    using (MemoryStream uploadStream = new MemoryStream(pdfBytes))
+                    {
+                        _logger.LogInformation("1--Contract uploadStream length={0}", pdfBytes.Length);
 
+                        var status = await blobClient.UploadAsync(uploadStream, overwrite: true);
+                        _logger.LogInformation("2--Contract uploadStream Status={0}, uri={1}", status, blobClient.Uri.AbsoluteUri);
+
+                    }
+                    result.FileName = fileName;
+                    result.FilePath = blobClient.Uri.AbsoluteUri;
+                    _logger.LogInformation("3--Contract upload finish path={0}", blobClient.Uri.AbsoluteUri);
+                    return result;
+                }
+                else
+                {
+                    _logger.LogInformation("BlobClient is null when upload file ={0}", fileName);
+                    return result;
+                }
+            }
+            catch (Exception ex)
+            {
+                _logger.LogError(ex.Message);
+                return result;
+            }
+        }
         public async Task<BlobObject> Download(string url)
         {
             try

+ 5 - 0
MTWorkHR.Application/Services/Base/FileService.cs

@@ -215,5 +215,10 @@ namespace MTWorkHR.Application.Services
         {
             throw new NotImplementedException();
         }
+
+        public Task<AttachmentResponseDto> UploadFile(byte[] pdfBytes, string fileName)
+        {
+            throw new NotImplementedException();
+        }
     }
 }

+ 73 - 0
MTWorkHR.Application/Services/Contract/ContractPdfService.cs

@@ -0,0 +1,73 @@
+
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.UnitOfWork;
+using MTWorkHR.Application.Services.Interfaces;
+using MTWorkHR.Core.Entities;
+using Microsoft.AspNetCore.Identity;
+using MTWorkHR.Application.Mapper;
+using MTWorkHR.Core.Global;
+using MTWorkHR.Infrastructure.Entities;
+using MTWorkHR.Infrastructure.Repositories;
+using MTWorkHR.Infrastructure.UnitOfWorks;
+using MTWorkHR.Core.IRepositories.Base;
+using Microsoft.AspNetCore.Http;
+using System.IO;
+using MTWorkHR.Infrastructure.Reports;
+using MTWorkHR.Core.Entities.Base;
+using Microsoft.Extensions.Logging;
+using MTWorkHR.Application.Identity;
+
+namespace MTWorkHR.Application.Services
+{
+    public class ContractPdfService
+    {
+      //  private readonly IContractService _contractService;
+      //  //   private readonly IFileService _fileService;
+      //  private readonly IUnitOfWork _unitOfWork;
+      ////  private ILogger _logger;
+      //  private readonly IUserService _userService;
+
+      //  public ContractPdfService(IUnitOfWork unitOfWork, IContractService contractService, IUserService userService) 
+      //  {
+      //     _unitOfWork = unitOfWork;
+      //     _userService = userService;
+      //     _contractService = contractService;
+      //    //  _fileService = fileService;
+      //  }
+
+      //  public async Task GenerateContractPdf(string outputPath, long contractId)
+      //  {
+      //      try
+      //      {
+      //          //    var contractData = await _unitOfWork.Contract.GetByIdWithAllChildren(contractId);
+      //          //    // var contractData = new Contract { CompanyId = 1, JobTitleName = "SW Developer", ProjectStages = new List<ProjectStage> { new ProjectStage { Title = "Team Project", ScopeOfWork = "testing" } } };
+
+      //          //    var contract = MapperObject.Mapper.Map<ContractDetail>(contractData);
+
+      //          //    var user = await _userService.GetUserById(contractData.UserId);
+      //          //    if (user != null)
+      //          //    {
+      //          //        contract.EmployeeName = user.FirstName + " " + user.LastName;
+      //          //        contract.EmployeeEmail = user.Email;
+      //          //        contract.EmployeePassport = user.PassportNumber;
+      //          //        contract.EmployeePhone = user.PhoneNumber;
+      //          //        contract.EmployeeUniversity = user.UniversityName;
+      //          //        contract.AcademicQualification = user.QualificationName;
+      //          //        contract.EmployeeJobName = user.JobTitleName;
+      //          //    }
+
+
+      //          var contract = await _contractService.GetByIdReport(contractId);
+      //          var x = await new ContractPdfGenerator().GenerateContractPdf(outputPath, contract);
+      //      }catch(Exception e)
+      //      {
+      //     //     _logger.LogError(e, "Failed to generate contract PDF for contractId {ContractId}", contractId);
+      //          var msg = e.Message;
+      //      }
+      //  }
+
+     
+
+       
+    }
+}

+ 309 - 7
MTWorkHR.Application/Services/Contract/ContractService.cs

@@ -9,7 +9,13 @@ using MTWorkHR.Core.Entities;
 using System.Linq.Dynamic.Core;
 using Microsoft.AspNetCore.Identity;
 using MTWorkHR.Infrastructure.Entities;
-
+using System.Linq;
+using MTWorkHR.Core.IDto;
+using MTWorkHR.Core.Entities.User;
+using System.Diagnostics.Contracts;
+using Contract = MTWorkHR.Core.Entities.Contract;
+using MTWorkHR.Infrastructure.Reports;
+using DevExpress.DataProcessing;
 namespace MTWorkHR.Application.Services
 {
     public class ContractService : BaseService<Contract, ContractDto, ContractDto>, IContractService
@@ -17,18 +23,24 @@ namespace MTWorkHR.Application.Services
         private readonly IUnitOfWork _unitOfWork;
         private readonly IUserService _userService;
         private readonly GlobalInfo _globalInfo;
+        private readonly IFileService _fileService;
+        private readonly IOrderAllocationService _orderAllocationService;
 
-        public ContractService(IUnitOfWork unitOfWork, IUserService userService, GlobalInfo globalInfo) : base(unitOfWork)
+        public ContractService(IUnitOfWork unitOfWork, IUserService userService, GlobalInfo globalInfo, IOrderAllocationService orderAllocationService, IFileService fileService) : base(unitOfWork)
         {
             _unitOfWork = unitOfWork;
             _userService = userService;
             _globalInfo = globalInfo;
+            _orderAllocationService = orderAllocationService;
+            _fileService = fileService;
         }
 
         public override async Task<ContractDto> GetById(long id)
         {
             var entity = await _unitOfWork.Contract.GetByIdWithAllChildren(id);
             var response = MapperObject.Mapper.Map<ContractDto>(entity);
+            response.WorkingDays = entity.WorkingDays != null ? entity.WorkingDays.Split(",").ToList() : null;
+
             return response;
         }
        
@@ -40,7 +52,7 @@ namespace MTWorkHR.Application.Services
             {
                 throw new AppException(ExceptionEnum.MapperIssue);
             }
-
+            entity.WorkingDays = input.WorkingDays!=null? string.Join(",", input.WorkingDays): null;
             var team = await _unitOfWork.Contract.AddAsync(entity);
             await _unitOfWork.CompleteAsync();
 
@@ -64,6 +76,8 @@ namespace MTWorkHR.Application.Services
         //    var response = Mapper.MapperObject.Mapper.Map<ContractDto>(entity);
         //    return response;
         //}
+       
+
         public async Task<PagingResultDto<ContractDto>> GetAll(ContractPagingInputDto PagingInputDto)
         {
             var res = await _unitOfWork.Contract.GetAllWithChildrenAsync();
@@ -71,13 +85,13 @@ namespace MTWorkHR.Application.Services
 
             if (_globalInfo.UserType != UserTypeEnum.Business)
             {
-               // query = query.Where(m => m.ContractUsers != null && m.ContractUsers.Count > 0 && m.ContractUsers.Count(u=> u.AssignedUserId == _globalInfo.UserId) > 0);
+                // query = query.Where(m => m.ContractUsers != null && m.ContractUsers.Count > 0 && m.ContractUsers.Count(u=> u.AssignedUserId == _globalInfo.UserId) > 0);
 
             }
             if (PagingInputDto.Filter != null)
             {
                 var filter = PagingInputDto.Filter;
-                query = query.Where(u => u.JobDescription.Contains(filter));
+                query = query.Where(u => u.JobDescription != null && u.JobDescription.Contains(filter));
             }
 
             if (PagingInputDto.ContractStatusId != null)
@@ -119,6 +133,148 @@ namespace MTWorkHR.Application.Services
             return response;
         }
 
+        #region HR data____________________________
+        public async Task<PagingResultDto<ContractAllHRDto>> GetAllForHr(ContractPagingInputDto PagingInputDto)
+        {
+            var res = await _unitOfWork.Contract.GetAllWithChildrenAsync();
+            var query = res.Item1;
+
+            if (_globalInfo.UserType != UserTypeEnum.Business)
+            {
+                // query = query.Where(m => m.ContractUsers != null && m.ContractUsers.Count > 0 && m.ContractUsers.Count(u=> u.AssignedUserId == _globalInfo.UserId) > 0);
+
+            }
+            if (PagingInputDto.Filter != null)
+            {
+                var filter = PagingInputDto.Filter;
+                query = query.Where(u => u.JobDescription.Contains(filter));
+            }
+
+            if (PagingInputDto.ContractStatusId != null)
+            {
+                query = query.Where(u => (int)u.ContractStatusId == PagingInputDto.ContractStatusId);
+            }
+            if (PagingInputDto.ContractTypeId != null)
+            {
+                query = query.Where(u => (int)u.ContractTypeId == PagingInputDto.ContractTypeId);
+            }
+
+            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<ContractAllHRDto>>(await page.ToListAsync());
+
+
+            var teamUsersList = await _unitOfWork.TeamUser.GetAllWithChildrenAsync();
+            var vacationAllocations = await _unitOfWork.OrderAllocation.GetAllAsync();
+            foreach (var item in list)
+            {
+                if (item.UserId != null)
+                {
+                    var user = await _userService.GetUserWithAttachmentById(item.UserId);
+                    if (user != null)
+                    {
+                        item.EmployeeName = user.FirstName + " " + user.LastName;
+                        item.EmployeeEmail = user.Email;
+                        var attach = user.UserAttachments?.FirstOrDefault(a => a.AttachmentTypeId == 9);
+                        item.ProfileImagePath = attach?.FilePath;
+                        //___________Get Teams
+                        //var TeamsList = teamUsersList.Item1.Where(t => t.AssignedUserId == item.UserId).Select(t => GlobalInfo.lang == "en" ? t.Team.NameEn : t.Team.NameAr);
+                        //item.Teams = TeamsList == null ? "" : string.Join(",", TeamsList);
+                        var latestTeam = teamUsersList.Item1.OrderByDescending(a=> a.Id).FirstOrDefault(t => t.AssignedUserId == item.UserId);
+                        item.Teams = latestTeam == null ? "" : GlobalInfo.lang == "en" ? latestTeam.Team?.NameEn : latestTeam.Team?.NameAr;
+                        //_____________Get vacation balance
+                        var remainVacations = vacationAllocations.Item1.FirstOrDefault(t => t.EmployeeId == item.UserId && t.ContractId == item.Id);
+                        item.RestVacations = remainVacations == null ? item.VacationDays : remainVacations.NumberOfDays ;
+                        item.SpentVacations = item.VacationDays - item.RestVacations;
+                    }
+                }
+            }
+
+            // Filter employees by name if provided
+            if (!string.IsNullOrEmpty(PagingInputDto.UserName))
+            {
+                var filter = PagingInputDto.UserName;
+
+                list = list.Where(u =>
+                     (u.EmployeeName != null && u.EmployeeName.ToLower().Contains(filter))
+                    || (u.EmployeeEmail != null && u.EmployeeEmail.ToLower().Contains(filter))
+                ).ToList();
+            }
+
+
+
+            var response = new PagingResultDto<ContractAllHRDto>
+            {
+                Result = list,
+                Total = list.Count
+            };
+
+            return response;
+        }
+        public async Task<ContractHRDto> GetByIdHRDetails(long contractId)
+        {
+            var entity = await _unitOfWork.Contract.GetByIdWithAllChildren(contractId);
+            if (entity != null)
+            {
+                var response = MapperObject.Mapper.Map<ContractHRDto>(entity);
+                response.WorkingDays = entity.WorkingDays != null ? entity.WorkingDays.Split(",").ToList() : null;
+                //--------------------
+                var user = await _userService.GetUserWithAttachmentById(entity.UserId);
+                response.EmployeeName = user.FirstName + " " + user.LastName;
+                response.EmployeeEmail = user.Email;
+                var attach = user.UserAttachments?.FirstOrDefault(a => a.AttachmentTypeId == 9);
+                response.ProfileImagePath = attach?.FilePath;
+                //___________Get Teams
+                var teamUsersList = await _unitOfWork.TeamUser.GetUserTeams(entity.UserId);
+                var teamsList = MapperObject.Mapper.Map<List<TeamDto>>(teamUsersList.Item1);
+
+                response.TeamList = teamsList;
+                //_____________Get vacation balance
+                var vacationAllocations = await _unitOfWork.OrderAllocation.GetUserAllocations(entity.UserId, 1, 1, entity.Id, DateTime.Now.Year);
+                var remainVacations = vacationAllocations;
+                response.RestVacations = remainVacations == null ? entity.VacationDays : remainVacations.NumberOfDays;
+                response.SpentVacations = entity.VacationDays - response.RestVacations;
+                //__-----------Order Requests----
+                var orderRequestsList = await _unitOfWork.OrderRequest.GetAllUserOrdersAsync(entity.UserId, contractId);
+                var vacationsList = orderRequestsList.Item1.Where(o => o.OrderStatus == ApprovalStatusEnum.Approved && o.OrderTypeId == 1 && (o.LeaveTypeId == 1 || o.LeaveTypeId == 2));
+                var orderList = MapperObject.Mapper.Map<List<OrderRequestHRDto>>(vacationsList);
+                response.OrderList = orderList;
+                /////------------------------
+                var invoiceList = await _unitOfWork.Invoice.GetAllUserInvoices(contractId);
+                var Invoices = MapperObject.Mapper.Map<List<InvoiceDto>>(invoiceList.Item1);
+
+                response.InvoiceList = Invoices;
+
+                //------------------
+                if(entity.ContractTypeId == (int)ContractTypeEnum.EmployeeContract)
+                {
+                    var lastInvoice = Invoices.LastOrDefault();
+                    var diffDate = DateTime.Now.Date - entity.StartDate.Value.Date;
+                    if(lastInvoice != null)
+                    {
+                        if (entity.BillingCycle == "Monthly")
+                            response.NextSalaryDate = lastInvoice.InvoiceDate.Value.AddMonths(1);
+                        else if (entity.BillingCycle == "Fortnightly")
+                            response.NextSalaryDate = lastInvoice.InvoiceDate.Value.AddDays(15);
+                    }
+                    else
+                    {
+                        if (entity.BillingCycle == "Monthly")
+                            response.NextSalaryDate = entity.StartDate.Value.AddMonths(1);
+                        else if(entity.BillingCycle == "Fortnightly")
+                            response.NextSalaryDate = entity.StartDate.Value.AddDays(15);
+                    }
+                }
+                return response;
+            }
+            return new ContractHRDto();
+        }
+        #endregion
         public async Task<bool> ChangeStatus(long contractId, int statusId)
         {
             var entity = await _unitOfWork.Contract.GetByIdAsync(contractId);
@@ -129,13 +285,159 @@ namespace MTWorkHR.Application.Services
             if (statusId == (int)ContractStatusEnum.Approved)
             {
                 var updatedSuccess = await _userService.Update(entity.UserId, entity.CompanyId);
-                if (!updatedSuccess) { result = false; }
+                addVacationAllocation(entity.VacationDays.HasValue ? entity.VacationDays.Value : 0, entity.UserId, contractId);
+                if (!updatedSuccess) { 
+                    result = false; 
+                }
             }
-            await _unitOfWork.CompleteAsync();
             return result;
         }
 
+        private async Task addVacationAllocation(int noVacationDays, string employeeId, long contractId)
+        {
+            try 
+            { 
+                await _orderAllocationService.Create(new OrderAllocationDto { ContractId = contractId, EmployeeId = employeeId, OrderTypeId = 1, LeaveTypeId = 1, NumberOfDays = noVacationDays, Period = DateTime.Now.Year });
+               // var orderTypes = await _unitOfWork.OrderType.GetAllAsync();
+               // var leaveTypes = await _unitOfWork.LeaveType.GetAllAsync();
+                //foreach (var orderType in orderTypes.Item1)
+                //{
+                //    foreach (var leaveType in leaveTypes.Item1)
+                //    {
+                //        if (orderType.Id != 1 && leaveType.Id != 1 && (leaveType.DefaultDays > 0 || orderType.DefaultDays > 0))
+                //        {
+                //            await _orderAllocationService.Create(new OrderAllocationDto
+                //            {
+                //                ContractId = contractId,
+                //                EmployeeId = employeeId,
+                //                OrderTypeId = (int)orderType.Id,
+                //                LeaveTypeId = (int)leaveType.Id,
+                //                NumberOfDays = leaveType.DefaultDays > 0 ? leaveType.DefaultDays : orderType.DefaultDays,
+                //                Period = DateTime.Now.Year
+                //            }
+                //            );
+                //        }
+                //    }
+                //}
+            }
+            catch(Exception ex)
+            {
+                throw ;
+            }
+            
+        }
+
+        public async Task<ContractDetail> GetByIdReport(long id)
+        {
+            var entity = await _unitOfWork.Contract.GetByIdWithAllChildren(id);
+            var contract = MapperObject.Mapper.Map<ContractDetail>(entity);
+            contract.WorkingDays = entity.WorkingDays;//!= null ? entity.WorkingDays.Split(",").ToList() : null;
+            var user = await _userService.GetUserById(entity.UserId);
+            if (user != null)
+            {
+                contract.EmployeeName = user.FirstName + " " + user.LastName;
+                contract.EmployeeEmail = user.Email;
+                contract.EmployeePassport = user.PassportNumber;
+                contract.EmployeePhone = user.PhoneNumber;
+                contract.EmployeeUniversity = user.UniversityName;
+                contract.AcademicQualification = user.QualificationName;
+                contract.EmployeeJobName = user.JobTitleName;
+            }
+            return contract;
+        }
+
 
 
+        public async Task<AttachmentResponseDto> GenerateContractPdf(string outputPath, long contractId)
+        {
+            try
+            {
+                var entity = await _unitOfWork.Contract.GetByIdWithAllChildren(contractId);
+
+                var contract = new ContractDetail
+                {
+                    StartDate = entity.StartDate,
+                    BillingCycle = entity.BillingCycle,
+                    ContractDuration = entity.ContractDurationId != null ? ((ContractDurationEnum)entity.ContractDurationId).ToString() : "",
+                    ContractStatusId = (ContractStatusEnum)entity.ContractStatusId,
+                    FirstPatchAmount = entity.FirstPatchAmount,
+                    FirstPatchDateFrom = entity.FirstPatchDateFrom,
+                    FirstPatchDateTo = entity.FirstPatchDateTo,
+                    LastPatchAmount = entity.LastPatchAmount,
+                    LastPatchDateFrom = entity.LastPatchDateFrom,
+                    LastPatchDateTo = entity.LastPatchDateTo,
+                    JobDescription = entity.JobDescription,
+                    JobNumber = entity.JobNumber,
+                    Salary = entity.Salary,
+                    JobTitleName = entity.JobTitleName,//Specialization = entity.SpecializationId,
+                    TrialPeriod = entity.TrialPeriod,
+                    VacationDays = entity.VacationDays, //WhoCanTerminateContract = entity.WhoCanTerminateContract,TypeOfWork = entity.TypeOfWork
+                                                        //WhoCanTerminateContractInTrial = 
+                    WorkCountry = entity.WorkCountryId + "",
+                    WorkingHours = entity.WorkingHours + "",
+                    ContractTypeId = (ContractTypeEnum)entity.ContractTypeId,
+                    Currency = entity.Currency,
+                    FixedAllowances = entity.FixedAllowances,
+                    ProjectStages = entity.ProjectStages,
+                    ContractTasks = entity.ContractTasks,
+                    WorkState = entity.WorkStateId + "",
+                    WorkingDays = entity.WorkingDays
+                };              
+                
+                var user = await _userService.GetUserById(entity.UserId);
+                if (user != null)
+                {
+                    contract.EmployeeName = user.FirstName + " " + user.LastName;
+                    contract.EmployeeEmail = user.Email;
+                    contract.EmployeePassport = user.PassportNumber;
+                    contract.EmployeePhone = user.PhoneNumber;
+                    contract.EmployeeUniversity = user.UniversityName;
+                    contract.AcademicQualification = user.QualificationName;
+                    contract.EmployeeJobName = user.JobTitleName;
+                    contract.EmployeeDateOfBirth = user.DateOfBirth;
+                }
+                var representativeUser = await _userService.GetUserById(entity.CompanyRepresentativeId);
+                if (representativeUser != null)
+                {
+                    contract.CompanyRepresentativeName = representativeUser.FirstName + " " + representativeUser.LastName;
+                    contract.CompanyRepresentativeEmail = representativeUser.Email;
+                    contract.CompanyRepresentativePassport = representativeUser.PassportNumber;
+                    contract.CompanyRepresentativePhone = representativeUser.PhoneNumber;
+                    contract.CompanyRepresentativePosition = representativeUser.Position ?? "";
+                }
+                var company = await _unitOfWork.Company.GetByIdAsync(entity.CompanyId);
+                if (company != null)
+                {
+                    contract.CompanyName = company.CompanyName;
+                    contract.CompanyEmail = company.Email;
+                    contract.CompanyPhone = company.PhoneNumber;
+                    contract.CompanyCR = company.CRNumber;
+                    contract.CompanyAddress = company.Address;
+                }
+
+
+                var pdfBytes = await new ContractPdfGenerator().GenerateContractPdf(outputPath, contract);
+                // Upload to Azure Blob Storage and return the Blob URL
+                string fileName = $"contract_{Guid.NewGuid()}.pdf";
+                var result = await _fileService.UploadFile(pdfBytes, fileName);
+                entity.FilePath = result.FilePath;
+                await _unitOfWork.CompleteAsync();
+
+                return result;
+            }
+            catch (Exception e)
+            {
+                throw e;
+
+                //     _logger.LogError(e, "Failed to generate contract PDF for contractId {ContractId}", contractId);
+                var msg = e.Message;
+                //return new AttachmentResponseDto();
+            }
+        }
+        public byte[] generatePdfTest()
+        {
+            var pdfBytes = new ContractPdfGenerator().GeneratePdf();
+            return pdfBytes;
+        }
     }
 }

+ 12 - 0
MTWorkHR.Application/Services/Interfaces/IContractPdfService.cs

@@ -0,0 +1,12 @@
+
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Application.Services.Interfaces
+{
+    public interface IContractPdfService 
+    {
+        Task GenerateContractPdf(string outputPath, long contractId); // Adjust parameters as needed
+    }
+}

+ 9 - 0
MTWorkHR.Application/Services/Interfaces/IContractService.cs

@@ -1,6 +1,7 @@
 
 using MTWorkHR.Application.Models;
 using MTWorkHR.Core.Entities;
+using MTWorkHR.Infrastructure.Entities;
 using System.Threading.Tasks;
 
 namespace MTWorkHR.Application.Services.Interfaces
@@ -8,7 +9,15 @@ namespace MTWorkHR.Application.Services.Interfaces
     public interface IContractService : IService<Contract, ContractDto, ContractDto>
     {
         Task<PagingResultDto<ContractDto>> GetAll(ContractPagingInputDto PagingInputDto);
+        Task<PagingResultDto<ContractAllHRDto>> GetAllForHr(ContractPagingInputDto PagingInputDto);
         Task<bool> ChangeStatus(long contractId, int statusId);
+        Task<ContractHRDto> GetByIdHRDetails(long id);
 
+
+        Task<ContractDetail> GetByIdReport(long id);
+
+        Task<AttachmentResponseDto> GenerateContractPdf(string outputPath, long contractId);
+
+        byte[] generatePdfTest();
     }
 }

+ 1 - 0
MTWorkHR.Application/Services/Interfaces/IFileService.cs

@@ -20,5 +20,6 @@ namespace MTWorkHR.Application.Services.Interfaces
         string GetActualAttachmentPath();
         Task<Tuple<MemoryStream, string, string>> GetFileDownloadInfo(string fileUrl);
         Task<BlobObject> Download(string url);
+        Task<AttachmentResponseDto> UploadFile(byte[] pdfBytes, string fileName);
     }
 }

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

@@ -7,5 +7,7 @@ namespace MTWorkHR.Application.Services.Interfaces
 {
     public interface IOrderAllocationService : IService<OrderAllocation, OrderAllocationDto, OrderAllocationDto>
     {
+        Task<OrderAllocationDto> CreateAllEmployees(OrderAllocationDto input);
+
     }
 }

+ 3 - 0
MTWorkHR.Application/Services/Interfaces/IOrderRequestService.cs

@@ -10,5 +10,8 @@ namespace MTWorkHR.Application.Services.Interfaces
     {
         Task<OrderRequestDto> ChangeStatus(long id, int statusId);
         Task<PagingResultDto<OrderRequestDto>> GetAll(OrderPagingInputDto PagingInputDto);
+        Task<OverTimeDto> GetOverTime(long id);
+        Task<BusinessTripDto> GetBusinessTrip(long id);
+        Task<ServiceCertificateRequestDto> GetServiceCertificate(long id);
     }
 }

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

@@ -9,6 +9,6 @@ namespace MTWorkHR.Application.Services.Interfaces
     {
         Task<bool> AssignAdminManager(TeamUserDto teamUser);
         Task<string> GetTeamName(long teamId);
-       
+        Task<IList<TeamDto>> GetTeamListForUser(string userId);
     }
 }

+ 3 - 0
MTWorkHR.Application/Services/Interfaces/IUserService.cs

@@ -32,8 +32,11 @@ namespace MTWorkHR.Application.Identity
         Task<List<UserAllDto>> GetAllCompanyEmployees();
         Task<BlobObject> Download(string filePath);
         Task<UserDto> GetUserWithAttachmentById(string id);
+        Task<List<UserDto>> GetUsersWithAttachmentsByIds(List<string> ids);
+        
         Task<string> GetProfileImage(string userId);
         Task<bool> Update(string userId, long companyId);
         Task Suspend(string id);
+        Task<bool> UnAssignCompanyEmployees(long companyId);
     }
 }

+ 15 - 0
MTWorkHR.Application/Services/Task/ProjectService.cs

@@ -109,6 +109,21 @@ namespace MTWorkHR.Application.Services
             var list = MapperObject.Mapper
                 .Map<IList<ProjectDto>>(await page.ToListAsync());
 
+            var tasks = await _unitOfWork.UserTask.GetAllWithChildrenAsync();
+
+
+            foreach (var project in list)
+            {
+                var projectTasks = tasks.Item1.Where(a=> a.ProjectId == project.Id);
+                var totalCount = (decimal)projectTasks.Count();
+                if (totalCount > 0)
+                {
+                    decimal countDone = projectTasks.Count(a => a.TaskStatus.NameEn == "Done");
+                    project.ProgressPercentage = countDone / totalCount;
+                }
+                else project.ProgressPercentage = 0;
+            }
+
             var response = new PagingResultDto<ProjectDto>
             {
                 Result = list,

+ 110 - 74
MTWorkHR.Application/Services/User/AttendanceService.cs

@@ -31,105 +31,141 @@ namespace MTWorkHR.Application.Services
             _globalInfo = globalInfo;
             _userService = userService;
         }
-        public async Task<PagingResultDto<AttendanceDto>> GetAll(AttendancePagingInputDto PagingInputDto)
+        public async Task<PagingResultDto<AttendanceDto>> GetAll(AttendancePagingInputDto pagingInputDto)
         {
-            var res = await _unitOfWork.Attendance.GetAllWithChildrenAsync();
-            var query = res.Item1;
+            // Fetch all attendances with related data
+            var attendanceResult = await _unitOfWork.Attendance.GetAllWithChildrenAsync();
+            var query = attendanceResult.Item1.AsQueryable();
 
+            // Apply filters based on user type and input
             if (_globalInfo.UserType != UserTypeEnum.Business)
             {
                 query = query.Where(m => m.UserId == _globalInfo.UserId);
+            }
 
+            if (!string.IsNullOrEmpty(pagingInputDto.Filter))
+            {
+                query = query.Where(u => u.LeaveReason!.Contains(pagingInputDto.Filter) || u.UserName!.Contains(pagingInputDto.Filter));
             }
-            if (PagingInputDto.Filter != null)
+
+            if (pagingInputDto.SearchDate != null)
             {
-                var filter = PagingInputDto.Filter;
-                query = query.Where(u => u.LeaveReason!.Contains(filter) || u.UserName!.Contains(filter));
+                query = query.Where(u => u.AttendanceDate.Date == pagingInputDto.SearchDate.Value.Date);
             }
-                  
-            if (PagingInputDto.SearchDate != null)
+
+            if (!string.IsNullOrEmpty(pagingInputDto.UserId))
             {
-                query = query.Where(u => u.AttendanceDate.Date == PagingInputDto.SearchDate.Value.Date);
+                query = query.Where(u => u.UserId == pagingInputDto.UserId);
             }
 
-            if (PagingInputDto.UserId != null)
+            // Apply sorting
+            var orderedQuery = query.OrderBy($"{pagingInputDto.OrderByField} {pagingInputDto.OrderType}");
+
+            // Apply paging
+            var pagedQuery = orderedQuery
+                .Skip((pagingInputDto.PageNumber - 1) * pagingInputDto.PageSize)
+                .Take(pagingInputDto.PageSize);
+
+            // Fetch total count for pagination
+            var totalCount = await query.CountAsync();
+
+            // Map attendance data to DTOs
+            var attendanceDtos = MapperObject.Mapper.Map<IList<AttendanceDto>>(await pagedQuery.ToListAsync());
+
+
+            // Fetch all company employees
+            var employeesList = await _userService.GetAllCompanyEmployees();
+
+            // Filter employees by name if provided
+            if (!string.IsNullOrEmpty(pagingInputDto.UserName))
             {
-                query = query.Where(u => u.UserId == PagingInputDto.UserId);
+                var filter = pagingInputDto.UserName;
+                var filters = filter.Split(" ");
+                var firstNameFilter = filters[0];
+                var lastNameFilter = filters.Length > 1 ? filters[1] : "";
+
+                employeesList = employeesList.Where(u =>
+                    u.UserName.Contains(filter) || u.Email.Contains(filter) || u.FavoriteName.Contains(filter) ||
+                    u.FirstName.Contains(filter) || u.LastName.Contains(filter) ||
+                    (u.FirstName.Contains(firstNameFilter) && (string.IsNullOrEmpty(lastNameFilter) || u.LastName.Contains(lastNameFilter))) ||
+                    (u.LastName.Contains(lastNameFilter) && (string.IsNullOrEmpty(firstNameFilter) || u.FirstName.Contains(firstNameFilter)))
+                ).ToList();
             }
-            //var dayGroupByUser = query.GroupBy(m => new { m.UserId, m.UserName, AttendanceDate = m.AttendanceDate.Date }).Select
-            //  (g => new Attendance
-            //  {
-            //      UserId = g.Key.UserId,
-            //      UserName = g.Key.UserName,
-            //      AttendanceDate = g.Key.AttendanceDate,
-            //      TotalHours = g.Sum(s => (s.CheckInTime.HasValue && s.CheckOutTime.HasValue) ? (s.CheckOutTime.Value - s.CheckInTime.Value).TotalHours : 0)
-            //  });
-
-            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<AttendanceDto>>(await page.ToListAsync());
-
-
-            //var dayGroupByUser = list.GroupBy(m => new { m.UserId,m.WeekDay, m.UserName, AttendanceDate = m.AttendanceDate.Date }).Select
-            //  (g => new AttendanceDto { 
-            //      UserId = g.Key.UserId, UserName=g.Key.UserName,
-            //      WeekDay= g.Key.WeekDay,
-            //      AttendanceDate = g.Key.AttendanceDate, 
-            //      TotalHours = g.Sum(s=> s.TotalHours) 
-            //  }).ToList();
-            var employeesList = list.Select(a => a.UserId).Distinct();
-            Dictionary<string, UserBasicInfoDto> employeeDictList = new Dictionary<string, UserBasicInfoDto>();
-            foreach (var RequestingEmployeeId in employeesList)
+
+            // Create a dictionary to store user data
+            var userDataDictionary = new Dictionary<string, UserBasicInfoDto>();
+
+            // Fetch user data for all employees
+            foreach (var employee in employeesList)
             {
-                if (RequestingEmployeeId != null)
+                var user = await _userService.GetUserWithAttachmentById(employee.Id);
+                if (user != null)
                 {
-                    var user = await _userService.GetUserWithAttachmentById(RequestingEmployeeId);
-                    if (user != null)
+                    var userDto = MapperObject.Mapper.Map<UserBasicInfoDto>(user);
+                    userDto.ProfileImage = await GetProfileImageAsync(user.UserAttachments);
+                    userDataDictionary[employee.Id] = userDto;
+                }
+            }
+
+            // Combine attendance data with user data
+            var result = new List<AttendanceDto>();
+            if (string.IsNullOrEmpty(pagingInputDto.UserId))
+            {
+                foreach (var employee in employeesList)
+                {
+                    var latestAttendance = attendanceDtos.LastOrDefault(a => a.UserId == employee.Id);
+                    if (latestAttendance != null)
+                    {
+                        latestAttendance.Employee = userDataDictionary[employee.Id];
+                    }
+                    else
                     {
-                        var entitiy = MapperObject.Mapper.Map<UserBasicInfoDto>(user);
-                        //item.Employee = entitiy;
-                        var attach = user.UserAttachments?.FirstOrDefault(a => a.AttachmentTypeId == 9);
-                        if (attach != null)
-                            using (var stream = new MemoryStream(attach.Content))
-                            {
-                                var file = new FormFile(stream, 0, stream.Length, Path.GetFileNameWithoutExtension(attach.FileName), attach.FileName)
-                                {
-                                    Headers = new HeaderDictionary(),
-                                    ContentType = attach.ContentType,
-                                };
-
-                                System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition
-                                {
-                                    FileName = file.FileName
-                                };
-                                file.ContentDisposition = cd.ToString();
-                                entitiy.ProfileImage = file;
-                                
-                            }
-                        employeeDictList.Add(RequestingEmployeeId, entitiy);
+                        latestAttendance = new AttendanceDto
+                        {
+                            UserId = employee.Id,
+                            UserName = employee.UserName,
+                            Employee = userDataDictionary[employee.Id]
+                        };
                     }
+                    result.Add(latestAttendance);
                 }
             }
-            foreach (var item in list)
+            else
             {
-                UserBasicInfoDto? employee;
-                bool success = employeeDictList.TryGetValue(item.UserId, out employee);
-               // var employee2 = employeeDictList[item.UserId];
-                if(success && employee != null) item.Employee = employee;
+                foreach (var attendance in attendanceDtos)
+                {
+                    attendance.Employee = userDataDictionary[pagingInputDto.UserId];
+                }
+                result = attendanceDtos.ToList();
             }
-            var response = new PagingResultDto<AttendanceDto>
+
+            // Return the paged result
+            return new PagingResultDto<AttendanceDto>
             {
-                Result = list ,
-                //Result = ! string.IsNullOrEmpty( PagingInputDto.UserId ) ? list : dayGroupByUser,
-                Total = total
+                Result = result,
+                Total = string.IsNullOrEmpty(pagingInputDto.UserId) ? result.Count : totalCount
             };
+        }
 
-            return response;
+        // Helper method to get profile image
+        private async Task<FormFile> GetProfileImageAsync(ICollection<AttachmentDto> attachments)
+        {
+            var profileImage = attachments?.FirstOrDefault(a => a.AttachmentTypeId == 9);
+            if (profileImage == null) return null;
+
+            using (var stream = new MemoryStream(profileImage.Content))
+            {
+                var file = new FormFile(stream, 0, stream.Length, Path.GetFileNameWithoutExtension(profileImage.FileName), profileImage.FilePath)
+                {
+                    Headers = new HeaderDictionary(),
+                    ContentType = profileImage.ContentType,
+                    ContentDisposition = new System.Net.Mime.ContentDisposition
+                    {
+                        FileName = profileImage.FileName
+                    }.ToString()
+                };
+                return file;
+            }
         }
 
         public override async Task<AttendanceDto> Create(AttendanceDto input)

+ 29 - 18
MTWorkHR.Application/Services/User/CompanyService.cs

@@ -58,15 +58,21 @@ namespace MTWorkHR.Application.Services
             if (companyId > 0)
             {
                 var entity = await _unitOfWork.Company.GetByIdWithAllChildren(companyId);
+                if(entity == null)
+                    throw new AppException(ExceptionEnum.RecordAlreadyExist);
+
                 companyResponse = MapperObject.Mapper.Map<CompanyDto>(entity);
                 var userDto = await _userService.GetById(entity.UserId);
                 companyResponse.CommercialRegAttach = userDto.CommercialRegAttach;
-                companyResponse.PassportAttach = userDto.PassportAttach;
-                companyResponse.IdAttach = userDto.IdAttach;
-                companyResponse.ExperienceCertificateAttach = userDto.ExperienceCertificateAttach;
-                companyResponse.TaxDeclarationAttach = userDto.TaxDeclarationAttach;
-                companyResponse.CompanyUser = MapperObject.Mapper.Map<CompanyUserDto>(userDto);
-                companyResponse.UserType = companyResponse.CompanyUser.UserType;
+                if (userDto != null)
+                {
+                    companyResponse.PassportAttach = userDto.PassportAttach;
+                    companyResponse.IdAttach = userDto.IdAttach;
+                    companyResponse.ExperienceCertificateAttach = userDto.ExperienceCertificateAttach;
+                    companyResponse.TaxDeclarationAttach = userDto.TaxDeclarationAttach;
+                    companyResponse.CompanyUser = MapperObject.Mapper.Map<CompanyUserDto>(userDto);
+                    companyResponse.UserType = companyResponse.CompanyUser.UserType;
+                }
             }
             return companyResponse;
         }
@@ -158,15 +164,7 @@ namespace MTWorkHR.Application.Services
 
             // var userResp = await _userService.Create(companyUser);
             var user = MapperObject.Mapper.Map<ApplicationUser>(companyUser);
-            if (user.UserType == 0)
-            {
-                user.UserType = (int)UserTypeEnum.Business;
-                var employeeRole = await _roleManager.FindByNameAsync("Business");
-                if (employeeRole != null)
-                {
-                    await _userManager.AddToRoleAsync(user, "Business");
-                }
-            }
+           
             var result = await _userManager.CreateAsync(user, companyUser.Password);
             if (!result.Succeeded)
             {
@@ -177,6 +175,15 @@ namespace MTWorkHR.Application.Services
                 }
                 throw new AppException(ExceptionEnum.RecordCreationFailed);
             }
+            if (user.UserType == 0)
+            {
+                user.UserType = (int)UserTypeEnum.Business;
+                var employeeRole = await _roleManager.FindByNameAsync("Business");
+                if (employeeRole != null)
+                {
+                    await _userManager.AddToRoleAsync(user, "Business");
+                }
+            }
             return user;
         }
 
@@ -278,15 +285,19 @@ namespace MTWorkHR.Application.Services
         public override async  Task Delete(long id)
         {
             var entity = await _unitOfWork.Company.GetByIdAsync(id);
-            await _userService.Delete(entity.UserId); // delete user first
-            await _unitOfWork.Company.DeleteAsync(entity);
+            if(entity == null)
+                throw new AppException(ExceptionEnum.RecordNotExist);
 
+            await _userService.Delete(entity.UserId); // delete user first
+            entity.IsDeleted = true;
+            await _userService.UnAssignCompanyEmployees(id);
+            await _unitOfWork.CompleteAsync();
         }
 
         public async Task Suspend(long id)
         {
             var entity = await _unitOfWork.Company.GetByIdAsync(id);
-            await _userService.Suspend(entity.UserId); // delete user first
+            await _userService.Suspend(entity.UserId); // suspend user first
             entity.IsSuspended = true;
             await _unitOfWork.CompleteAsync();
         }

+ 2 - 2
MTWorkHR.Application/Services/User/OrderAllocationService.cs

@@ -36,7 +36,7 @@ namespace MTWorkHR.Application.Services
         }
 
 
-        public override async Task<OrderAllocationDto> Create(OrderAllocationDto input)
+        public async Task<OrderAllocationDto> CreateAllEmployees(OrderAllocationDto input)
         {
             try
             {
@@ -47,7 +47,7 @@ namespace MTWorkHR.Application.Services
                 var allocations = new List<OrderAllocation>();
                 foreach (var emp in employees)
                 {
-                    if (await _unitOfWork.OrderAllocation.AllocationExists(emp.Id, orderType.Id, input.LeaveTypeId, period))
+                    if (await _unitOfWork.OrderAllocation.AllocationExists(emp.Id, orderType.Id, input.LeaveTypeId,0, period))
                         continue;
                     allocations.Add(new OrderAllocation
                     {

+ 191 - 60
MTWorkHR.Application/Services/User/OrderRequestService.cs

@@ -13,9 +13,11 @@ using MTWorkHR.Application.Services.Interfaces;
 using MTWorkHR.Core.Email;
 using MTWorkHR.Core.Entities;
 using MTWorkHR.Infrastructure.UnitOfWorks;
-using MTWorkHR.Core.Entities.User;
 using System.Linq.Dynamic.Core;
 using Microsoft.AspNetCore.Http;
+using MTWorkHR.Core.Entities.User;
+using MTWorkHR.Core.Entities.Base;
+using System.Linq;
 
 namespace MTWorkHR.Application.Services
 {
@@ -40,11 +42,66 @@ namespace MTWorkHR.Application.Services
         public override async Task<OrderRequestDto> GetById(long id)
         {
             var entity = await _unitOfWork.OrderRequest.GetByIdWithAllChildren(id);
+            if(entity == null)
+            {
+                throw new AppException(ExceptionEnum.RecordNotExist);
+            }
             var response = MapperObject.Mapper.Map<OrderRequestDto>(entity);
-            response.Employee = await _userService.GetUserWithAttachmentById(entity.RequestingEmployeeId);
+            response.Employee = await GetEmployeeDto(entity.RequestingEmployeeId);
+            return response;
+        }
+
+        public async Task<OverTimeDto> GetOverTime(long id)
+        {
+            var entity = await _unitOfWork.OrderRequest.GetByIdWithAllChildren(id);
+            if (entity == null)
+            {
+                throw new AppException(ExceptionEnum.RecordNotExist);
+            }
+            var response = MapperObject.Mapper.Map<OverTimeDto>(entity);
+            response.Employee = await GetEmployeeDto(entity.RequestingEmployeeId);
             return response;
         }
-      
+
+        public async Task<BusinessTripDto> GetBusinessTrip(long id)
+        {
+            var entity = await _unitOfWork.OrderRequest.GetByIdWithAllChildren(id);
+            if (entity == null)
+            {
+                throw new AppException(ExceptionEnum.RecordNotExist);
+            }
+            var response = MapperObject.Mapper.Map<BusinessTripDto>(entity);
+            response.Employee = await GetEmployeeDto(entity.RequestingEmployeeId);
+            return response;
+        }
+
+        public async Task<ServiceCertificateRequestDto> GetServiceCertificate(long id)
+        {
+            var entity = await _unitOfWork.OrderRequest.GetByIdWithAllChildren(id);
+            if (entity == null)
+            {
+                throw new AppException(ExceptionEnum.RecordNotExist);
+            }
+            var response = MapperObject.Mapper.Map<ServiceCertificateRequestDto>(entity);
+            response.Employee = await GetEmployeeDto(entity.RequestingEmployeeId);
+            return response;
+        }
+
+
+        private async Task<EmployeeDto> GetEmployeeDto(string employeeId)
+        {
+            var user = await _userService.GetUserById(employeeId);
+            var image = await _userService.GetProfileImage(employeeId);
+
+            return new EmployeeDto
+            {
+                Id = employeeId,
+                FirstName = user.FirstName,
+                LastName = user.LastName,
+                Email = user.Email,
+                ProfileImagePath = image
+            };
+        }
         public  async Task<PagingResultDto<OrderRequestDto>> GetAll(OrderPagingInputDto PagingInputDto)
         {
             var res = await _unitOfWork.OrderRequest.GetAllWithChildrenAsync();
@@ -65,7 +122,8 @@ namespace MTWorkHR.Application.Services
             }
             if (PagingInputDto.SearchDate != null)
             {
-                query = query.Where(u => u.StartDate.Date <= PagingInputDto.SearchDate.Value.Date && u.EndDate!.Value.Date >= PagingInputDto.SearchDate.Value.Date) ;
+               // query = query.Where(u => u.StartDate.Date <= PagingInputDto.SearchDate.Value.Date && u.EndDate!.Value.Date >= PagingInputDto.SearchDate.Value.Date) ;
+                query = query.Where(u => u.CreateDate.Date == PagingInputDto.SearchDate.Value.Date) ;
             }
             if (PagingInputDto.OrderTypeId != null)
             {
@@ -79,71 +137,128 @@ namespace MTWorkHR.Application.Services
             {
                 query = query.Where(u => (long?)u.OrderStatus == PagingInputDto.StatusId);
             }
+          
+
+
+
+            // UserName filter (join with users table)
+            if (!string.IsNullOrEmpty(PagingInputDto.UserName))
+            {
+                var filter = PagingInputDto.UserName.ToLower();
+                query = query.Join(
+                    _userManager.Users,
+                    order => order.RequestingEmployeeId,
+                    user => user.Id,
+                    (order, user) => new { Order = order, User = user }
+                )
+                .Where(joined =>
+                    (joined.User.FirstName + " " + joined.User.LastName).ToLower().Contains(filter)
+                //  ||joined.User.Email.ToLower().Contains(filter)
+                )
+                .Select(joined => joined.Order);
+            }
+            var total = await query.CountAsync();
             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 = await MapToOrderRequestDtos(page);
+
+            var response = new PagingResultDto<OrderRequestDto>
+            {
+                Result = list,
+                Total = total
+            };
+
+            return response;
+        }
+
 
-            var list = MapperObject.Mapper
-                .Map<IList<OrderRequestDto>>(await page.ToListAsync());
-            foreach (var item in list)
+        private async Task<List<OrderRequestDto>> MapToOrderRequestDtos(IQueryable<OrderRequest> page)
+        {
+            var list = MapperObject.Mapper.Map<List<OrderRequestDto>>(await page.ToListAsync());
+
+            // Batch load user data to improve performance
+            var employeeIds = list.Where(x => x.RequestingEmployeeId != null)
+                                .Select(x => x.RequestingEmployeeId)
+                                .Distinct()
+                                .ToList();
+
+            if (employeeIds.Any())
             {
-                if (item.RequestingEmployeeId != null)
+                var users = await _userService.GetUsersWithAttachmentsByIds(employeeIds);
+                if (users != null)
                 {
-                    var user = await _userService.GetUserWithAttachmentById(item.RequestingEmployeeId);
-                    if (user != null)
+                    var userLookup = users.ToDictionary(u => u.Id, u => u);
+
+                    foreach (var item in list)
                     {
-                        item.Employee = user;
-                        var attach = user.UserAttachments?.FirstOrDefault(a => a.AttachmentTypeId == 9);
-                        if(attach != null)
-                        using (var stream = new MemoryStream(attach.Content))
+                        if (item.RequestingEmployeeId != null && userLookup.TryGetValue(item.RequestingEmployeeId, out var user))
                         {
-                            var file = new FormFile(stream, 0, stream.Length, Path.GetFileNameWithoutExtension(attach.FileName), attach.FileName)
-                            {
-                                Headers = new HeaderDictionary(),
-                                ContentType = attach.ContentType,
-                            };
-
-                            System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition
+                            item.Employee = new EmployeeDto
                             {
-                                FileName = file.FileName
+                                Id = user.Id,
+                                FirstName = user.FirstName,
+                                LastName = user.LastName,
+                                Email = user.Email,
+                                Position = user.Position ?? user.JobTitleName,
+                                EmployeeName = $"{user.FirstName} {user.LastName}",
+                                ProfileImagePath = user.UserAttachments?.FirstOrDefault(a => a.AttachmentTypeId == 9)?.FilePath
                             };
-                            file.ContentDisposition = cd.ToString();
-                            item.Employee.ProfileImage = file;
                         }
                     }
                 }
             }
-            var response = new PagingResultDto<OrderRequestDto>
-            {
-                Result = list,
-                Total = total
-            };
 
-            return response;
+            return list;
         }
         public override async Task<OrderRequestDto> Create(OrderRequestDto input)
         {
             var period = DateTime.Now.Year;
-            if(string.IsNullOrEmpty( input.RequestingEmployeeId))
+            input.LeaveTypeId = (input.LeaveTypeId != null && input.LeaveTypeId > 0 ) ? input.LeaveTypeId : null;
+            input.OrderStatus = (input.OrderStatus != null && input.OrderStatus > 0 ) ? input.OrderStatus : ApprovalStatusEnum.Pending;
+            if (string.IsNullOrEmpty( input.RequestingEmployeeId))
             {
                 input.RequestingEmployeeId = _globalInfo.UserId;
             }
-            var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(input.RequestingEmployeeId, input.OrderTypeId, input.LeaveTypeId, period);
-
-            if (allocation is null)
+            if (input is BusinessTripDto)
+            {
+                input.OrderTypeId = 3;
+            }
+            else if (input is OverTimeDto)
             {
-                throw new AppException(ExceptionEnum.NoVacationBalance, "You do not have any allocations for this leave type.");
+                input.OrderTypeId = 2;
             }
-            else
+            else if (input is ServiceCertificateRequestDto)
             {
-                int daysRequested = (int)(input.EndDate - input.StartDate).TotalDays;
-                if (daysRequested > allocation.NumberOfDays)
+                input.OrderTypeId = 5;
+            }
+            var contract = await _unitOfWork.Contract.GetLatestActiveContract(input.RequestingEmployeeId);
+            if(contract!= null)
+                input.ContractId = contract.Id;
+            if (input.OrderTypeId == 1 &&  input.LeaveTypeId == 1) // Annual vacation in contract
+            {
+                if (contract != null)
                 {
-                    throw new AppException(ExceptionEnum.NoVacationBalance, "You do not have enough days for this request");
+                    var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(input.RequestingEmployeeId, input.OrderTypeId, input.LeaveTypeId, contract.Id, period);
+
+                    if (allocation is null)
+                    {
+                        throw new AppException(ExceptionEnum.NoVacationBalance, "You do not have any allocations for this leave type.");
+                    }
+                    else
+                    {
+                        int sub = (int)(input.EndDate.Date - input.StartDate.Date).TotalDays;
+                        int daysRequested = input.TotalDays > 0 ? (int)input.TotalDays : sub;
+                        if (daysRequested > allocation.NumberOfDays)
+                        {
+                            throw new AppException(ExceptionEnum.NoVacationBalance, "You do not have enough days for this request");
+                        }
+                    }
                 }
+                
             }
+          
             var orderRequest = MapperObject.Mapper.Map<OrderRequest>(input);
             orderRequest = await _unitOfWork.OrderRequest.AddAsync(orderRequest);
             await _unitOfWork.CompleteAsync();
@@ -168,30 +283,33 @@ namespace MTWorkHR.Application.Services
             {
                 //// Log or handle error, but don't throw...
             }
-            var response = MapperObject.Mapper.Map<OrderRequestDto>(orderRequest);
+            var res = await _unitOfWork.OrderRequest.GetByIdWithTypes(orderRequest.Id);
+            
+            var response = MapperObject.Mapper.Map<OrderRequestDto>(res);
             if (response.RequestingEmployeeId != null)
             {
                 var user = await _userService.GetUserWithAttachmentById(response.RequestingEmployeeId);
                 if (user != null)
                 {
-                    response.Employee = user;
+                    response.Employee = new EmployeeDto { Id = response.RequestingEmployeeId, FirstName = user.FirstName, LastName = user.LastName, Email = user.Email };
                     var attach = user.UserAttachments?.FirstOrDefault(a => a.AttachmentTypeId == 9);
-                    if (attach != null)
-                        using (var stream = new MemoryStream(attach.Content))
-                        {
-                            var file = new FormFile(stream, 0, stream.Length, Path.GetFileNameWithoutExtension(attach.FileName), attach.FileName)
-                            {
-                                Headers = new HeaderDictionary(),
-                                ContentType = attach.ContentType,
-                            };
+                    response.Employee.ProfileImagePath = attach?.FilePath;
+                    //if (attach != null)
+                    //    using (var stream = new MemoryStream(attach?.Content))
+                    //    {
+                    //        var file = new FormFile(stream, 0, stream.Length, Path.GetFileNameWithoutExtension(attach.FileName), attach.FileName)
+                    //        {
+                    //            Headers = new HeaderDictionary(),
+                    //            ContentType = attach?.ContentType,
+                    //        };
 
-                            System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition
-                            {
-                                FileName = file.FileName
-                            };
-                            file.ContentDisposition = cd.ToString();
-                            response.Employee.ProfileImage = file;
-                        }
+                    //        System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition
+                    //        {
+                    //            FileName = file.FileName
+                    //        };
+                    //        file.ContentDisposition = cd.ToString();
+                    //        response.Employee.ProfileImage = file;
+                    //    }
                 }
             }
             return response;
@@ -201,12 +319,25 @@ namespace MTWorkHR.Application.Services
         public async Task<OrderRequestDto> ChangeStatus(long id, int statusId )
         {
             var orderRequest = await _unitOfWork.OrderRequest.GetByIdAsync(id);
+            if (orderRequest == null)
+            {
+                throw new AppException(ExceptionEnum.RecordNotExist);
+            }
             orderRequest.OrderStatus = (ApprovalStatusEnum)statusId;
             if (orderRequest.OrderStatus == ApprovalStatusEnum.Approved)
             {
-                var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(orderRequest.RequestingEmployeeId, orderRequest.OrderTypeId, orderRequest.LeaveTypeId, DateTime.Now.Year);
-                int daysRequested = !orderRequest.EndDate.HasValue ? 1 : (int)(orderRequest.EndDate.Value - orderRequest.StartDate).TotalDays;
-                allocation.NumberOfDays -= daysRequested;
+                long? contractId = orderRequest.ContractId;
+                if (contractId == null || contractId == 0)
+                { 
+                    var contract = await _unitOfWork.Contract.GetLatestActiveContract(orderRequest.RequestingEmployeeId);
+                    contractId = contract.Id;
+                }
+                var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(orderRequest.RequestingEmployeeId, orderRequest.OrderTypeId, orderRequest.LeaveTypeId, contractId.Value, DateTime.Now.Year);
+                if (allocation != null)
+                {
+                    int daysRequested = !orderRequest.EndDate.HasValue ? 1 : (int)(orderRequest.EndDate.Value - orderRequest.StartDate).TotalDays;
+                    allocation.NumberOfDays -= daysRequested;
+                }
             }
             await _unitOfWork.CompleteAsync();
             var response = MapperObject.Mapper.Map<OrderRequestDto>(orderRequest);

+ 10 - 0
MTWorkHR.Application/Services/User/TeamService.cs

@@ -15,6 +15,7 @@ using MTWorkHR.Core.Entities;
 using MTWorkHR.Infrastructure.UnitOfWorks;
 using System.Linq;
 using System.Linq.Dynamic.Core;
+using MTWorkHR.Core.Entities.Base;
 
 namespace MTWorkHR.Application.Services
 {
@@ -159,5 +160,14 @@ namespace MTWorkHR.Application.Services
             return name;
         }
 
+        public async Task<IList<TeamDto>> GetTeamListForUser(string userId)
+        {
+            var teamsList = await _unitOfWork.TeamUser.GetUserTeams(userId);
+            var result = teamsList.Item1;
+
+            var response = Mapper.MapperObject.Mapper.Map<IList<TeamDto>>(result);
+            return response;
+        }
+
     }
 }

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

@@ -24,6 +24,9 @@ using Countries.NET.Database;
 using Microsoft.AspNetCore.Http;
 using System.Collections;
 using System.Linq;
+using System.ComponentModel.Design;
+using static iText.StyledXmlParser.Jsoup.Select.Evaluator;
+using static iText.IO.Util.IntHashtable;
 
 namespace MTWorkHR.Application.Services
 {
@@ -128,12 +131,14 @@ namespace MTWorkHR.Application.Services
                                 break;
                             case 9:
                                 response.ProfileImage = file;
+                                response.ProfileImagePath = attach.FilePath;
                                 break;
                         }
                         attach.Content = new byte[0];
                     }
                    
                 }
+            
             var attendance = await _unitOfWork.Attendance.GetAttendanceByUserId(id, DateTime.Now.Date);
             response.IsCheckedIn = attendance != null && attendance.CheckInTime.HasValue;
             response.IsCheckedOut = attendance != null && attendance.CheckOutTime.HasValue;
@@ -155,16 +160,35 @@ namespace MTWorkHR.Application.Services
         }
         public async Task<UserDto> GetUserWithAttachmentById(string id)
         {
-            var entity = await _userManager.Users.Include(u=> u.UserAttachments)
+            var entity = await _userManager.Users.Include(u=> u.UserAttachments).Include(u=> u.JobTitle)
                 .FirstOrDefaultAsync(x => x.Id == id);
             var response = MapperObject.Mapper.Map<UserDto>(entity);
 
             return response;
         }
 
+        public async Task<List<UserDto>> GetUsersWithAttachmentsByIds(List<string> ids)
+        {
+            // Validate input
+            if (ids == null || !ids.Any())
+            {
+                return new List<UserDto>();
+            }
+
+            // Query users with related data
+            var users = await _userManager.Users
+                .AsNoTracking() // Optional: Use if read-only data is sufficient
+                .Include(u => u.UserAttachments)
+                .Include(u => u.JobTitle)
+                .Where(u => ids.Contains(u.Id))
+                .ToListAsync();
+            var response = MapperObject.Mapper.Map<List<UserDto>>(users);
+            return response;
+        }
+
         public async Task<string> GetProfileImage(string userId)
         {
-            string imagePath = null;
+            string imagePath = "";
             var user = await _userManager.Users.Include(u => u.UserAttachments)
                 .FirstOrDefaultAsync(x => x.Id == userId);
             if (user != null)
@@ -278,33 +302,74 @@ namespace MTWorkHR.Application.Services
 
         public async Task<List<UserAllDto>> GetAllCompanyEmployees()
         {
-            var employees = await _userManager.GetUsersInRoleAsync("Employee");
-            var res = employees.Where(e => e.CompanyId == _globalInfo.CompanyId).ToList();
-            var response = MapperObject.Mapper.Map<List<UserAllDto>>(res);
+            var AllEmployees = await _userManager.GetUsersInRoleAsync("Employee");
+            var AllContractors = await _userManager.GetUsersInRoleAsync("Contractor");
+
+            var employees = AllEmployees.Where(e => e.CompanyId == _globalInfo.CompanyId).ToList();
+            var contractors = AllContractors.Where(e => e.CompanyId == _globalInfo.CompanyId).ToList();
+
+            var allUsers = employees.Union(contractors);
+            var response = MapperObject.Mapper.Map<List<UserAllDto>>(allUsers);
 
             return response;
         }
+        public async Task<bool> UnAssignCompanyEmployees(long companyId)
+        {
+            try
+            {
+                var AllEmployees = await _userManager.GetUsersInRoleAsync("Employee");
+                var AllContractors = await _userManager.GetUsersInRoleAsync("Contractor");
+                var employees = AllEmployees.Where(e => e.CompanyId == companyId).ToList();
+                var contractors = AllContractors.Where(e => e.CompanyId == companyId).ToList();
+                foreach (var emp in employees.Union(contractors))
+                {
+                    emp.CompanyId = null;
+                    await _userManager.UpdateAsync(emp);
 
+                }
+                await _unitOfWork.CompleteAsync();
+                return true;
+            }
+            catch(Exception ex) 
+            { return false; }
+        }
         public async Task Delete(string id)
         {
             var user = await _userManager.FindByIdAsync(id);
-            if (user != null)
+            if (user == null)
+                throw new AppException(ExceptionEnum.RecordNotExist);
+            if (!user.IsDeleted )
             {
                 user.IsDeleted = true;
 
                 await _userManager.UpdateAsync(user);
+                await _unitOfWork.CompleteAsync();
             }
         }
         public async Task Suspend(string id)
         {
             var user = await _userManager.FindByIdAsync(id);
-            if (user != null)
+            if (user == null)
+                throw new AppException(ExceptionEnum.RecordNotExist);
+            if (!user.IsStopped)
             {
                 user.IsStopped = true;
-
                 await _userManager.UpdateAsync(user);
+                await _unitOfWork.CompleteAsync();
             }
         }
+        public async Task ActiveUser(string userId)
+        {
+            var entity = await _userManager.Users.FirstOrDefaultAsync(x => x.Id == userId);
+            if (entity == null)
+                throw new AppException(ExceptionEnum.RecordNotExist);
+            entity.IsStopped = false;
+            entity.AccessFailedCount = 0;
+            entity.LockoutEnabled = false;
+            entity.LockoutEnd = null;
+            await _userManager.UpdateAsync(entity);
+            await _unitOfWork.CompleteAsync();
+        }
 
 
         public async Task<UserDto> Create(UserDto input)
@@ -322,6 +387,7 @@ namespace MTWorkHR.Application.Services
                 throw new AppException(ExceptionEnum.RecordNameAlreadyExist);
             //loop for given list of attachment, and move each file from Temp path to Actual path
             //  _fileService.UploadFiles(files);
+            input.CountryId = input.CountryId == null || input.CountryId == 0 ? input.UserAddress?.CountryId : input.CountryId;
             if (input.UserAttachments == null )
                 input.UserAttachments = new List<AttachmentDto>();
             if (input.ProfileImage != null)
@@ -685,18 +751,6 @@ namespace MTWorkHR.Application.Services
                 await _unitOfWork.CompleteAsync();
             }
         }
-        public async Task ActiveUser(string userId)
-        {
-            var entity = await _userManager.Users.FirstOrDefaultAsync(x => x.Id == userId);
-            if (entity == null)
-                throw new AppException(ExceptionEnum.UserNotExist);
-
-            entity.IsStopped = false;
-            entity.AccessFailedCount = 0;
-            entity.LockoutEnabled = false;
-            entity.LockoutEnd = null;
-            await _unitOfWork.CompleteAsync();
-
-        }
+      
     }
 }

+ 24 - 0
MTWorkHR.Core/Entities/Attendance/BusinessTripAttachment.cs

@@ -0,0 +1,24 @@
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using MTWorkHR.Core.Entities.User;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class BusinessTripAttachment : AuditEntity
+    {
+        public long BusinessTripExpensesId { get; set; }
+
+        [ForeignKey("BusinessTripExpensesId ")]
+        public BusinessTripExpenses BusinessTripExpenses { get; set; }
+
+        [MaxLength(250)]
+        public string? FileName { get; set; }
+
+        [MaxLength(250)]
+        public string? OriginalName { get; set; }
+
+        public string? FilePath { get; set; }
+        public string? ContentType { get; set; }
+    }
+}

+ 27 - 0
MTWorkHR.Core/Entities/Attendance/BusinessTripExpences.cs

@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Entities.User;
+
+namespace MTWorkHR.Core.Entities
+{ 
+    public class BusinessTripExpenses : Entity
+    {
+        public long? OrderRequestId { get; set; }
+
+        [ForeignKey("OrderRequestId")]
+        public OrderRequest OrderRequest { get; set; }
+        public decimal? TicketCost{ get; set; }
+        public decimal? TransportationCost { get; set; }
+        public decimal? AccommodationCost { get; set; }
+        public decimal? OtherCost { get; set; }
+        public decimal? TotalCost { get; set; }
+        public List<BusinessTripAttachment> Attachments { get; set; } = new List<BusinessTripAttachment>();
+
+    }
+}

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

@@ -12,6 +12,8 @@ namespace MTWorkHR.Core.Entities
     public class OrderAllocation : AuditEntity, IHaveCompany
     {
         public int NumberOfDays { get; set; }
+        public long ContractId { get; set; }
+
         [ForeignKey("OrderTypeId")]
         public OrderType OrderType { get; set; }
         public long OrderTypeId { get; set; }

+ 24 - 0
MTWorkHR.Core/Entities/Attendance/OrderAttachment.cs

@@ -0,0 +1,24 @@
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using MTWorkHR.Core.Entities.User;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class OrderAttachment : AuditEntity
+    {
+        public long OrderRequestId { get; set; }
+
+        [ForeignKey("OrderRequestId")]
+        public OrderRequest OrderRequest { get; set; }
+
+        [MaxLength(250)]
+        public string? FileName { get; set; }
+
+        [MaxLength(250)]
+        public string? OriginalName { get; set; }
+
+        public string? FilePath { get; set; }
+        public string? ContentType { get; set; }
+    }
+}

+ 15 - 6
MTWorkHR.Core/Entities/Attendance/OrderRequest.cs

@@ -1,4 +1,5 @@
-using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
 using MTWorkHR.Core.Global;
 using System;
 using System.Collections.Generic;
@@ -23,15 +24,23 @@ namespace MTWorkHR.Core.Entities.User
         public long? LeaveTypeId { get; set; }
         [Filter]
         public string? RequestComments { get; set; }
+        [Filter]
+        public string? RequestTitle { get; set; }
         public ApprovalStatusEnum? OrderStatus { get; set; }
         [Filter]
         public string RequestingEmployeeId { get; set; }
-        public int? CountryId{ get; set; }
-        public int? CityId { get; set; }
-        public string? StartTime { get; set; }
-        public string? EndTime { get; set; }
+     
+        public long CompanyId { get; set ; }
+        public long? ContractId { get; set ; }
+        public decimal? CourseNumberOfHours { get; set; }
+        public decimal? CourseCost { get; set; }
+        public decimal? TotalDays { get; set; }
+
+        public List<OrderAttachment>? OrderAttachments { get; set; }
+        public List<OverTimeDay>? OverTimeDays { get; set; }
 
-        public long CompanyId { get ; set ; }
+        public BusinessTripExpenses? BusinessTripExpenses { get; set; }
+        public ServiceCertificate? ServiceCertificate { get; set; }
 
     }
 }

+ 26 - 0
MTWorkHR.Core/Entities/Attendance/OverTimeDay.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Entities.User;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class OverTimeDay : Entity
+    {
+        public long? OrderRequestId { get; set; }
+
+        [ForeignKey("OrderRequestId")]
+        public OrderRequest OrderRequest { get; set; }
+        public DateTime? OverTimeDate{ get; set; }
+        public string? StartTime { get; set; }
+        public string? EndTime { get; set; }
+        public decimal? TotalHours { get; set; }
+        public string? OverTimeDetail { get; set; }
+        public OverTimeDayAttachment? OverTimeAttachment { get; set; }
+    }
+}

+ 24 - 0
MTWorkHR.Core/Entities/Attendance/OverTimeDayAttachment.cs

@@ -0,0 +1,24 @@
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using MTWorkHR.Core.Entities.User;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class OverTimeDayAttachment : AuditEntity
+    {
+        public long OverTimeDayId { get; set; }
+
+        [ForeignKey("OverTimeDayId")]
+        public OverTimeDay OverTimeDay { get; set; }
+
+        [MaxLength(250)]
+        public string? FileName { get; set; }
+
+        [MaxLength(250)]
+        public string? OriginalName { get; set; }
+
+        public string? FilePath { get; set; }
+        public string? ContentType { get; set; }
+    }
+}

+ 25 - 0
MTWorkHR.Core/Entities/Attendance/ServiceCertificate.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Entities.User;
+
+namespace MTWorkHR.Core.Entities
+{ 
+    public class ServiceCertificate : Entity
+    {
+        [ForeignKey("OrderRequestId")]
+        public OrderRequest OrderRequest { get; set; }
+        public string? ToWhom { get; set; }
+        public string? Name { get; set; }
+        public string? Salary { get; set; }
+        public DateTime? JoiningDate { get; set; }
+        public DateTime? ToDate { get; set; }
+        public string? Position { get; set; }
+
+    }
+}

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

@@ -45,7 +45,7 @@ namespace MTWorkHR.Core.Entities
 
 
         //------Working time---------------
-        public List<ContractWorkingDay>? WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
+        public string? WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
         public int? WorkingHours { get; set; } //	يومي/ اسبوعي  
         public int? WorkingHoursNum { get; set; } // عدد الساعات
         public DateTime? StartDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
@@ -74,6 +74,7 @@ namespace MTWorkHR.Core.Entities
         public DateTime? LastPatchDateFrom { get; set; } //
         public DateTime? LastPatchDateTo { get; set; } // 
         public decimal? LastPatchAmount { get; set; }
+        public string? FilePath { get; set; }// on cloud
 
 
         //  public decimal? GrossAnnualBaseSalary { get; set; }

+ 90 - 0
MTWorkHR.Core/Entities/Contract/ContractDetail.cs

@@ -0,0 +1,90 @@
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Global;
+
+
+namespace MTWorkHR.Core.Entities
+{
+    public class ContractDetail
+    {
+        public ContractTypeEnum ContractTypeId { get; set; }
+        public ContractStatusEnum ContractStatusId { get; set; }
+        //--------Company data-------
+        public string CompanyName { get; set; }
+        public string CompanyCR { get; set; }
+        public string CompanyEmail { get; set; }
+        public string CompanyAddress { get; set; }
+        public string CompanyPhone { get; set; }
+        //--------Company Representative-------
+        public string CompanyRepresentativeName { get; set; }
+        public string CompanyRepresentativePassport { get; set; }
+        public string CompanyRepresentativePhone { get; set; }
+        public string CompanyRepresentativeEmail { get; set; }
+        public string CompanyRepresentativePosition { get; set; }
+        //--------Employee Data------------------------------------
+        public string UserId { get; set; }
+        public string? EmployeeName { get; set; }
+        public string? EmployeeEmail { get; set; }
+        public string? EmployeePassport{ get; set; }
+        public string? EmployeePhone { get; set; }
+        public string? EmployeeUniversity { get; set; }
+        public DateTime? EmployeeDateOfBirth { get; set; }
+        //-----------------------------
+        public string? EmployeeJobName { get; set; }
+        public string? AcademicQualification { get; set; }
+        public string? Specialization { get; set; }
+        public string WorkCountry { get; set; }
+        public string WorkState { get; set; }
+        //-------------------Scope of work-----------
+        public string? JobTitleName { get; set; }
+        public string? JobDescription { get; set; }
+        [MaxLength(150)]
+        public string? JobNumber { get; set; } //ثابت و مأخوذ من المنصة
+        //----------------Contract data -------------------------
+        public DateTime? StartDate { get; set; }
+        public DateTime? EndDate { get; set; }
+
+        public string? ContractDuration { get; set; } //:  اختيار: شهري – ربعي – نصف سنوي – 3 ارباع – سنوي
+        public string? TypeOfWork { get; set; } //: :   اختيار: عقد بدوام كامل -  عقد دوام جزئي   
+        public int? VacationDays { get; set; } //اختيار: بدون – سنويا (رقم)
+        public int? TrialPeriod { get; set; } // تجربة (ادخال: تلقائياً كل ربع سنوي أسبوع تلقائياً) آخر: تعديل
+        public string? WhoCanTerminateContractInTrial { get; set; } //اختيار   الجميع – صاحب العمل – الموظف
+        public string? WhoCanTerminateContract { get; set; }
+        public int? NoticePeriodBeforeTermination { get; set; } //اختيار: بدون – تحديد (ادخال: تلقائياً مدة 10 أيام قبل انتهاء الاستحقاق) آخر: تعديل
+
+
+        //------Working time---------------
+        public string? WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
+        public string? WorkingHours { get; set; } //	يومي/ اسبوعي  
+        public int? WorkingHoursNum { get; set; } // عدد الساعات
+        public DateTime? StartDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
+        public DateTime? EndDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
+
+        //----------Salary-----------------
+        [MaxLength(50)]
+        public string? Currency { get; set; }
+        public decimal? Salary { get; set; }
+        public string? BillingCycle { get; set; }// 2 fortnightly, 4 Monthly
+        //------------------------Fixed Pay----------------
+        public DateTime? FirstPatchDateFrom { get; set; }
+        public DateTime? FirstPatchDateTo { get; set; } //
+        public decimal? FirstPatchAmount { get; set; }
+
+        public DateTime? LastPatchDateFrom { get; set; } //
+        public DateTime? LastPatchDateTo { get; set; } // 
+        public decimal? LastPatchAmount { get; set; }
+        public string? Teams { get; set; }
+        public string? Vacations { get; set; }
+
+
+        //---------Allowances----------------------
+        public bool IncludesAllAllowances { get; set; }
+        public List<ContractAllowance>? FixedAllowances { get; set; }
+
+        //-------------------------------
+        public List<ContractTask>? ContractTasks { get; set; }
+        public List<ProjectStage>? ProjectStages { get; set; }
+    }
+}

+ 24 - 0
MTWorkHR.Core/Entities/Payment/Invoice.cs

@@ -0,0 +1,24 @@
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class Invoice : FullAuditEntity
+    {
+
+        public string? InvoiceNumber { get; set; }
+        public DateTime? InvoiceDate{ get; set; }
+        public decimal? Amount{ get; set; }
+        public int? Status{ get; set; }
+        public int? ContractId{ get; set; }
+        public string? UserId { get; set; }
+
+    }
+}

MTWorkHR.Core/Entities/Payment/SubscriptionConfigurationDto.cs → MTWorkHR.Core/Entities/Payment/SubscriptionConfiguration.cs


+ 2 - 2
MTWorkHR.Core/Global/Enum/ContractTypeEnum.cs

@@ -10,7 +10,7 @@ namespace MTWorkHR.Core.Global
     {
         EmployeeContract = 1,
         FixedPayContract = 2,
-        PerProjectContract = 3,
-        PerTaskContract = 4,
+        PerTaskContract = 3,
+        PerProjectContract = 4,
     }
 }

+ 4 - 1
MTWorkHR.Core/Global/Enum/WorkingHours.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Runtime.Serialization;
 using System.Text;
 using System.Threading.Tasks;
 
@@ -8,7 +9,9 @@ namespace MTWorkHR.Core.Global
 {
     public enum WorkingHours
     {
-        Daily,
+        [EnumMember(Value = "1")]
+        Daily ,
+        [EnumMember(Value = "2")]
         Weekly,
     }
 }

+ 1 - 0
MTWorkHR.Core/IDto/IAttendancePagingInputDto.cs

@@ -6,6 +6,7 @@ namespace MTWorkHR.Core.IDto
     {
         public DateTime? SearchDate { get; set; }
         public string? UserId { get; set; }
+        public string? UserName { get; set; }
 
     }
 }

+ 1 - 0
MTWorkHR.Core/IDto/IContractPagingInputDto.cs

@@ -6,6 +6,7 @@ namespace MTWorkHR.Core.IDto
     {
         public long? ContractStatusId { get; set; }
         public long? ContractTypeId { get; set; }
+        public string? UserName { get; set; }
 
     }
 }

+ 4 - 1
MTWorkHR.Core/IDto/IOrderPagingInputDto.cs

@@ -5,7 +5,10 @@ namespace MTWorkHR.Core.IDto
     public interface IOrderPagingInputDto:IPagingInputDto
     {
         public DateTime? SearchDate { get; set; }
+        public string? UserName { get; set; }
         public string? AssignedUserId { get; set; }
-
+        public long? OrderTypeId { get; set; }
+        public long? LeaveTypeId { get; set; }
+        public long? StatusId { get; set; }
     }
 }

+ 1 - 0
MTWorkHR.Core/IRepositories/Contract/IContractRepository.cs

@@ -11,6 +11,7 @@ namespace MTWorkHR.Core.IRepositories
     public interface IContractRepository : IRepository<Contract>
     {
         Task<Contract> GetByIdWithAllChildren(long id);
+        Task<Contract> GetLatestActiveContract(string userId);
         Task<Tuple<IQueryable<Contract>, int>> GetAllWithChildrenAsync();
     }
 }

+ 15 - 0
MTWorkHR.Core/IRepositories/Payment/IInvoiceRepository.cs

@@ -0,0 +1,15 @@
+using MTWorkHR.Core.Entities;
+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 IInvoiceRepository : IRepository<Invoice>
+    {
+        Task<Tuple<IQueryable<Invoice>, int>> GetAllUserInvoices(long contractId);
+    }
+}

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

@@ -10,9 +10,9 @@ namespace MTWorkHR.Core.IRepositories
 {
     public interface IOrderAllocationRepository : IRepository<OrderAllocation>
     {
-        Task<bool> AllocationExists(string userId, long orderTypeId, long? leaveTypeId, int period);
+        Task<bool> AllocationExists(string userId, long orderTypeId, long? leaveTypeId, long contractId, int period);
         Task<OrderAllocation> GetByIdWithAllChildren(long id);
-        Task<OrderAllocation> GetUserAllocations(string userId, long orderTypeId, long? leaveTypeId, int period);
+        Task<OrderAllocation> GetUserAllocations(string userId, long orderTypeId, long? leaveTypeId, long contractId, int period);
 
     }
 }

+ 2 - 0
MTWorkHR.Core/IRepositories/User/IOrderRequestRepository.cs

@@ -12,7 +12,9 @@ namespace MTWorkHR.Core.IRepositories
     public interface IOrderRequestRepository : IRepository<OrderRequest>
     {
        Task<OrderRequest> GetByIdWithAllChildren(long id);
+        Task<OrderRequest> GetByIdWithTypes(long id);
         Task<Tuple<IQueryable<OrderRequest>, int>> GetAllWithChildrenAsync();
+        Task<Tuple<IQueryable<OrderRequest>, int>> GetAllUserOrdersAsync(string userId, long contractId);
 
     }
 }

+ 3 - 0
MTWorkHR.Core/IRepositories/User/ITeamUserRepository.cs

@@ -17,5 +17,8 @@ namespace MTWorkHR.Core.IRepositories
         Task<IList<TeamUser>> AddRangeAsync(IList<TeamUser> entity);
         Task DeleteAsync(TeamUser entity);
         Task DeleteAsync(IEnumerable<TeamUser> entities);
+
+        Task<Tuple<IQueryable<TeamUser>, int>> GetAllWithChildrenAsync();
+        Task<Tuple<IQueryable<Team>, int>> GetUserTeams(string userId);
     }
 }

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

@@ -42,6 +42,7 @@ namespace MTWorkHR.Core.UnitOfWork
 
         IHubConnectionRepository HubConnection { get; }
         ISubscriptionConfigurationRepository SubscriptionConfiguration { get; }
+        IInvoiceRepository Invoice { get; }
         Task<int> CompleteAsync();
 
         void BeginTran();

+ 26 - 1
MTWorkHR.Infrastructure/Configurations/AttachmentTypeConfiguration.cs

@@ -75,7 +75,32 @@ namespace MTWorkHR.Infrastructure.Configurations
                     Id = 9,
                     NameEn = "Image",
                     NameAr = "الصورة"
-                }
+                },
+                 new AttachmentType
+                 {
+                     Id = 10,
+                     NameEn = "Ticket Cost",
+                     NameAr = "تكلفة التذكرة"
+                 }
+                 ,
+                  new AttachmentType
+                  {
+                      Id = 11,
+                      NameEn = "Transportation Cost",
+                      NameAr = "تكلفة المواصلات"
+                  }
+                  , new AttachmentType
+                  {
+                      Id = 12,
+                      NameEn = "Accommodation Cost",
+                      NameAr = "تكلفة الاقامة"
+                  },
+                   new AttachmentType
+                   {
+                       Id = 13,
+                       NameEn = "Other",
+                       NameAr = "اخرى"
+                   }
                ) ;
         }
     }

+ 13 - 5
MTWorkHR.Infrastructure/Configurations/LeaveTypeConfiguration.cs

@@ -24,28 +24,28 @@ namespace MTWorkHR.Infrastructure.Configurations
                     Id = 1,
                     NameEn = "Annual Leave",
                     NameAr = "أجازة سنوية",
-                    DefaultDays = 21
+                    DefaultDays = 30
                 },
                  new LeaveType
                  {
                      Id = 2,
                      NameEn = "Sick Leave",
                      NameAr = "أجازة مرضية",
-                     DefaultDays = 15
+                     DefaultDays = 90
                  },
                 new LeaveType
                 {
                     Id = 3,
                     NameEn = "Marriage Leave",
                     NameAr = "أجازة زواج",
-                    DefaultDays = 20
+                    DefaultDays = 5
                 },
                 new LeaveType
                 {
                     Id = 4,
-                    NameEn = "Paternity leave", //(after closed from employee / manager)
+                    NameEn = "Maternity leave", //(after closed from employee / manager)
                     NameAr = "أجازة وضع",
-                    DefaultDays = 10
+                    DefaultDays = 20
 
                 },
                 new LeaveType
@@ -54,7 +54,15 @@ namespace MTWorkHR.Infrastructure.Configurations
                     NameEn = "Emergency leave",
                     NameAr = "أجازة طارئة",
                     DefaultDays = 10
+                },
+                new LeaveType
+                {
+                    Id = 6,
+                    NameEn = "Death of a relative",
+                    NameAr = "وفاة",
+                    DefaultDays = 3
                 }
+                
                ) ;
         }
     }

+ 20 - 10
MTWorkHR.Infrastructure/Configurations/OrderTypeConfiguration.cs

@@ -26,23 +26,17 @@ namespace MTWorkHR.Infrastructure.Configurations
                     NameAr = "إذن",
                     DefaultDays = 2
                 },
-                 new OrderType
-                 {
-                     Id = 2,
-                     NameEn = "Medical",
-                     NameAr = "طبية",
-                     DefaultDays = 15
-                 },
+                 
                 new OrderType
                 {
-                    Id = 3,
+                    Id = 2,
                     NameEn = "Overtime",
                     NameAr = "وقت إضافي",
                     DefaultDays = 20
                 },
                 new OrderType
                 {
-                    Id = 4,
+                    Id = 3,
                     NameEn = "Business trip", //(after closed from employee / manager)
                     NameAr = "رحلة عمل",
                     DefaultDays = 0
@@ -50,11 +44,27 @@ namespace MTWorkHR.Infrastructure.Configurations
                 },
                 new OrderType
                 {
-                    Id = 5,
+                    Id = 4,
                     NameEn = "Course",
                     NameAr = "دورة تدريبية",
                     DefaultDays = 0
                 }
+                ,
+                new OrderType
+                {
+                    Id = 5,
+                    NameEn = "Service Certificate",
+                    NameAr = "خدمة معتمده",
+                    DefaultDays = 0
+                }
+                 ,
+                new OrderType
+                {
+                    Id = 6,
+                    NameEn = "Other",
+                    NameAr = "أخرى",
+                    DefaultDays = 0
+                }
                ) ;
         }
     }

+ 291 - 166
MTWorkHR.Infrastructure/Configurations/PermissionConfiguration.cs

@@ -9,153 +9,141 @@ using System.Threading.Tasks;
 
 namespace MTWorkHR.Infrastructure.Configurations
 {
-        public class PermissionConfiguration : IEntityTypeConfiguration<Permission>
+    public class PermissionConfiguration : IEntityTypeConfiguration<Permission>
+    {
+        public void Configure(EntityTypeBuilder<Permission> builder)
         {
-            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"
+            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
 
-                    },
-                    new Permission()
-                    {
-                        Id = 15,
-                        Name = "UserTask.Update",
-                        Desc = "UserTask.Update",
-                        CategoryName = "Sales"
+            #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
 
-                    },
-                    new Permission()
-                    {
-                        Id = 16,
-                        Name = "UserTask.Delete",
-                        Desc = "UserTask.Delete",
-                        CategoryName = "User"
+            #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
 
-                    },
-                #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
+            #region Company
                 new Permission()
                 {
                     Id = 17,
@@ -163,7 +151,6 @@ namespace MTWorkHR.Infrastructure.Configurations
                     Desc = "Company",
                     Show = true,
                     CategoryName = "User"
-
                 },
                 new Permission()
                 {
@@ -171,7 +158,6 @@ namespace MTWorkHR.Infrastructure.Configurations
                     Name = "Company.Create",
                     Desc = "Company.Create",
                     CategoryName = "User"
-
                 },
                 new Permission()
                 {
@@ -179,7 +165,6 @@ namespace MTWorkHR.Infrastructure.Configurations
                     Name = "Company.Update",
                     Desc = "Company.Update",
                     CategoryName = "User"
-
                 },
                 new Permission()
                 {
@@ -187,83 +172,223 @@ namespace MTWorkHR.Infrastructure.Configurations
                     Name = "Company.Delete",
                     Desc = "Company.Delete",
                     CategoryName = "User"
-
+                },
+                new Permission()
+                {
+                    Id = 21,
+                    Name = "Company.Suspend",
+                    Desc = "Company.Suspend",
+                    CategoryName = "User"
                 },
             #endregion
+
             #region User
                 new Permission()
                 {
-                    Id = 21,
+                    Id = 22,
                     Name = "User",
                     Desc = "User",
                     Show = true,
                     CategoryName = "Adminstration"
-
                 },
                 new Permission()
                 {
-                    Id = 22,
+                    Id = 23,
                     Name = "User.Create",
                     Desc = "User.Create",
                     CategoryName = "Adminstration"
-
                 },
                 new Permission()
                 {
-                    Id = 23,
+                    Id = 24,
                     Name = "User.Update",
                     Desc = "User.Update",
                     CategoryName = "Adminstration"
-
                 },
                 new Permission()
                 {
-                    Id = 24,
+                    Id = 25,
                     Name = "User.Delete",
                     Desc = "User.Delete",
                     CategoryName = "Adminstration"
-
+                },
+                new Permission()
+                {
+                    Id = 26,
+                    Name = "User.Suspend",
+                    Desc = "User.Suspend",
+                    CategoryName = "Adminstration"
                 },
             #endregion
 
             #region Role
                 new Permission()
                 {
-                    Id = 25,
+                    Id = 27,
                     Name = "Role",
                     Desc = "Role",
                     Show = true,
                     CategoryName = "Adminstration"
-
                 },
                 new Permission()
                 {
-                    Id = 26,
+                    Id = 28,
                     Name = "Role.Create",
                     Desc = "Role.Create",
                     CategoryName = "Adminstration"
-
                 },
                 new Permission()
                 {
-                    Id = 27,
+                    Id = 29,
                     Name = "Role.Update",
                     Desc = "Role.Update",
                     CategoryName = "Adminstration"
-
                 },
                 new Permission()
                 {
-                    Id = 28,
+                    Id = 30,
                     Name = "Role.Delete",
                     Desc = "Role.Delete",
                     CategoryName = "Adminstration"
+                },
+            #endregion
+
+            #region Attendance
+                new Permission()
+                {
+                    Id = 31,
+                    Name = "Attendance",
+                    Desc = "Attendance",
+                    Show = true,
+                    CategoryName = "Adminstration"
+                },
+                new Permission()
+                {
+                    Id = 32,
+                    Name = "Attendance.Create",
+                    Desc = "Attendance.Create",
+                    CategoryName = "Adminstration"
+                },
+                new Permission()
+                {
+                    Id = 33,
+                    Name = "Attendance.Update",
+                    Desc = "Attendance.Update",
+                    CategoryName = "Adminstration"
+                },
+                new Permission()
+                {
+                    Id = 34,
+                    Name = "Attendance.Delete",
+                    Desc = "Attendance.Delete",
+                    CategoryName = "Adminstration"
+                },
+            #endregion
+
+            #region Contract
+                new Permission()
+                {
+                    Id = 35,
+                    Name = "Contract",
+                    Desc = "Contract",
+                    Show = true,
+                    CategoryName = "Adminstration"
+                },
+                new Permission()
+                {
+                    Id = 36,
+                    Name = "Contract.Create",
+                    Desc = "Contract.Create",
+                    CategoryName = "Adminstration"
+                },
+                new Permission()
+                {
+                    Id = 37,
+                    Name = "Contract.Update",
+                    Desc = "Contract.Update",
+                    CategoryName = "Adminstration"
+                },
+                new Permission()
+                {
+                    Id = 38,
+                    Name = "Contract.Delete",
+                    Desc = "Contract.Delete",
+                    CategoryName = "Adminstration"
+                },
+            #endregion
+
+            #region OrderAllocation
+                new Permission()
+                {
+                    Id = 39,
+                    Name = "OrderAllocation",
+                    Desc = "OrderAllocation",
+                    Show = true,
+                    CategoryName = "Adminstration"
+                },
+                new Permission()
+                {
+                    Id = 40,
+                    Name = "OrderAllocation.Create",
+                    Desc = "OrderAllocation.Create",
+                    CategoryName = "Adminstration"
+                },
+                new Permission()
+                {
+                    Id = 41,
+                    Name = "OrderAllocation.Update",
+                    Desc = "OrderAllocation.Update",
+                    CategoryName = "Adminstration"
+                },
+                new Permission()
+                {
+                    Id = 42,
+                    Name = "OrderAllocation.Delete",
+                    Desc = "OrderAllocation.Delete",
+                    CategoryName = "Adminstration"
+                },
+            #endregion
 
+            #region OrderRequest
+                new Permission()
+                {
+                    Id = 43,
+                    Name = "OrderRequest",
+                    Desc = "OrderRequest",
+                    Show = true,
+                    CategoryName = "Adminstration"
+                },
+                new Permission()
+                {
+                    Id = 44,
+                    Name = "OrderRequest.Create",
+                    Desc = "OrderRequest.Create",
+                    CategoryName = "Adminstration"
+                },
+                new Permission()
+                {
+                    Id = 45,
+                    Name = "OrderRequest.Update",
+                    Desc = "OrderRequest.Update",
+                    CategoryName = "Adminstration"
+                },
+                new Permission()
+                {
+                    Id = 46,
+                    Name = "OrderRequest.Delete",
+                    Desc = "OrderRequest.Delete",
+                    CategoryName = "Adminstration"
                 }
                 #endregion
-                );
-
-            }
+                , new Permission()
+                {
+                    Id = 47,
+                    Name = "User.ResetPassword",
+                    Desc = "User.ResetPassword",
+                    CategoryName = "Adminstration"
+                }
+                
+            );
         }
-    
-}
+    }
+}

+ 1 - 1
MTWorkHR.Infrastructure/Configurations/RoleConfiguration.cs

@@ -21,7 +21,7 @@ namespace MTWorkHR.Infrastructure.Configurations
                     Id = "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211A",
                     Name = "Admin",
                     NormalizedName = "ADMIN",
-                    IsAdmin = true,
+                    IsAdmin = false, // this flag to authorize all function in case of true.
                     IsDeleted = false,
                     
                 },

+ 226 - 0
MTWorkHR.Infrastructure/Configurations/RolePermissionConfiguration.cs

@@ -0,0 +1,226 @@
+using Microsoft.AspNetCore.Identity;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using MTWorkHR.Infrastructure.Entities;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Infrastructure.Configurations
+{
+    public class RolePermissionConfiguration : IEntityTypeConfiguration<RolePermission>
+    {
+
+        public void Configure(EntityTypeBuilder<RolePermission> builder)
+        {
+            builder.HasData(
+
+                //___________________________________________________________________Employee________________
+
+                // Add all permissions except company (delete, suspend ) and user(delete,suspend),
+                new RolePermission { Id = 1, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 1, PermissionName = "Project" },
+                new RolePermission { Id = 2, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 2, PermissionName = "Project.Create" },
+                new RolePermission { Id = 3, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 3, PermissionName = "Project.Update" },
+                new RolePermission { Id = 4, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 4, PermissionName = "Project.Delete" },
+
+                new RolePermission { Id = 5, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 5, PermissionName = "Meeting" },
+                new RolePermission { Id = 6, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 6, PermissionName = "Meeting.Create" },
+                new RolePermission { Id = 7, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 7, PermissionName = "Meeting.Update" },
+                new RolePermission { Id = 8, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 8, PermissionName = "Meeting.Delete" },
+
+                new RolePermission { Id = 9, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 9, PermissionName = "Team" },
+                new RolePermission { Id = 10, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 10, PermissionName = "Team.Create" },
+                new RolePermission { Id = 11, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 11, PermissionName = "Team.Update" },
+                new RolePermission { Id = 12, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 12, PermissionName = "Team.Delete" },
+
+                new RolePermission { Id = 13, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 13, PermissionName = "UserTask" },
+                new RolePermission { Id = 14, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 14, PermissionName = "UserTask.Create" },
+                new RolePermission { Id = 15, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 15, PermissionName = "UserTask.Update" },
+                new RolePermission { Id = 16, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 16, PermissionName = "UserTask.Delete" },
+
+                // Company permissions (excluding Delete and Suspend)
+                new RolePermission { Id = 17, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 17, PermissionName = "Company" },
+                //new RolePermission { Id = 18, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 18, PermissionName = "Company.Create" },
+                //new RolePermission { Id = 19, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 19, PermissionName = "Company.Update" },
+
+                // User permissions (excluding Delete and Suspend)
+                new RolePermission { Id = 20, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 22, PermissionName = "User" },
+                //new RolePermission { Id = 21, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 23, PermissionName = "User.Create" },
+                new RolePermission { Id = 22, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 24, PermissionName = "User.Update" },
+
+                // Role permissions
+                new RolePermission { Id = 23, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 27, PermissionName = "Role" },
+                new RolePermission { Id = 24, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 28, PermissionName = "Role.Create" },
+                new RolePermission { Id = 25, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 29, PermissionName = "Role.Update" },
+                new RolePermission { Id = 26, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 30, PermissionName = "Role.Delete" },
+
+                // Attendance permissions
+                new RolePermission { Id = 27, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 31, PermissionName = "Attendance" },
+                new RolePermission { Id = 28, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 32, PermissionName = "Attendance.Create" },
+                new RolePermission { Id = 29, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 33, PermissionName = "Attendance.Update" },
+                new RolePermission { Id = 30, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 34, PermissionName = "Attendance.Delete" },
+
+                // Contract permissions
+                //new RolePermission { Id = 31, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 35, PermissionName = "Contract" },
+                //new RolePermission { Id = 32, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 36, PermissionName = "Contract.Create" },
+                //new RolePermission { Id = 33, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 37, PermissionName = "Contract.Update" },
+                //new RolePermission { Id = 34, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 38, PermissionName = "Contract.Delete" },
+
+                // OrderAllocation permissions
+                new RolePermission { Id = 35, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 39, PermissionName = "OrderAllocation" },
+                new RolePermission { Id = 36, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 40, PermissionName = "OrderAllocation.Create" },
+                new RolePermission { Id = 37, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 41, PermissionName = "OrderAllocation.Update" },
+                new RolePermission { Id = 38, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 42, PermissionName = "OrderAllocation.Delete" },
+
+                // OrderRequest permissions
+                new RolePermission { Id = 39, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 43, PermissionName = "OrderRequest" },
+                new RolePermission { Id = 40, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 44, PermissionName = "OrderRequest.Create" },
+                new RolePermission { Id = 41, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 45, PermissionName = "OrderRequest.Update" },
+                new RolePermission { Id = 42, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 46, PermissionName = "OrderRequest.Delete" },
+                //__________________________________________________________Admin____________________
+
+                new RolePermission { Id = 43, RoleId = "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211A", PermissionId = 17, PermissionName = "Company" },
+                new RolePermission { Id = 44, RoleId = "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211A", PermissionId = 20, PermissionName = "Company.Delete" },
+                new RolePermission { Id = 45, RoleId = "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211A", PermissionId = 21, PermissionName = "Company.Suspend" },
+                new RolePermission { Id = 46, RoleId = "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211A", PermissionId = 22, PermissionName = "User" },
+                new RolePermission { Id = 47, RoleId = "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211A", PermissionId = 25, PermissionName = "User.Delete" },
+                new RolePermission { Id = 48, RoleId = "AD5B3B92-2311-48F8-9DEC-F9FAEF1F211A", PermissionId = 26, PermissionName = "User.Suspend" },
+
+
+                //_____________________________________________________________Contractor
+
+                // Start with Id = 49 and include all permissions except company (delete, suspend ) and user(delete,suspend),
+                new RolePermission { Id = 49, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 1, PermissionName = "Project" },
+                new RolePermission { Id = 50, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 2, PermissionName = "Project.Create" },
+                new RolePermission { Id = 51, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 3, PermissionName = "Project.Update" },
+                new RolePermission { Id = 52, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 4, PermissionName = "Project.Delete" },
+
+                new RolePermission { Id = 53, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 5, PermissionName = "Meeting" },
+                new RolePermission { Id = 54, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 6, PermissionName = "Meeting.Create" },
+                new RolePermission { Id = 55, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 7, PermissionName = "Meeting.Update" },
+                new RolePermission { Id = 56, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 8, PermissionName = "Meeting.Delete" },
+
+                new RolePermission { Id = 57, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 9, PermissionName = "Team" },
+                new RolePermission { Id = 58, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 10, PermissionName = "Team.Create" },
+                new RolePermission { Id = 59, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 11, PermissionName = "Team.Update" },
+                new RolePermission { Id = 60, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 12, PermissionName = "Team.Delete" },
+
+                new RolePermission { Id = 61, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 13, PermissionName = "UserTask" },
+                new RolePermission { Id = 62, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 14, PermissionName = "UserTask.Create" },
+                new RolePermission { Id = 63, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 15, PermissionName = "UserTask.Update" },
+                new RolePermission { Id = 64, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 16, PermissionName = "UserTask.Delete" },
+
+                // Company permissions (excluding Delete and Suspend)
+                new RolePermission { Id = 65, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 17, PermissionName = "Company" },
+                //new RolePermission { Id = 66, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 18, PermissionName = "Company.Create" },
+                //new RolePermission { Id = 67, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 19, PermissionName = "Company.Update" },
+
+                // User permissions (excluding Delete and Suspend)
+                new RolePermission { Id = 68, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 22, PermissionName = "User" },
+                new RolePermission { Id = 69, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 23, PermissionName = "User.Create" },
+                new RolePermission { Id = 70, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 24, PermissionName = "User.Update" },
+
+                // Role permissions
+                new RolePermission { Id = 71, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 27, PermissionName = "Role" },
+                new RolePermission { Id = 72, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 28, PermissionName = "Role.Create" },
+                new RolePermission { Id = 73, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 29, PermissionName = "Role.Update" },
+                new RolePermission { Id = 74, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 30, PermissionName = "Role.Delete" },
+
+                // Attendance permissions
+                new RolePermission { Id = 75, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 31, PermissionName = "Attendance" },
+                new RolePermission { Id = 76, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 32, PermissionName = "Attendance.Create" },
+                new RolePermission { Id = 77, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 33, PermissionName = "Attendance.Update" },
+                new RolePermission { Id = 78, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 34, PermissionName = "Attendance.Delete" },
+
+                // Contract permissions
+                new RolePermission { Id = 79, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 35, PermissionName = "Contract" },
+                new RolePermission { Id = 80, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 36, PermissionName = "Contract.Create" },
+                new RolePermission { Id = 81, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 37, PermissionName = "Contract.Update" },
+                new RolePermission { Id = 82, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 38, PermissionName = "Contract.Delete" },
+
+                // OrderAllocation permissions
+                new RolePermission { Id = 83, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 39, PermissionName = "OrderAllocation" },
+                new RolePermission { Id = 84, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 40, PermissionName = "OrderAllocation.Create" },
+                new RolePermission { Id = 85, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 41, PermissionName = "OrderAllocation.Update" },
+                new RolePermission { Id = 86, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 42, PermissionName = "OrderAllocation.Delete" },
+
+                // OrderRequest permissions
+                new RolePermission { Id = 87, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 43, PermissionName = "OrderRequest" },
+                new RolePermission { Id = 88, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 44, PermissionName = "OrderRequest.Create" },
+                new RolePermission { Id = 89, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 45, PermissionName = "OrderRequest.Update" },
+                new RolePermission { Id = 90, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 46, PermissionName = "OrderRequest.Delete" },
+
+                //_____________________________________________________________BUSINESS
+
+                // Start with Id = 91 and include all permissions except company (delete, suspend ) and user(delete,suspend),
+                new RolePermission { Id = 91, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 1, PermissionName = "Project" },
+                new RolePermission { Id = 92, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 2, PermissionName = "Project.Create" },
+                new RolePermission { Id = 93, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 3, PermissionName = "Project.Update" },
+                new RolePermission { Id = 94, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 4, PermissionName = "Project.Delete" },
+
+                new RolePermission { Id = 95, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 5, PermissionName = "Meeting" },
+                new RolePermission { Id = 96, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 6, PermissionName = "Meeting.Create" },
+                new RolePermission { Id = 97, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 7, PermissionName = "Meeting.Update" },
+                new RolePermission { Id = 98, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 8, PermissionName = "Meeting.Delete" },
+
+                new RolePermission { Id = 99, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 9, PermissionName = "Team" },
+                new RolePermission { Id = 100, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 10, PermissionName = "Team.Create" },
+                new RolePermission { Id = 101, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 11, PermissionName = "Team.Update" },
+                new RolePermission { Id = 102, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 12, PermissionName = "Team.Delete" },
+
+                new RolePermission { Id = 103, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 13, PermissionName = "UserTask" },
+                new RolePermission { Id = 104, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 14, PermissionName = "UserTask.Create" },
+                new RolePermission { Id = 105, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 15, PermissionName = "UserTask.Update" },
+                new RolePermission { Id = 106, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 16, PermissionName = "UserTask.Delete" },
+
+                // Company permissions (excluding Delete and Suspend)
+                new RolePermission { Id = 107, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 17, PermissionName = "Company" },
+                new RolePermission { Id = 108, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 18, PermissionName = "Company.Create" },
+                new RolePermission { Id = 109, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 19, PermissionName = "Company.Update" },
+
+                // User permissions (excluding Delete and Suspend)
+                new RolePermission { Id = 110, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 22, PermissionName = "User" },
+                new RolePermission { Id = 111, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 23, PermissionName = "User.Create" },
+                new RolePermission { Id = 112, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 24, PermissionName = "User.Update" },
+
+                // Role permissions
+                new RolePermission { Id = 113, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 27, PermissionName = "Role" },
+                new RolePermission { Id = 114, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 28, PermissionName = "Role.Create" },
+                new RolePermission { Id = 115, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 29, PermissionName = "Role.Update" },
+                new RolePermission { Id = 116, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 30, PermissionName = "Role.Delete" },
+
+                // Attendance permissions
+                new RolePermission { Id = 117, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 31, PermissionName = "Attendance" },
+                new RolePermission { Id = 118, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 32, PermissionName = "Attendance.Create" },
+                new RolePermission { Id = 119, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 33, PermissionName = "Attendance.Update" },
+                new RolePermission { Id = 120, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 34, PermissionName = "Attendance.Delete" },
+
+                // Contract permissions
+                new RolePermission { Id = 121, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 35, PermissionName = "Contract" },
+                new RolePermission { Id = 122, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 36, PermissionName = "Contract.Create" },
+                new RolePermission { Id = 123, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 37, PermissionName = "Contract.Update" },
+                new RolePermission { Id = 124, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 38, PermissionName = "Contract.Delete" },
+
+                // OrderAllocation permissions
+                new RolePermission { Id = 125, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 39, PermissionName = "OrderAllocation" },
+                new RolePermission { Id = 126, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 40, PermissionName = "OrderAllocation.Create" },
+                new RolePermission { Id = 127, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 41, PermissionName = "OrderAllocation.Update" },
+                new RolePermission { Id = 128, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 42, PermissionName = "OrderAllocation.Delete" },
+
+                // OrderRequest permissions
+                new RolePermission { Id = 129, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 43, PermissionName = "OrderRequest" },
+                new RolePermission { Id = 130, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 44, PermissionName = "OrderRequest.Create" },
+                new RolePermission { Id = 131, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 45, PermissionName = "OrderRequest.Update" },
+                new RolePermission { Id = 132, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 46, PermissionName = "OrderRequest.Delete" },
+
+
+                //user.ResetPassword
+                new RolePermission { Id = 133, RoleId = "EM5B3B92-2311-48F8-9DEC-F9FAEF1F211E", PermissionId = 47, PermissionName = "User.ResetPassword" },
+                new RolePermission { Id = 134, RoleId = "CO5B3B92-2311-48F8-9DEC-F9FAEF1F211R", PermissionId = 47, PermissionName = "User.ResetPassword" },
+                new RolePermission { Id = 135, RoleId = "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", PermissionId = 47, PermissionName = "User.ResetPassword" }
+            );
+        }
+    }
+}

+ 28 - 27
MTWorkHR.Infrastructure/Configurations/UserConfiguration.cs

@@ -17,33 +17,34 @@ namespace MTWorkHR.Infrastructure.Configurations
         {
             var hasher = new PasswordHasher<ApplicationUser>();
             builder.HasData(
-                new ApplicationUser
-                {
-                    Id = "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA",
-                    FirstName = "Super",
-                    LastName ="Admin",
-                    UserName = "Admin@super.com",
-                    Email = "admin@super.com",
-                    NormalizedEmail = "ADMIN@SUPER.COM",
-                    EmailConfirmed = true,
-                    NormalizedUserName = "ADMIN@SUPER.COM",
-                    PhoneNumber = "1234567890",
-                    PhoneNumberConfirmed = true,
-                    IsDeleted = false,
-                    IsStopped = false,
-                    DeleteUserId = null,AccessFailedCount = 0,
-                    UserType = 0,
-                    ConcurrencyStamp= "7cc87689-9eab-4280-b8e3-1834080783a5",
-                    SecurityStamp = "49bb16c3-4704-4c60-908d-dc8506950acc",
-                    PassportNumber = "1234567",
-                    TaxNumber = 111334455,
-                    IncomeTaxValue = 1,
-                    QualificationId = null,
-                    IdNumber = "1230000099",
-                    DateOfBirth = new DateTime(2000,2,10), 
-                    CompanyId = null,
-                    PasswordHash = "AQAAAAIAAYagAAAAEPg+ASbciPFxtyxQq8Wx5ilBUQ0RbAoITXXkOQm1PzC5BzySX0sn/wUmOjBKPDGV9w==" //hasher.HashPassword(null, "P@ssword1")
-                },
+               new ApplicationUser
+               {
+                   Id = "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA",
+                   FirstName = "Super",
+                   LastName = "Admin",
+                   UserName = "Admin@super.com",
+                   Email = "admin@super.com",
+                   NormalizedEmail = "ADMIN@SUPER.COM",
+                   EmailConfirmed = true,
+                   NormalizedUserName = "ADMIN@SUPER.COM",
+                   PhoneNumber = "1234567890",
+                   PhoneNumberConfirmed = true,
+                   IsDeleted = false,
+                   IsStopped = false,
+                   DeleteUserId = null,
+                   AccessFailedCount = 0,
+                   UserType = 0,
+                   ConcurrencyStamp = "7cc87689-9eab-4280-b8e3-1834080783a5",
+                   SecurityStamp = "49bb16c3-4704-4c60-908d-dc8506950acc",
+                   PassportNumber = "123456700",
+                   TaxNumber = 111334455,
+                   IncomeTaxValue = 1,
+                   QualificationId = null,
+                   IdNumber = "1234",
+                   DateOfBirth = new DateTime(2000, 2, 10),
+                   CompanyId = null,
+                   PasswordHash = "AQAAAAIAAYagAAAAEPg+ASbciPFxtyxQq8Wx5ilBUQ0RbAoITXXkOQm1PzC5BzySX0sn/wUmOjBKPDGV9w==" //hasher.HashPassword(null, "P@ssword1")
+               },
                 new ApplicationUser
                 {
                     Id = "AL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB",

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

@@ -55,6 +55,7 @@ namespace MTWorkHR.Infrastructure.DBContext
         public DbSet<Contract> Contracts { get; set; }
         public DbSet<Nationality> Nationalities{ get; set; }
         public DbSet<SubscriptionConfiguration> SubscriptionConfiguration { get; set; }
+        public DbSet<Invoice> Invoice { get; set; }
 
         //------------------------Logs------------------------
         public DbSet<UserLog> UserLogs { get; set; }

+ 97 - 0
MTWorkHR.Infrastructure/Entities/ContractDetail.cs

@@ -0,0 +1,97 @@
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Global;
+using Newtonsoft.Json;
+
+namespace MTWorkHR.Infrastructure.Entities
+{
+    public class ContractDetail2
+    {
+        public ContractTypeEnum ContractTypeId { get; set; }
+        public ContractStatusEnum ContractStatusId { get; set; }
+        //--------Company data-------
+        public string CompanyName { get; set; }
+        public string CompanyCR { get; set; }
+        public string CompanyEmail { get; set; }
+        public string CompanyAddress { get; set; }
+        public string CompanyPhone { get; set; }
+        //--------Company Representative-------
+        public string CompanyRepresentativeName { get; set; }
+        public string CompanyRepresentativePassport { get; set; }
+        public string CompanyRepresentativePhone { get; set; }
+        public string CompanyRepresentativeEmail { get; set; }
+        public string CompanyRepresentativePosition { get; set; }
+        //--------Employee Data------------------------------------
+        public string UserId { get; set; }
+        [JsonProperty(Required = Required.AllowNull)]
+        public string? EmployeeName { get; set; }
+        [JsonProperty(Required = Required.AllowNull)]
+        public string? EmployeeEmail { get; set; }
+        public string? EmployeePassport{ get; set; }
+        public string? EmployeePhone { get; set; }
+        public string? EmployeeUniversity { get; set; }
+        public DateTime? EmployeeDateOfBirth { get; set; }
+        //-----------------------------
+        public string? EmployeeJobName { get; set; }
+        public string? AcademicQualification { get; set; }
+        public string? Specialization { get; set; }
+        public string WorkCountry { get; set; }
+        public string WorkState { get; set; }
+        //-------------------Scope of work-----------
+        public string? JobTitleName { get; set; }
+        public string? JobDescription { get; set; }
+        [MaxLength(150)]
+        public string? JobNumber { get; set; } //ثابت و مأخوذ من المنصة
+        //----------------Contract data -------------------------
+        public DateTime? StartDate { get; set; }
+        [JsonProperty(Required = Required.AllowNull)]
+        public DateTime? EndDate { get; set; }
+
+        [JsonProperty(Required = Required.AllowNull)]
+        public string? ContractDuration { get; set; } //:  اختيار: شهري – ربعي – نصف سنوي – 3 ارباع – سنوي
+        public string? TypeOfWork { get; set; } //: :   اختيار: عقد بدوام كامل -  عقد دوام جزئي   
+        [JsonProperty(Required = Required.AllowNull)]
+        public int? VacationDays { get; set; } //اختيار: بدون – سنويا (رقم)
+        public int? TrialPeriod { get; set; } // تجربة (ادخال: تلقائياً كل ربع سنوي أسبوع تلقائياً) آخر: تعديل
+        public string? WhoCanTerminateContractInTrial { get; set; } //اختيار   الجميع – صاحب العمل – الموظف
+        public string? WhoCanTerminateContract { get; set; }
+        [JsonProperty(Required = Required.AllowNull)]
+        public int? NoticePeriodBeforeTermination { get; set; } //اختيار: بدون – تحديد (ادخال: تلقائياً مدة 10 أيام قبل انتهاء الاستحقاق) آخر: تعديل
+
+
+        //------Working time---------------
+        [JsonProperty(Required = Required.AllowNull)]
+        public List<string>? WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
+        public string? WorkingHours { get; set; } //	يومي/ اسبوعي  
+        public int? WorkingHoursNum { get; set; } // عدد الساعات
+        public DateTime? StartDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
+        public DateTime? EndDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
+
+        //----------Salary-----------------
+        [MaxLength(50)]
+        public string? Currency { get; set; }
+        public decimal? Salary { get; set; }
+        public string? BillingCycle { get; set; }// 2 fortnightly, 4 Monthly
+        //------------------------Fixed Pay----------------
+        public DateTime? FirstPatchDateFrom { get; set; }
+        public DateTime? FirstPatchDateTo { get; set; } //
+        public decimal? FirstPatchAmount { get; set; }
+
+        public DateTime? LastPatchDateFrom { get; set; } //
+        public DateTime? LastPatchDateTo { get; set; } // 
+        public decimal? LastPatchAmount { get; set; }
+        public string? Teams { get; set; }
+        public string? Vacations { get; set; }
+
+
+        //---------Allowances----------------------
+        public bool IncludesAllAllowances { get; set; }
+        public List<ContractAllowance>? FixedAllowances { get; set; }
+
+        //-------------------------------
+        public List<ContractTask>? ContractTasks { get; set; }
+        public List<ProjectStage>? ProjectStages { get; set; }
+    }
+}

+ 2 - 1
MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs

@@ -32,7 +32,7 @@ namespace MTWorkHR.Infrastructure
             
             services.AddDbContext<HRDataContext>(options =>
                 options.UseSqlServer(
-                    config.ConnectionStrings.LocalConnectionString  //configuration.GetSection("ConnectionString:MTWorkHRConnectionString").Value
+                    config.ConnectionStrings.MTWorkHRConnectionString  //configuration.GetSection("ConnectionString:MTWorkHRConnectionString").Value
                     ));
            
             services.AddIdentity<ApplicationUser, ApplicationRole>().AddEntityFrameworkStores<HRDataContext>().AddDefaultTokenProviders();
@@ -107,6 +107,7 @@ namespace MTWorkHR.Infrastructure
             services.AddScoped(typeof(IContractTaskAttachmentRepository), typeof(ContractTaskAttachmentRepository));
             services.AddScoped(typeof(IProjectStageAttachmentRepository), typeof(ProjectStageAttachmentRepository));
             services.AddScoped(typeof(ISubscriptionConfigurationRepository), typeof(SubscriptionConfigurationRepository));
+            services.AddScoped(typeof(IInvoiceRepository), typeof(InvoiceRepository));
 
             services.AddScoped(typeof(IHubConnectionRepository), typeof(HubConnectionRepository));
             

+ 2 - 4
MTWorkHR.Infrastructure/MTWorkHR.Infrastructure.csproj

@@ -13,6 +13,8 @@
 
   <ItemGroup>
     <PackageReference Include="DevExpress.AspNetCore.Reporting" Version="24.1.6" />
+    <PackageReference Include="itext7" Version="8.0.3" />
+    <PackageReference Include="itext7.bouncy-castle-adapter" Version="8.0.3" />
     <PackageReference Include="MailKit" Version="4.3.0" />
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
     <PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
@@ -32,8 +34,4 @@
     <ProjectReference Include="..\MTWorkHR.Core\MTWorkHR.Core.csproj" />
   </ItemGroup>
 
-  <ItemGroup>
-    <Folder Include="Reports\" />
-  </ItemGroup>
-
 </Project>

File diff suppressed because it is too large
+ 5825 - 0
MTWorkHR.Infrastructure/Migrations/20250113145938_altrUserAdmin.Designer.cs


+ 32 - 0
MTWorkHR.Infrastructure/Migrations/20250113145938_altrUserAdmin.cs

@@ -0,0 +1,32 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrUserAdmin : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.UpdateData(
+                table: "AspNetUsers",
+                keyColumn: "Id",
+                keyValue: "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA",
+                columns: new[] { "CompanyId", "Email", "FirstName", "IdNumber", "LastName", "NormalizedEmail", "NormalizedUserName", "PassportNumber", "TaxNumber", "UserName", "UserType" },
+                values: new object[] { null, "admin@super.com", "Super", "1234", "Admin", "ADMIN@SUPER.COM", "ADMIN@SUPER.COM", "123456700", 111334455m, "Admin@super.com", 0 });
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.UpdateData(
+                table: "AspNetUsers",
+                keyColumn: "Id",
+                keyValue: "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA",
+                columns: new[] { "CompanyId", "Email", "FirstName", "IdNumber", "LastName", "NormalizedEmail", "NormalizedUserName", "PassportNumber", "TaxNumber", "UserName", "UserType" },
+                values: new object[] { 1L, "a@b.com", "Zinab", "123", "Elgendy", "A@B.COM", "A@B.COM", "1234567", 111m, "A@b.com", 1 });
+        }
+    }
+}

File diff suppressed because it is too large
+ 6895 - 0
MTWorkHR.Infrastructure/Migrations/20250119103851_rolePermissions.Designer.cs


File diff suppressed because it is too large
+ 1046 - 0
MTWorkHR.Infrastructure/Migrations/20250119103851_rolePermissions.cs


+ 0 - 0
MTWorkHR.Infrastructure/Migrations/20250120121744_altrAdminRole.Designer.cs


Some files were not shown because too many files changed in this diff