4 Commits a6c7d54b8f ... 468d072d2e

Author SHA1 Message Date
  zinab_elgendy 468d072d2e CompanyUserGetMessages 1 month ago
  zinab_elgendy 80e19c52b1 Merge reporting and chatCompanyUsers 1 month ago
  zinab_elgendy da29f4e4f7 Company: add address, email, phone 1 month ago
  zinab_elgendy f06c7f5530 Contract with Report 1 month ago
32 changed files with 22841 additions and 285 deletions
  1. 23 0
      MTWorkHR.API/Controllers/CustomWebDocumentViewerController.cs
  2. 52 0
      MTWorkHR.API/Controllers/ReportingController.cs
  3. 10 0
      MTWorkHR.API/MTWorkHR.API.csproj
  4. 20 0
      MTWorkHR.API/Program.cs
  5. 1235 0
      MTWorkHR.API/Reports/ContractReport.Designer.cs
  6. 16 0
      MTWorkHR.API/Reports/ContractReport.cs
  7. 123 0
      MTWorkHR.API/Reports/ContractReport.resx
  8. 130 0
      MTWorkHR.API/Reports/EmployeeContract.Designer.cs
  9. 16 0
      MTWorkHR.API/Reports/EmployeeContract.cs
  10. 123 0
      MTWorkHR.API/Reports/EmployeeContract.resx
  11. 85 0
      MTWorkHR.API/Reports/ReportStorageWebExtension.cs
  12. 1 1
      MTWorkHR.API/appsettings.json
  13. 27 10
      MTWorkHR.Application/Chat/ChatHub.cs
  14. 3 0
      MTWorkHR.Application/Dtos/Identity/UserDto.cs
  15. 3 0
      MTWorkHR.Application/Dtos/Identity/UserUpdateDto.cs
  16. 22 0
      MTWorkHR.Application/Dtos/Lookup/NationalityDto.cs
  17. 5 1
      MTWorkHR.Application/Dtos/User/CompanyDto.cs
  18. 6 2
      MTWorkHR.Application/Services/User/CompanyService.cs
  19. 14 0
      MTWorkHR.Core/Entities/User/Company.cs
  20. 24 0
      MTWorkHR.Core/Entities/User/Nationality.cs
  21. 1479 0
      MTWorkHR.Infrastructure/Configurations/NationalityConfiguration.cs
  22. 1 0
      MTWorkHR.Infrastructure/DBContext/HRDataContext.cs
  23. 6 0
      MTWorkHR.Infrastructure/Entities/ApplicationUser.cs
  24. 17 0
      MTWorkHR.Infrastructure/MTWorkHR.Infrastructure.csproj
  25. 5642 0
      MTWorkHR.Infrastructure/Migrations/20241029101807_altrUserCompany_addNationality.Designer.cs
  26. 375 0
      MTWorkHR.Infrastructure/Migrations/20241029101807_altrUserCompany_addNationality.cs
  27. 5663 0
      MTWorkHR.Infrastructure/Migrations/20241030125620_altrCompanyTbl.Designer.cs
  28. 129 0
      MTWorkHR.Infrastructure/Migrations/20241030125620_altrCompanyTbl.cs
  29. 5698 0
      MTWorkHR.Infrastructure/Migrations/20241103150423_altrRoleBusiness.Designer.cs
  30. 32 0
      MTWorkHR.Infrastructure/Migrations/20241103150423_altrRoleBusiness.cs
  31. 1847 271
      MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs
  32. 14 0
      MTWorkHR.Infrastructure/appsettings.json

+ 23 - 0
MTWorkHR.API/Controllers/CustomWebDocumentViewerController.cs

@@ -0,0 +1,23 @@
+using DevExpress.AspNetCore.Reporting.QueryBuilder.Native.Services;
+using DevExpress.AspNetCore.Reporting.QueryBuilder;
+using DevExpress.AspNetCore.Reporting.WebDocumentViewer.Native.Services;
+using DevExpress.AspNetCore.Reporting.WebDocumentViewer;
+using Microsoft.AspNetCore.Mvc;
+
+namespace MTWorkHR.API.Controllers
+{
+    [ApiExplorerSettings(IgnoreApi = true)]
+    public class CustomWebDocumentViewerController : WebDocumentViewerController
+    {
+        public CustomWebDocumentViewerController(IWebDocumentViewerMvcControllerService controllerService) : base(controllerService)
+        {
+        }
+    }
+    [ApiExplorerSettings(IgnoreApi = true)]
+    public class CustomQueryBuilderController : QueryBuilderController
+    {
+        public CustomQueryBuilderController(IQueryBuilderMvcControllerService controllerService) : base(controllerService)
+        {
+        }
+    }
+}

+ 52 - 0
MTWorkHR.API/Controllers/ReportingController.cs

@@ -0,0 +1,52 @@
+
+using Microsoft.AspNetCore.Mvc;
+using DevExpress.XtraReports.UI;
+using DevExpress.XtraReports.Web.Extensions;
+using System.IO;
+
+namespace MTWorkHR.API.Controllers
+{
+    [ApiController]
+    [Route("api/[controller]")]
+    public class ReportController : ControllerBase
+    {
+        private readonly ReportStorageWebExtension _reportStorage;
+
+        public ReportController(ReportStorageWebExtension reportStorage)
+        {
+            _reportStorage = reportStorage;
+        }
+
+        [HttpGet("generate-pdf")]
+        public async Task<IActionResult> GeneratePdf(string reportUrl)
+        {
+            byte[] reportData = _reportStorage.GetData(reportUrl);
+
+            // Load the report from the byte array
+            using (MemoryStream ms = new MemoryStream(reportData))
+            {
+                XtraReport report = XtraReport.FromStream(ms, true);
+
+                using (MemoryStream pdfStream = new MemoryStream())
+                {
+                    try
+                    {
+                        if (report.DataSource == null)
+                        {
+                            var m = "The report's DataSource is null.";
+                        }
+                        await report.CreateDocumentAsync();
+
+                        await report.ExportToPdfAsync(pdfStream);
+                    }
+                    catch(Exception e)
+                    {
+                        var mess = e.Message;
+                    }
+                    return File(pdfStream.ToArray(), "application/pdf", "GeneratedReport.pdf");
+                }
+            }
+        }
+
+    }
+}

+ 10 - 0
MTWorkHR.API/MTWorkHR.API.csproj

@@ -11,6 +11,7 @@
 
 
   <ItemGroup>
   <ItemGroup>
     <PackageReference Include="Azure.Storage.Blobs" Version="12.20.0" />
     <PackageReference Include="Azure.Storage.Blobs" Version="12.20.0" />
+    <PackageReference Include="DevExpress.AspNetCore.Reporting" Version="24.1.6" />
     <PackageReference Include="dotenv.net" Version="3.2.0" />
     <PackageReference Include="dotenv.net" Version="3.2.0" />
     <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.8" />
     <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.8" />
     <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
     <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
@@ -28,4 +29,13 @@
     <ProjectReference Include="..\MTWorkHR.Infrastructure\MTWorkHR.Infrastructure.csproj" />
     <ProjectReference Include="..\MTWorkHR.Infrastructure\MTWorkHR.Infrastructure.csproj" />
   </ItemGroup>
   </ItemGroup>
 
 
+  <ItemGroup>
+    <Compile Update="Reports\ContractReport.cs">
+      <SubType>XtraReport</SubType>
+    </Compile>
+    <Compile Update="Reports\EmployeeContract.cs">
+      <SubType>XtraReport</SubType>
+    </Compile>
+  </ItemGroup>
+
 </Project>
 </Project>

+ 20 - 0
MTWorkHR.API/Program.cs

@@ -17,6 +17,11 @@ using Moq;
 
 
 
 
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.DependencyInjection;
+using DevExpress.AspNetCore;
+using DevExpress.XtraCharts;
+using DevExpress.XtraReports.Web.Extensions;
+using DevExpress.AspNetCore.Reporting;
+using MTWorkHR.Infrastructure.Reports;
 using MTWorkHR.API.Chat;
 using MTWorkHR.API.Chat;
 using Microsoft.AspNetCore.SignalR;
 using Microsoft.AspNetCore.SignalR;
 
 
@@ -83,6 +88,20 @@ builder.Services.Configure<ApiBehaviorOptions>(options =>
 {
 {
     options.SuppressModelStateInvalidFilter = true;
     options.SuppressModelStateInvalidFilter = true;
 });
 });
+
+builder.Services.AddDevExpressControls(); // Add DevExpress Reporting controls
+
+//Reporting
+
+
+builder.Services.AddScoped<ReportStorageWebExtension, CustomReportStorageWebExtension>();
+
+builder.Services.ConfigureReportingServices(configurator => {
+    configurator.ConfigureWebDocumentViewer(viewerConfigurator => {
+        viewerConfigurator.UseCachedReportSourceBuilder();
+    });
+});
+
 // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
 // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
 builder.Services.AddEndpointsApiExplorer();
 builder.Services.AddEndpointsApiExplorer();
 //builder.Services.AddSwaggerGen();
 //builder.Services.AddSwaggerGen();
@@ -143,6 +162,7 @@ var app = builder.Build();
 // Configure the HTTP request pipeline.
 // Configure the HTTP request pipeline.
 // if (app.Environment.IsDevelopment())
 // if (app.Environment.IsDevelopment())
 // {
 // {
+app.UseDevExpressControls(); // Required for DevExpress Reporting
 app.UseSwagger();
 app.UseSwagger();
 //app.UseSwaggerUI();
 //app.UseSwaggerUI();
 app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MTWorkHR.API v1"));
 app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MTWorkHR.API v1"));

File diff suppressed because it is too large
+ 1235 - 0
MTWorkHR.API/Reports/ContractReport.Designer.cs


+ 16 - 0
MTWorkHR.API/Reports/ContractReport.cs

@@ -0,0 +1,16 @@
+using DevExpress.XtraReports.UI;
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace MTWorkHR.Infrastructure.Reports
+{
+    public partial class ContractReport : DevExpress.XtraReports.UI.XtraReport
+    {
+        public ContractReport()
+        {
+            InitializeComponent();
+        }
+    }
+}

File diff suppressed because it is too large
+ 123 - 0
MTWorkHR.API/Reports/ContractReport.resx


+ 130 - 0
MTWorkHR.API/Reports/EmployeeContract.Designer.cs

@@ -0,0 +1,130 @@
+namespace MTWorkHR.Infrastructure.Reports
+{
+    partial class EmployeeContract
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary> 
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.components = new System.ComponentModel.Container();
+            DevExpress.DataAccess.Sql.CustomSqlQuery customSqlQuery1 = new DevExpress.DataAccess.Sql.CustomSqlQuery();
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EmployeeContract));
+            this.TopMargin = new DevExpress.XtraReports.UI.TopMarginBand();
+            this.BottomMargin = new DevExpress.XtraReports.UI.BottomMarginBand();
+            this.Detail = new DevExpress.XtraReports.UI.DetailBand();
+            this.xrLabel1 = new DevExpress.XtraReports.UI.XRLabel();
+            this.sqlDataSource1 = new DevExpress.DataAccess.Sql.SqlDataSource(this.components);
+            this.xrLabel2 = new DevExpress.XtraReports.UI.XRLabel();
+            this.xrLabel3 = new DevExpress.XtraReports.UI.XRLabel();
+            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
+            // 
+            // TopMargin
+            // 
+            this.TopMargin.Name = "TopMargin";
+            // 
+            // BottomMargin
+            // 
+            this.BottomMargin.Name = "BottomMargin";
+            // 
+            // Detail
+            // 
+            this.Detail.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
+            this.xrLabel3,
+            this.xrLabel2,
+            this.xrLabel1});
+            this.Detail.Name = "Detail";
+            // 
+            // xrLabel1
+            // 
+            this.xrLabel1.Font = new DevExpress.Drawing.DXFont("Arial", 19F, DevExpress.Drawing.DXFontStyle.Bold);
+            this.xrLabel1.LocationFloat = new DevExpress.Utils.PointFloat(169.1667F, 25F);
+            this.xrLabel1.Multiline = true;
+            this.xrLabel1.Name = "xrLabel1";
+            this.xrLabel1.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
+            this.xrLabel1.SizeF = new System.Drawing.SizeF(349.1666F, 47.16666F);
+            this.xrLabel1.StylePriority.UseFont = false;
+            this.xrLabel1.Text = "Hi my friend";
+            // 
+            // sqlDataSource1
+            // 
+            this.sqlDataSource1.ConnectionName = "LocalConnectionString";
+            this.sqlDataSource1.Name = "sqlDataSource1";
+            customSqlQuery1.Name = "Query";
+            customSqlQuery1.Sql = "select * from contracts";
+            this.sqlDataSource1.Queries.AddRange(new DevExpress.DataAccess.Sql.SqlQuery[] {
+            customSqlQuery1});
+            this.sqlDataSource1.ResultSchemaSerializable = resources.GetString("sqlDataSource1.ResultSchemaSerializable");
+            // 
+            // xrLabel2
+            // 
+            this.xrLabel2.ExpressionBindings.AddRange(new DevExpress.XtraReports.UI.ExpressionBinding[] {
+            new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[BillingCycle]")});
+            this.xrLabel2.LocationFloat = new DevExpress.Utils.PointFloat(45.83333F, 76.99999F);
+            this.xrLabel2.Multiline = true;
+            this.xrLabel2.Name = "xrLabel2";
+            this.xrLabel2.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
+            this.xrLabel2.SizeF = new System.Drawing.SizeF(100F, 23F);
+            this.xrLabel2.Text = "xrLabel2";
+            this.xrLabel2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight;
+            // 
+            // xrLabel3
+            // 
+            this.xrLabel3.ExpressionBindings.AddRange(new DevExpress.XtraReports.UI.ExpressionBinding[] {
+            new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[CreateDate]")});
+            this.xrLabel3.LocationFloat = new DevExpress.Utils.PointFloat(217.5F, 76.99999F);
+            this.xrLabel3.Multiline = true;
+            this.xrLabel3.Name = "xrLabel3";
+            this.xrLabel3.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
+            this.xrLabel3.SizeF = new System.Drawing.SizeF(100F, 23F);
+            this.xrLabel3.Text = "xrLabel3";
+            this.xrLabel3.TextFormatString = "{0:d}";
+            // 
+            // EmployeeContract
+            // 
+            this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
+            this.TopMargin,
+            this.BottomMargin,
+            this.Detail});
+            this.ComponentStorage.AddRange(new System.ComponentModel.IComponent[] {
+            this.sqlDataSource1});
+            this.DataMember = "Query";
+            this.DataSource = this.sqlDataSource1;
+            this.Font = new DevExpress.Drawing.DXFont("Arial", 9.75F);
+            this.Version = "24.1";
+            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
+
+        }
+
+        #endregion
+
+        private DevExpress.XtraReports.UI.TopMarginBand TopMargin;
+        private DevExpress.XtraReports.UI.BottomMarginBand BottomMargin;
+        private DevExpress.XtraReports.UI.DetailBand Detail;
+        private DevExpress.XtraReports.UI.XRLabel xrLabel1;
+        private DevExpress.DataAccess.Sql.SqlDataSource sqlDataSource1;
+        private DevExpress.XtraReports.UI.XRLabel xrLabel3;
+        private DevExpress.XtraReports.UI.XRLabel xrLabel2;
+    }
+}

+ 16 - 0
MTWorkHR.API/Reports/EmployeeContract.cs

@@ -0,0 +1,16 @@
+using DevExpress.XtraReports.UI;
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace MTWorkHR.Infrastructure.Reports
+{
+    public partial class EmployeeContract : DevExpress.XtraReports.UI.XtraReport
+    {
+        public EmployeeContract()
+        {
+            InitializeComponent();
+        }
+    }
+}

File diff suppressed because it is too large
+ 123 - 0
MTWorkHR.API/Reports/EmployeeContract.resx


+ 85 - 0
MTWorkHR.API/Reports/ReportStorageWebExtension.cs

@@ -0,0 +1,85 @@
+using DevExpress.XtraReports.UI;
+using Microsoft.AspNetCore.Hosting;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web;
+
+namespace MTWorkHR.Infrastructure.Reports
+{
+    public class CustomReportStorageWebExtension : DevExpress.XtraReports.Web.Extensions.ReportStorageWebExtension
+    {
+      //  private readonly GlobalInfo globalInfo;
+    //    private readonly AppSettingsConfiguration settings;
+        public CustomReportStorageWebExtension()
+        {
+        }
+        public override byte[] GetData(string url)
+        {
+            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;
+
+                // Create a report instance.
+
+                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);
+                        }
+                    }
+
+                    // Disable the Visible property for all report parameters
+                    // to hide the Parameters Panel in the viewer.
+                    foreach (var parameter in report.Parameters)
+                    {
+                        parameter.Visible = false;
+                    }
+
+                    // If you do not hide the panel, disable the report's RequestParameters property.
+                    // report.RequestParameters = false;
+
+                    using (MemoryStream ms = new MemoryStream())
+                    {
+                        report.SaveLayoutToXml(ms);
+                        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(
+                string.Format("Could not find report '{0}'.", url));
+        }
+        private XtraReport getReport(string reportName)
+        {
+            switch (reportName)
+            {
+                case "ContractReport":
+                    return new ContractReport();
+                case "EmployeeContract":
+                    return new EmployeeContract();
+                default: return null;
+            }
+        }
+    
+    }
+}

+ 1 - 1
MTWorkHR.API/appsettings.json

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

+ 27 - 10
MTWorkHR.Application/Chat/ChatHub.cs

@@ -53,28 +53,36 @@ namespace MTWorkHR.API.Chat
 
 
             try
             try
             {
             {
-                // Get all employees with the "Employee" role
-                var employees = await _userManager.GetUsersInRoleAsync("Employee");
-                var companyEmployees = await _userManager.GetUsersInRoleAsync("Employee");
+                // Get all employees with "Employee" and "Business" roles
+                var employeesInRole = await _userManager.GetUsersInRoleAsync("Employee");
+                var businessInRole = await _userManager.GetUsersInRoleAsync("Business");
+
+                // Combine employee lists if needed and apply unique filtering based on IDs
+                var allEmployees = employeesInRole.Union(businessInRole).DistinctBy(e => e.Id).ToList();
+
                 var CompanyId = GetAuthenticatedCompanyId();
                 var CompanyId = GetAuthenticatedCompanyId();
                 var userId = Context.User.Identities.FirstOrDefault()?.FindFirst("uid")?.Value;
                 var userId = Context.User.Identities.FirstOrDefault()?.FindFirst("uid")?.Value;
 
 
-                // Get all message sender and receiver IDs excluding current user
+                // Get all message sender and receiver IDs excluding the current user
                 var allMessages = await GetAllMessages();
                 var allMessages = await GetAllMessages();
                 var companyUserIds = allMessages
                 var companyUserIds = allMessages
-                    .SelectMany(m => new[] { m.SenderId, m.ReceiverId }).Where(id => id != userId).Distinct().ToHashSet();
+                    .SelectMany(m => new[] { m.SenderId, m.ReceiverId })
+                    .Where(id => id != userId)
+                    .Distinct()
+                    .ToHashSet();
 
 
-                // Filter employees who belong to the same company or have messaged the current user
-                var res = employees.Where(e => e.Id != userId && (e.CompanyId == CompanyId || companyUserIds.Contains(e.Id))).ToList();
-
-                //var mappedEmployees = MapperObject.Mapper.Map<List<ChatUserDto>>(res);
+                // 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
                 // Get online users and map to a dictionary for faster lookups
                 var allConnections = await _unitOfWork.HubConnection.GetAllAsync();
                 var allConnections = await _unitOfWork.HubConnection.GetAllAsync();
                 var onlineUsers = allConnections.Item1.ToDictionary(c => c.UserId, c => c.SignalrId);
                 var onlineUsers = allConnections.Item1.ToDictionary(c => c.UserId, c => c.SignalrId);
 
 
                 // Retrieve last message data for each employee
                 // Retrieve last message data for each employee
-                foreach (var emp in res)
+                foreach (var emp in employeesToChat)
                 {
                 {
                     var onlineSignalrId = onlineUsers.TryGetValue(emp.Id, out var signalrId) ? signalrId : null;
                     var onlineSignalrId = onlineUsers.TryGetValue(emp.Id, out var signalrId) ? signalrId : null;
                     var isOnline = onlineSignalrId != null;
                     var isOnline = onlineSignalrId != null;
@@ -183,6 +191,15 @@ namespace MTWorkHR.API.Chat
         //----------------------------------------------------------------------
         //----------------------------------------------------------------------
         //----------------------------------------------------------------------
         //----------------------------------------------------------------------
         //----------------------------------------------------------------------
         //----------------------------------------------------------------------
+        public async Task<bool> MarkAsSeen(long messageId)
+        {
+            //var userId = Context.User.Identities.FirstOrDefault().FindFirst("uid")?.Value;
+            var message = await _unitOfWork.ChatMessage.GetByIdAsync(messageId);
+            message.IsSeen = true;
+            await _unitOfWork.CompleteAsync();
+
+            return true;
+        }
 
 
         //Simple Test Method
         //Simple Test Method
         public async Task SendMessageAll(string user, string message)
         public async Task SendMessageAll(string user, string message)

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

@@ -24,6 +24,8 @@ namespace MTWorkHR.Application.Models
         public string Email { get; set; }
         public string Email { get; set; }
 
 
         public string PassportNumber { get; set; }
         public string PassportNumber { get; set; }
+        public DateTime? PassportExpiryDate { get; set; }
+
         public string? FavoriteName { get; set; }
         public string? FavoriteName { get; set; }
 
 
         public string PhoneNumber { get; set; }
         public string PhoneNumber { get; set; }
@@ -40,6 +42,7 @@ namespace MTWorkHR.Application.Models
         public int? JobTitleId { get; set; }
         public int? JobTitleId { get; set; }
         public int? IndustryId { get; set; }
         public int? IndustryId { get; set; }
         public int? CountryId { get; set; }
         public int? CountryId { get; set; }
+        public int? NationalityId { get; set; }
         public string? QualificationName { get; set; }
         public string? QualificationName { get; set; }
         public string? UniversityName { get; set; }
         public string? UniversityName { get; set; }
         public string? JobTitleName { get; set; }
         public string? JobTitleName { get; set; }

+ 3 - 0
MTWorkHR.Application/Dtos/Identity/UserUpdateDto.cs

@@ -19,6 +19,8 @@ namespace MTWorkHR.Application.Models
         public string Email { get; set; }
         public string Email { get; set; }
 
 
         public string PassportNumber { get; set; }
         public string PassportNumber { get; set; }
+        public DateTime? PassportExpiryDate { get; set; }
+
         public string? FavoriteName { get; set; }
         public string? FavoriteName { get; set; }
 
 
         public string PhoneNumber { get; set; }
         public string PhoneNumber { get; set; }
@@ -35,6 +37,7 @@ namespace MTWorkHR.Application.Models
         public int? JobTitleId { get; set; }
         public int? JobTitleId { get; set; }
         public int? IndustryId { get; set; }
         public int? IndustryId { get; set; }
         public int? CountryId { get; set; }
         public int? CountryId { get; set; }
+        public int? NationalityId { get; set; }
         public string? QualificationName { get; set; }
         public string? QualificationName { get; set; }
         public string? UniversityName { get; set; }
         public string? UniversityName { get; set; }
         public string? JobTitleName { get; set; }
         public string? JobTitleName { get; set; }

+ 22 - 0
MTWorkHR.Application/Dtos/Lookup/NationalityDto.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 Countries.NET;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Application.Models
+{
+    public class NationalityDto :EntityDto
+    {
+        public string NameAr { get; set; }
+        public string NameEn { get; set; }
+        public long? CountryId { get; set; }
+        public string? CountryCode { get; set; }
+
+    }
+}

+ 5 - 1
MTWorkHR.Application/Dtos/User/CompanyDto.cs

@@ -15,8 +15,12 @@ namespace MTWorkHR.Application.Models
 
 
         public string CRNumber { get; set; } //Commercial Registration
         public string CRNumber { get; set; } //Commercial Registration
         public string? UserId { get; set; }
         public string? UserId { get; set; }
+        public string? PhoneNumber { get; set; }
+        public string? Address { get; set; }
+        public string? Email { get; set; }
+        public long? CountryId { get; set; }
+        public long? CityId { get; set; }
         public UserTypeEnum? UserType { get; set; }
         public UserTypeEnum? UserType { get; set; }
-
         public CompanyUserDto? CompanyUser { get; set; }
         public CompanyUserDto? CompanyUser { get; set; }
         public IFormFile? ProfileImage { get; set; }
         public IFormFile? ProfileImage { get; set; }
         public IFormFile? CommercialRegAttach { get; set; }
         public IFormFile? CommercialRegAttach { get; set; }

+ 6 - 2
MTWorkHR.Application/Services/User/CompanyService.cs

@@ -91,7 +91,7 @@ namespace MTWorkHR.Application.Services
             {
             {
                 throw new AppException(ExceptionEnum.MapperIssue);
                 throw new AppException(ExceptionEnum.MapperIssue);
             }
             }
-
+           
             var company = await _unitOfWork.Company.AddAsync(entity);
             var company = await _unitOfWork.Company.AddAsync(entity);
 
 
             UserCreated.CompanyId = company.Id;
             UserCreated.CompanyId = company.Id;
@@ -103,7 +103,11 @@ namespace MTWorkHR.Application.Services
         public async Task<ApplicationUser> CreateCompanyUser(CompanyDto input)
         public async Task<ApplicationUser> CreateCompanyUser(CompanyDto input)
         {
         {
             var companyUser = MapperObject.Mapper.Map<UserDto>(input.CompanyUser);
             var companyUser = MapperObject.Mapper.Map<UserDto>(input.CompanyUser);
-
+            input.Email = string.IsNullOrEmpty( input.Email)? input.CompanyUser?.Email : input.Email;
+            input.PhoneNumber = string.IsNullOrEmpty(input.PhoneNumber) ? input.CompanyUser?.PhoneNumber: input.PhoneNumber;
+            input.Address = string.IsNullOrEmpty(input.Address) ? input.CompanyUser?.UserAddress?.AddressDesc: input.Address;
+            input.CountryId = input.CountryId!=null && input.CountryId > 0 ?  input.CountryId : input.CompanyUser?.UserAddress?.CountryId;
+            input.CityId = input.CityId != null && input.CityId > 0 ?  input.CityId : input.CompanyUser?.UserAddress?.CityId;
             //UserDto companyUser = new UserDto
             //UserDto companyUser = new UserDto
             //{
             //{
             //    UserType = UserTypeEnum.Business,
             //    UserType = UserTypeEnum.Business,

+ 14 - 0
MTWorkHR.Core/Entities/User/Company.cs

@@ -16,5 +16,19 @@ namespace MTWorkHR.Core.Entities
         [Filter]
         [Filter]
         public string CRNumber { get; set; }
         public string CRNumber { get; set; }
         public int TaxNumber { get; set; }
         public int TaxNumber { get; set; }
+        public string PhoneNumber { get; set; }
+        public string Address { get; set; }
+        public string Email { get; set; }
+
+        public long? CountryId { get; set; }
+        [ForeignKey("CountryId")]
+
+        public CountryLookup? Country { get; set; }
+
+        public long? CityId { get; set; }
+        [ForeignKey("CityId")]
+
+        public City? City { get; set; }
+
     }
     }
 }
 }

+ 24 - 0
MTWorkHR.Core/Entities/User/Nationality.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.Core.Entities.Base;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class Nationality : Entity
+    {
+        [Required]
+        [MaxLength(250)]
+        [Filter]
+        public string NameAr { get; set; }
+        [Required]
+        [MaxLength(250)]
+        [Filter]
+        public string NameEn { get; set; }
+        public string? CountryCode { get; set; }
+        public string? CountryId { get; set; }
+    }
+}

File diff suppressed because it is too large
+ 1479 - 0
MTWorkHR.Infrastructure/Configurations/NationalityConfiguration.cs


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

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

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

@@ -18,6 +18,7 @@ namespace MTWorkHR.Infrastructure.Entities
         public int UserType { get; set; }
         public int UserType { get; set; }
         public string? FavoriteName { get; set; }
         public string? FavoriteName { get; set; }
         public string PassportNumber { get; set; }
         public string PassportNumber { get; set; }
+        public DateTime? PassportExpiryDate { get; set; }
         public long? QualificationId { get; set; }
         public long? QualificationId { get; set; }
 
 
         [ForeignKey("QualificationId")]
         [ForeignKey("QualificationId")]
@@ -31,6 +32,10 @@ namespace MTWorkHR.Infrastructure.Entities
         public long? IndustryId { get; set; }
         public long? IndustryId { get; set; }
         [ForeignKey("IndustryId")]
         [ForeignKey("IndustryId")]
         public Industry? Industry { get; set; }
         public Industry? Industry { get; set; }
+        public long? NationalityId { get; set; }
+        [ForeignKey("NationalityId")]
+
+        public Nationality? Nationality { get; set; }
         public long? CountryId { get; set; }
         public long? CountryId { get; set; }
         [ForeignKey("CountryId")]
         [ForeignKey("CountryId")]
 
 
@@ -59,6 +64,7 @@ namespace MTWorkHR.Infrastructure.Entities
         public string? LinkedInLink { get; set; }
         public string? LinkedInLink { get; set; }
         public string? Position { get; set; }
         public string? Position { get; set; }
         public long? CompanyId { get; set; }
         public long? CompanyId { get; set; }
+        public string? CompanyRepresentativeTitle { get; set; }
 
 
         public ICollection<ApplicationRole> UserRoles { get; set; }
         public ICollection<ApplicationRole> UserRoles { get; set; }
         public ICollection<UserAttachment> UserAttachments { get; set; }
         public ICollection<UserAttachment> UserAttachments { get; set; }

+ 17 - 0
MTWorkHR.Infrastructure/MTWorkHR.Infrastructure.csproj

@@ -7,6 +7,12 @@
   </PropertyGroup>
   </PropertyGroup>
 
 
   <ItemGroup>
   <ItemGroup>
+    <None Remove="Reports\ORMDataModel1.xpo" />
+    <None Remove="Reports\ORMDataModel1.xpo.diagram" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="DevExpress.AspNetCore.Reporting" Version="24.1.6" />
     <PackageReference Include="MailKit" Version="4.3.0" />
     <PackageReference Include="MailKit" Version="4.3.0" />
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
     <PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
     <PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
@@ -18,6 +24,7 @@
     </PackageReference>
     </PackageReference>
     <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
     <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
     <PackageReference Include="MimeKit" Version="4.3.0" />
     <PackageReference Include="MimeKit" Version="4.3.0" />
+    <PackageReference Include="QuestPDF" Version="2024.10.2" />
     <PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.8" />
     <PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.8" />
   </ItemGroup>
   </ItemGroup>
 
 
@@ -25,4 +32,14 @@
     <ProjectReference Include="..\MTWorkHR.Core\MTWorkHR.Core.csproj" />
     <ProjectReference Include="..\MTWorkHR.Core\MTWorkHR.Core.csproj" />
   </ItemGroup>
   </ItemGroup>
 
 
+  <ItemGroup>
+    <None Update="appsettings.json">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+
+  <ItemGroup>
+    <Folder Include="Reports\" />
+  </ItemGroup>
+
 </Project>
 </Project>

File diff suppressed because it is too large
+ 5642 - 0
MTWorkHR.Infrastructure/Migrations/20241029101807_altrUserCompany_addNationality.Designer.cs


+ 375 - 0
MTWorkHR.Infrastructure/Migrations/20241029101807_altrUserCompany_addNationality.cs

@@ -0,0 +1,375 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrUserCompany_addNationality : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AddColumn<int>(
+                name: "ContractStatusId",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0);
+
+            migrationBuilder.AddColumn<int>(
+                name: "ContractorTaxResidencyId",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0);
+
+            migrationBuilder.AddColumn<int>(
+                name: "Address",
+                table: "Companies",
+                type: "int",
+                nullable: false,
+                defaultValue: 0);
+
+            migrationBuilder.AddColumn<int>(
+                name: "Email",
+                table: "Companies",
+                type: "int",
+                nullable: false,
+                defaultValue: 0);
+
+            migrationBuilder.AddColumn<int>(
+                name: "PhoneNumber",
+                table: "Companies",
+                type: "int",
+                nullable: false,
+                defaultValue: 0);
+
+            migrationBuilder.AddColumn<string>(
+                name: "CompanyRepresentativeTitle",
+                table: "AspNetUsers",
+                type: "nvarchar(max)",
+                nullable: true);
+
+            migrationBuilder.AddColumn<long>(
+                name: "NationalityId",
+                table: "AspNetUsers",
+                type: "bigint",
+                nullable: true);
+
+            migrationBuilder.AddColumn<DateTime>(
+                name: "PassportExpiryDate",
+                table: "AspNetUsers",
+                type: "datetime2",
+                nullable: true);
+
+            migrationBuilder.CreateTable(
+                name: "Nationalities",
+                columns: table => new
+                {
+                    Id = table.Column<long>(type: "bigint", nullable: false)
+                        .Annotation("SqlServer:Identity", "1, 1"),
+                    NameAr = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
+                    NameEn = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
+                    CountryCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    CountryId = table.Column<string>(type: "nvarchar(max)", nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_Nationalities", x => x.Id);
+                });
+
+            migrationBuilder.UpdateData(
+                table: "AspNetUsers",
+                keyColumn: "Id",
+                keyValue: "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA",
+                columns: new[] { "CompanyRepresentativeTitle", "NationalityId", "PassportExpiryDate" },
+                values: new object[] { null, null, null });
+
+            migrationBuilder.UpdateData(
+                table: "AspNetUsers",
+                keyColumn: "Id",
+                keyValue: "AL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB",
+                columns: new[] { "CompanyRepresentativeTitle", "NationalityId", "PassportExpiryDate" },
+                values: new object[] { null, null, null });
+
+            migrationBuilder.InsertData(
+                table: "Nationalities",
+                columns: new[] { "Id", "CountryCode", "CountryId", "NameAr", "NameEn" },
+                values: new object[,]
+                {
+                    { 1L, "AF", null, "أفغاني", "Afghan" },
+                    { 2L, "AL", null, "ألباني", "Albanian" },
+                    { 3L, "DZ", null, "جزائري", "Algerian" },
+                    { 4L, "AS", null, "أمريكي ساموي", "American Samoan" },
+                    { 5L, "US", null, "أمريكي", "American" },
+                    { 6L, "AD", null, "أندوري", "Andorran" },
+                    { 7L, "AO", null, "أنغولي", "Angolan" },
+                    { 8L, "AI", null, "أنغويلي", "Anguillian" },
+                    { 9L, "AG", null, "أنتيغي", "Antiguan" },
+                    { 10L, "AR", null, "أرجنتيني", "Argentinian" },
+                    { 11L, "AM", null, "أرميني", "Armenian" },
+                    { 12L, "AW", null, "أروبي", "Aruban" },
+                    { 13L, "AU", null, "أسترالي", "Australian" },
+                    { 14L, "AT", null, "نمساوي", "Austrian" },
+                    { 15L, "AZ", null, "أذربيجاني", "Azerbaijani" },
+                    { 16L, "BS", null, "باهامي", "Bahamian" },
+                    { 17L, "BH", null, "بحريني", "Bahraini" },
+                    { 18L, "BD", null, "بنغلاديشي", "Bangladeshi" },
+                    { 19L, "BB", null, "باربادوسي", "Barbadian" },
+                    { 20L, "BY", null, "بيلاروسي", "Belarusian" },
+                    { 21L, "BE", null, "بلجيكي", "Belgian" },
+                    { 22L, "BZ", null, "بليزي", "Belizean" },
+                    { 23L, "BJ", null, "بنيني", "Beninese" },
+                    { 24L, "BT", null, "بوتاني", "Bhutanese" },
+                    { 25L, "BO", null, "بوليفي", "Bolivian" },
+                    { 26L, "BA", null, "بوسني", "Bosnian" },
+                    { 27L, "BR", null, "برازيلي", "Brazilian" },
+                    { 28L, "GB", null, "بريطاني", "British" },
+                    { 29L, "BN", null, "بروني", "Bruneian" },
+                    { 30L, "BG", null, "بلغاري", "Bulgarian" },
+                    { 31L, "BF", null, "بوركيني", "Burkinabe" },
+                    { 32L, "MM", null, "بورمي", "Burmese" },
+                    { 33L, "BI", null, "بوروندي", "Burundian" },
+                    { 34L, "KH", null, "كمبودي", "Cambodian" },
+                    { 35L, "CM", null, "كاميروني", "Cameroonian" },
+                    { 36L, "CA", null, "كندي", "Canadian" },
+                    { 37L, "CV", null, "الرأس الأخضر", "Cape Verdean" },
+                    { 38L, "CF", null, "أفريقي أوسط", "Central African" },
+                    { 39L, "TD", null, "تشادي", "Chadian" },
+                    { 40L, "CL", null, "تشيلي", "Chilean" },
+                    { 41L, "CN", null, "صيني", "Chinese" },
+                    { 42L, "CO", null, "كولومبي", "Colombian" },
+                    { 43L, "KM", null, "قُمُري", "Comorian" },
+                    { 44L, "CG", null, "كونغولي", "Congolese" },
+                    { 45L, "CR", null, "كوستاريكي", "Costa Rican" },
+                    { 46L, "HR", null, "كرواتي", "Croatian" },
+                    { 47L, "CU", null, "كوبي", "Cuban" },
+                    { 48L, "CY", null, "قبرصي", "Cypriot" },
+                    { 49L, "CZ", null, "تشيكي", "Czech" },
+                    { 50L, "DK", null, "دنماركي", "Danish" },
+                    { 51L, "DJ", null, "جيبوتي", "Djiboutian" },
+                    { 52L, "DO", null, "دومينيكاني", "Dominican" },
+                    { 53L, "NL", null, "هولندي", "Dutch" },
+                    { 54L, "EC", null, "إكوادوري", "Ecuadorean" },
+                    { 55L, "EG", null, "مصري", "Egyptian" },
+                    { 56L, "AE", null, "إماراتي", "Emirati" },
+                    { 57L, "GQ", null, "غيني استوائي", "Equatorial Guinean" },
+                    { 58L, "ER", null, "إريتيري", "Eritrean" },
+                    { 59L, "EE", null, "إستوني", "Estonian" },
+                    { 60L, "ET", null, "أثيوبي", "Ethiopian" },
+                    { 61L, "FJ", null, "فيجي", "Fijian" },
+                    { 62L, "FI", null, "فنلندي", "Finnish" },
+                    { 63L, "FR", null, "فرنسي", "French" },
+                    { 64L, "GA", null, "غابوني", "Gabonese" },
+                    { 65L, "GM", null, "غامبي", "Gambian" },
+                    { 66L, "GE", null, "جورجي", "Georgian" },
+                    { 67L, "DE", null, "ألماني", "German" },
+                    { 68L, "GH", null, "غاني", "Ghanaian" },
+                    { 69L, "GI", null, "جبل طارق", "Gibraltarian" },
+                    { 70L, "GR", null, "يوناني", "Greek" },
+                    { 71L, "GL", null, "جرينلندي", "Greenlandic" },
+                    { 72L, "GD", null, "غرينادي", "Grenadian" },
+                    { 73L, "GU", null, "غوامي", "Guamanian" },
+                    { 74L, "GT", null, "غواتيمالي", "Guatemalan" },
+                    { 75L, "GN", null, "غيني", "Guinean" },
+                    { 76L, "GW", null, "غيني", "Guinean" },
+                    { 77L, "GY", null, "غياني", "Guyanese" },
+                    { 78L, "HT", null, "هايتي", "Haitian" },
+                    { 79L, "HN", null, "هندوراسي", "Honduran" },
+                    { 80L, "HK", null, "هونغ كونغي", "Hong Konger" },
+                    { 81L, "HU", null, "مجري", "Hungarian" },
+                    { 82L, "IS", null, "آيسلندي", "Icelander" },
+                    { 83L, "IN", null, "هندي", "Indian" },
+                    { 84L, "ID", null, "إندونيسي", "Indonesian" },
+                    { 85L, "IR", null, "إيراني", "Iranian" },
+                    { 86L, "IQ", null, "عراقي", "Iraqi" },
+                    { 87L, "IE", null, "إيرلندي", "Irish" },
+                    { 89L, "IT", null, "إيطالي", "Italian" },
+                    { 90L, "JM", null, "جامايكي", "Jamaican" },
+                    { 91L, "JP", null, "ياباني", "Japanese" },
+                    { 92L, "JE", null, "جيرسي", "Jersey" },
+                    { 93L, "JO", null, "أردني", "Jordanian" },
+                    { 94L, "KZ", null, "كازاخي", "Kazakh" },
+                    { 95L, "KE", null, "كيني", "Kenyan" },
+                    { 96L, "KI", null, "كيريباتي", "Kiribati" },
+                    { 97L, "KP", null, "كوري شمالي", "North Korean" },
+                    { 98L, "KR", null, "كوري جنوبي", "South Korean" },
+                    { 99L, "KW", null, "كويتي", "Kuwaiti" },
+                    { 100L, "KG", null, "قرغيزستاني", "Kyrgyzstani" },
+                    { 101L, "LA", null, "لاوي", "Lao" },
+                    { 102L, "LV", null, "لاتفي", "Latvian" },
+                    { 103L, "LB", null, "لبناني", "Lebanese" },
+                    { 104L, "LS", null, "ليسوتو", "Lesotho" },
+                    { 105L, "LR", null, "ليبيريي", "Liberian" },
+                    { 106L, "LY", null, "ليبي", "Libyan" },
+                    { 107L, "LI", null, "ليختنشتايني", "Liechtensteiner" },
+                    { 108L, "LT", null, "ليتواني", "Lithuanian" },
+                    { 109L, "LU", null, "لوكسمبورغي", "Luxembourgish" },
+                    { 110L, "MG", null, "ملغاشي", "Malagasy" },
+                    { 111L, "MW", null, "ملووي", "Malawian" },
+                    { 112L, "MY", null, "ماليزيا", "Malaysian" },
+                    { 113L, "MV", null, "مالديفي", "Maldivian" },
+                    { 114L, "ML", null, "مالي", "Malian" },
+                    { 115L, "MT", null, "مالطي", "Maltese" },
+                    { 116L, "MH", null, "مارشالي", "Marshallese" },
+                    { 117L, "MR", null, "موريتاني", "Mauritanian" },
+                    { 118L, "MU", null, "موريشيوسي", "Mauritian" },
+                    { 119L, "MX", null, "مكسيكي", "Mexican" },
+                    { 120L, "FM", null, "ماكروني", "Micronesian" },
+                    { 121L, "MD", null, "مولدوفي", "Moldovan" },
+                    { 122L, "MC", null, "موناكي", "Monacan" },
+                    { 123L, "MN", null, "منغولي", "Mongolian" },
+                    { 124L, "ME", null, "مونتينيغري", "Montenegrin" },
+                    { 125L, "MA", null, "مغربي", "Moroccan" },
+                    { 126L, "MZ", null, "موزمبيقي", "Mozambican" },
+                    { 127L, "NA", null, "ناميبي", "Namibian" },
+                    { 128L, "NR", null, "نيواروي", "Nauruan" },
+                    { 129L, "NP", null, "نيبالي", "Nepali" },
+                    { 130L, "NL", null, "هولندي", "Dutch" },
+                    { 131L, "NZ", null, "نيوزيلندي", "New Zealander" },
+                    { 132L, "NI", null, "نيكاراغوي", "Nicaraguan" },
+                    { 133L, "NE", null, "نيجيري", "Nigerien" },
+                    { 134L, "NG", null, "نيجيري", "Nigerian" },
+                    { 135L, "MK", null, "مقدوني شمالي", "North Macedonian" },
+                    { 136L, "NO", null, "نرويجي", "Norwegian" },
+                    { 137L, "OM", null, "عماني", "Omani" },
+                    { 138L, "PK", null, "باكستاني", "Pakistani" },
+                    { 139L, "PW", null, "بالاوي", "Palauan" },
+                    { 140L, "PA", null, "بنمي", "Panamanian" },
+                    { 141L, "PG", null, "بابوا غينيا الجديدة", "Papua New Guinean" },
+                    { 142L, "PY", null, "باراغواني", "Paraguayan" },
+                    { 143L, "PE", null, "بيروفي", "Peruvian" },
+                    { 144L, "PH", null, "فلبيني", "Filipino" },
+                    { 145L, "PL", null, "بولندي", "Polish" },
+                    { 146L, "PT", null, "برتغالي", "Portuguese" },
+                    { 147L, "QA", null, "قطري", "Qatari" },
+                    { 148L, "RE", null, "لا ريونيون", "Réunionese" },
+                    { 149L, "RO", null, "روماني", "Romanian" },
+                    { 150L, "RU", null, "روسي", "Russian" },
+                    { 151L, "RW", null, "رواندي", "Rwandan" },
+                    { 152L, "BL", null, "سانت بارتيليمي", "Saint Barthélemy" },
+                    { 153L, "SH", null, "سانت هيلاني", "Saint Helenian" },
+                    { 154L, "KN", null, "سانت كيتس ونيفيس", "Saint Kitts and Nevis" },
+                    { 155L, "LC", null, "سانت لوسيان", "Saint Lucian" },
+                    { 156L, "MF", null, "سانت مارتن", "Saint Martin" },
+                    { 157L, "SX", null, "سانت مارتن", "Sint Maarten" },
+                    { 158L, "WS", null, "سماوي", "Samoan" },
+                    { 159L, "SM", null, "سانماريني", "Sammarinese" },
+                    { 160L, "ST", null, "ساو توماني", "Sao Tomean" },
+                    { 161L, "SA", null, "سعودي", "Saudi" },
+                    { 162L, "SN", null, "سنغالي", "Senegalese" },
+                    { 163L, "RS", null, "صربي", "Serbian" },
+                    { 164L, "SC", null, "سيشلي", "Seychellois" },
+                    { 165L, "SL", null, "سيراليوني", "Sierra Leonean" },
+                    { 166L, "SG", null, "سنغافوري", "Singaporean" },
+                    { 167L, "SK", null, "سلوفاكي", "Slovak" },
+                    { 168L, "SI", null, "سلوفيني", "Slovenian" },
+                    { 169L, "SB", null, "سولوموني", "Solomon Islander" },
+                    { 170L, "SO", null, "صومالي", "Somali" },
+                    { 171L, "ZA", null, "جنوب أفريقي", "South African" },
+                    { 172L, "SS", null, "جنوب سوداني", "South Sudanese" },
+                    { 173L, "ES", null, "إسباني", "Spanish" },
+                    { 174L, "LK", null, "سريلانكي", "Sri Lankan" },
+                    { 175L, "SD", null, "سوداني", "Sudanese" },
+                    { 176L, "SR", null, "سورينامي", "Surinamese" },
+                    { 177L, "SZ", null, "سواتي", "Swazi" },
+                    { 178L, "SE", null, "سويدي", "Swedish" },
+                    { 179L, "CH", null, "سويسري", "Swiss" },
+                    { 180L, "SY", null, "سوري", "Syrian" },
+                    { 181L, "TW", null, "تايواني", "Taiwanese" },
+                    { 182L, "TJ", null, "طاجيكي", "Tajik" },
+                    { 183L, "TZ", null, "تنزاني", "Tanzanian" },
+                    { 184L, "TH", null, "تايلندي", "Thai" },
+                    { 185L, "TL", null, "تيموري", "Timorese" },
+                    { 186L, "TG", null, "توغولي", "Togolese" },
+                    { 187L, "TK", null, "توكلاوي", "Tokelauan" },
+                    { 188L, "TO", null, "تونغي", "Tongan" },
+                    { 189L, "TT", null, "ترينيدادي", "Trinidadian" },
+                    { 190L, "TN", null, "تونسي", "Tunisian" },
+                    { 191L, "TR", null, "تركي", "Turkish" },
+                    { 192L, "TM", null, "تركماني", "Turkmen" },
+                    { 193L, "TC", null, "تركي وكايكوسي", "Turks and Caicos Islander" },
+                    { 194L, "TV", null, "توفالي", "Tuvaluan" },
+                    { 195L, "UG", null, "أوغندي", "Ugandan" },
+                    { 196L, "UA", null, "أوكراني", "Ukrainian" },
+                    { 197L, "AE", null, "إماراتي", "Emirati" },
+                    { 198L, "GB", null, "بريطاني", "British" },
+                    { 199L, "US", null, "أمريكي", "American" },
+                    { 200L, "UY", null, "أوروغواي", "Uruguayan" },
+                    { 201L, "UZ", null, "أوزبكي", "Uzbek" },
+                    { 202L, "VU", null, "فانواتي", "Vanuatuan" },
+                    { 203L, "VE", null, "فنزويلي", "Venezuelan" },
+                    { 204L, "VN", null, "فيتنامي", "Vietnamese" },
+                    { 205L, "WF", null, "واليس وفوتونا", "Wallis and Futuna" },
+                    { 206L, "YE", null, "يمني", "Yemeni" },
+                    { 207L, "ZM", null, "زامبي", "Zambian" },
+                    { 208L, "ZW", null, "زيمبابوي", "Zimbabwean" }
+                });
+
+            migrationBuilder.CreateIndex(
+                name: "IX_AspNetUsers_NationalityId",
+                table: "AspNetUsers",
+                column: "NationalityId");
+
+            migrationBuilder.AddForeignKey(
+                name: "FK_AspNetUsers_Nationalities_NationalityId",
+                table: "AspNetUsers",
+                column: "NationalityId",
+                principalTable: "Nationalities",
+                principalColumn: "Id");
+            var sqlStm = @"update Nationalities set CountryId = (select top 1 id from CountryLookups where UPPER(CountryCode)=UPPER(code))";
+            migrationBuilder.Sql(sqlStm);
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropForeignKey(
+                name: "FK_AspNetUsers_Nationalities_NationalityId",
+                table: "AspNetUsers");
+
+            migrationBuilder.DropTable(
+                name: "Nationalities");
+
+            migrationBuilder.DropIndex(
+                name: "IX_AspNetUsers_NationalityId",
+                table: "AspNetUsers");
+
+            migrationBuilder.DropColumn(
+                name: "ContractStatusId",
+                table: "Contracts");
+
+            migrationBuilder.DropColumn(
+                name: "ContractorTaxResidencyId",
+                table: "Contracts");
+
+            migrationBuilder.DropColumn(
+                name: "Address",
+                table: "Companies");
+
+            migrationBuilder.DropColumn(
+                name: "Email",
+                table: "Companies");
+
+            migrationBuilder.DropColumn(
+                name: "PhoneNumber",
+                table: "Companies");
+
+            migrationBuilder.DropColumn(
+                name: "CompanyRepresentativeTitle",
+                table: "AspNetUsers");
+
+            migrationBuilder.DropColumn(
+                name: "NationalityId",
+                table: "AspNetUsers");
+
+            migrationBuilder.DropColumn(
+                name: "PassportExpiryDate",
+                table: "AspNetUsers");
+        }
+    }
+}

File diff suppressed because it is too large
+ 5663 - 0
MTWorkHR.Infrastructure/Migrations/20241030125620_altrCompanyTbl.Designer.cs


+ 129 - 0
MTWorkHR.Infrastructure/Migrations/20241030125620_altrCompanyTbl.cs

@@ -0,0 +1,129 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrCompanyTbl : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+          
+
+            migrationBuilder.AlterColumn<string>(
+                name: "PhoneNumber",
+                table: "Companies",
+                type: "nvarchar(max)",
+                nullable: false,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.AlterColumn<string>(
+                name: "Email",
+                table: "Companies",
+                type: "nvarchar(max)",
+                nullable: false,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.AlterColumn<string>(
+                name: "Address",
+                table: "Companies",
+                type: "nvarchar(max)",
+                nullable: false,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.AddColumn<long>(
+                name: "CityId",
+                table: "Companies",
+                type: "bigint",
+                nullable: true);
+
+            migrationBuilder.AddColumn<long>(
+                name: "CountryId",
+                table: "Companies",
+                type: "bigint",
+                nullable: true);
+
+            migrationBuilder.CreateIndex(
+                name: "IX_Companies_CityId",
+                table: "Companies",
+                column: "CityId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_Companies_CountryId",
+                table: "Companies",
+                column: "CountryId");
+
+            migrationBuilder.AddForeignKey(
+                name: "FK_Companies_Cities_CityId",
+                table: "Companies",
+                column: "CityId",
+                principalTable: "Cities",
+                principalColumn: "Id");
+
+            migrationBuilder.AddForeignKey(
+                name: "FK_Companies_CountryLookups_CountryId",
+                table: "Companies",
+                column: "CountryId",
+                principalTable: "CountryLookups",
+                principalColumn: "Id");
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropForeignKey(
+                name: "FK_Companies_Cities_CityId",
+                table: "Companies");
+
+            migrationBuilder.DropForeignKey(
+                name: "FK_Companies_CountryLookups_CountryId",
+                table: "Companies");
+
+            migrationBuilder.DropIndex(
+                name: "IX_Companies_CityId",
+                table: "Companies");
+
+            migrationBuilder.DropIndex(
+                name: "IX_Companies_CountryId",
+                table: "Companies");
+
+            migrationBuilder.DropColumn(
+                name: "CityId",
+                table: "Companies");
+
+            migrationBuilder.DropColumn(
+                name: "CountryId",
+                table: "Companies");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "PhoneNumber",
+                table: "Companies",
+                type: "int",
+                nullable: false,
+                oldClrType: typeof(string),
+                oldType: "nvarchar(max)");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "Email",
+                table: "Companies",
+                type: "int",
+                nullable: false,
+                oldClrType: typeof(string),
+                oldType: "nvarchar(max)");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "Address",
+                table: "Companies",
+                type: "int",
+                nullable: false,
+                oldClrType: typeof(string),
+                oldType: "nvarchar(max)");
+
+        }
+    }
+}

File diff suppressed because it is too large
+ 5698 - 0
MTWorkHR.Infrastructure/Migrations/20241103150423_altrRoleBusiness.Designer.cs


+ 32 - 0
MTWorkHR.Infrastructure/Migrations/20241103150423_altrRoleBusiness.cs

@@ -0,0 +1,32 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrRoleBusiness : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+           
+            migrationBuilder.InsertData(
+                table: "AspNetRoles",
+                columns: new[] { "Id", "ConcurrencyStamp", "CreateDate", "CreateUser", "DeleteUserId", "IsAdmin", "IsDeleted", "Name", "NormalizedName", "UpdateDate", "UpdateUser" },
+                values: new object[] { "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110", null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), null, null, false, false, "Business", "BUSINESS", null, null });
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+         
+
+            migrationBuilder.DeleteData(
+                table: "AspNetRoles",
+                keyColumn: "Id",
+                keyValue: "BS5B3B92-2311-48F8-9DEC-F9FAEF1F2110");
+        }
+    }
+}

File diff suppressed because it is too large
+ 1847 - 271
MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs


+ 14 - 0
MTWorkHR.Infrastructure/appsettings.json

@@ -0,0 +1,14 @@
+{
+  "connectionStrings": {
+    "localhost_MTWorkHRDB_Connection": "data source=localhost;integrated security=True;initial catalog=MTWorkHRDB;Encrypt=False;MultipleActiveResultSets=true"
+
+  },
+  "exclude": [
+    "**/bin",
+    "**/bower_components",
+    "**/jspm_packages",
+    "**/node_modules",
+    "**/obj",
+    "**/platforms"
+  ]
+}