Procházet zdrojové kódy

SearchEmployee new filters

zinab_elgendy před 4 měsíci
rodič
revize
3b9ee31a40

+ 1 - 1
MTWorkHR.API/Controllers/UserController.cs

@@ -71,7 +71,7 @@ namespace MTWorkHR.API.Controllers
 
         [HttpGet("GetBlobFile")]
         [ProducesResponseType(StatusCodes.Status200OK)]
-        public async Task<ActionResult> GetBlobFile([FromBody] string filePath)
+        public async Task<ActionResult> GetBlobFile([FromQuery] string filePath)
         {
             var res = await _userService.Download(filePath);
             return File(res.Content, res.ContentType);

+ 1 - 1
MTWorkHR.API/Program.cs

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

+ 1 - 1
MTWorkHR.Application/Dtos/Identity/UserAllDto.cs

@@ -32,7 +32,7 @@ namespace MTWorkHR.Application.Models
         public long? IndustryId { get; set; }
         public long? CountryId { get; set; }
         public bool IsStopped { get; set; }
-
+        public string? Position { get; set; }
         public long? CompanyId { get; set; }
         public UserTypeEnum UserType { get; set; }
 

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

@@ -48,6 +48,7 @@ namespace MTWorkHR.Application.Models
 
         public decimal TaxNumber { get; set; }
         public decimal IncomeTaxValue { get; set; }
+        public string? Position { get; set; }
         public long? CompanyId { get; set; }
 
         public IFormFile? ProfileImage { get; set; }

+ 1 - 1
MTWorkHR.Application/Dtos/Identity/UserUpdateDto.cs

@@ -40,9 +40,9 @@ namespace MTWorkHR.Application.Models
         public string? JobTitleName { get; set; }
         public string? IndustryName { get; set; }
         public string? CountryName { get; set; }
-
         public decimal TaxNumber { get; set; }
         public decimal IncomeTaxValue { get; set; }
+        public string? Position { get; set; }
         public long? CompanyId { get; set; }
         public IFormFile? ProfileImage { get; set; }
 

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

@@ -14,6 +14,8 @@ namespace MTWorkHR.Application.Models
         public long? JobTitleId { get; set; }
         public long? IndustryId { get; set; }
         public long? CountryId { get; set; }
+        public long? UserTypeId { get; set; }
+        public bool? Employed { get; set; }
 
     }
 }

+ 1 - 1
MTWorkHR.Application/Middlewares/LoggingMiddleware.cs

@@ -75,7 +75,7 @@ namespace MTWorkHR.Application.Middlewares
                 int errorNum = 0;
                 int.TryParse(errorNo, out errorNum); 
                 dynamic logEnitity = Activator.CreateInstance(entityType, new object[] {
-                    actionName, QueryString, bodyStr, DateTime.Now, "",GetLocalIPAddress(), GetServerIp(context), GetUserExternalIp(context), "", "", msg, error?.InnerException?.Message });
+                    controllerName+"/"+actionName, QueryString, bodyStr, DateTime.Now, "",GetLocalIPAddress(), GetServerIp(context), GetUserExternalIp(context), "", "", msg, error?.InnerException?.Message });
 
 
                 //finally call service.create to insert the log

+ 1 - 1
MTWorkHR.Application/Services/Base/FileService.cs

@@ -47,7 +47,7 @@ namespace MTWorkHR.Application.Services
                     }
                 }
                 else
-                    throw new AppException(ExceptionEnum.FileLengthNotCorrect);
+                    throw new AppException(ExceptionEnum.InCorrectFileLength);
 
             }
             return fileNames;

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

@@ -134,14 +134,14 @@ namespace MTWorkHR.Application.Services
 
             if (allocation is null)
             {
-                throw new AppException(ExceptionEnum.RecordNotExist, "You do not have any allocations for this leave type.");
+                throw new AppException(ExceptionEnum.NoVacationBalance, "You do not have any allocations for this leave type.");
             }
             else
             {
                 int daysRequested = (int)(input.EndDate - input.StartDate).TotalDays;
                 if (daysRequested > allocation.NumberOfDays)
                 {
-                    throw new AppException(ExceptionEnum.RecordNotExist, "You do not have enough days for this request");
+                    throw new AppException(ExceptionEnum.NoVacationBalance, "You do not have enough days for this request");
                 }
             }
             var orderRequest = MapperObject.Mapper.Map<OrderRequest>(input);

+ 29 - 14
MTWorkHR.Application/Services/User/UserService.cs

@@ -120,6 +120,7 @@ namespace MTWorkHR.Application.Services
                                 response.ProfileImage = file;
                                 break;
                         }
+                        attach.Content = new byte[0];
                     }
                    
                 }
@@ -162,6 +163,7 @@ namespace MTWorkHR.Application.Services
         {
             var query = _userManager.Users
                 .Include(u => u.Qualification).Include(u => u.JobTitle).Include(u => u.University).Include(u => u.Industry).Include(u => u.Country)
+                .Where(e => _globalInfo.CompanyId == null || e.CompanyId != _globalInfo.CompanyId)
                 .AsQueryable();
 
             if (PagingInputDto.Filter != null)
@@ -173,6 +175,7 @@ namespace MTWorkHR.Application.Services
                     u.FirstName.Contains(filter) ||
                     u.LastName.Contains(filter) ||
                     u.FavoriteName.Contains(filter) ||
+                    u.Position.Contains(filter) ||
                     u.PhoneNumber.Contains(filter));
             }
             if (PagingInputDto.IndustryId != null)
@@ -195,6 +198,18 @@ namespace MTWorkHR.Application.Services
             {
                 query = query.Where(u => u.CountryId == PagingInputDto.CountryId);
             }
+            if (PagingInputDto.UserTypeId != null)
+            {
+                query = query.Where(u => u.UserType == PagingInputDto.UserTypeId);
+            }
+            if (PagingInputDto.Employed != null && PagingInputDto.Employed == true)
+            {
+                query = query.Where(u => u.CompanyId != null);
+            }
+            if (PagingInputDto.Employed != null && PagingInputDto.Employed == false)
+            {
+                query = query.Where(u => u.CompanyId == null);
+            }
 
             var order = query.OrderBy(PagingInputDto.OrderByField + " " + PagingInputDto.OrderType);
 
@@ -229,7 +244,7 @@ namespace MTWorkHR.Application.Services
         public async Task<List<UserAllDto>> GetAllCompanyEmployees()
         {
             var employees = await _userManager.GetUsersInRoleAsync("Employee");
-            var res = employees.Where(e => _globalInfo.CompanyId == null || e.CompanyId == _globalInfo.CompanyId).ToList();
+            var res = employees.Where(e => e.CompanyId == _globalInfo.CompanyId).ToList();
             var response = MapperObject.Mapper.Map<List<UserAllDto>>(res);
 
             return response;
@@ -251,15 +266,15 @@ namespace MTWorkHR.Application.Services
         {
             var emailExists = await _userManager.FindByEmailAsync(input.Email);
             if (emailExists != null)
-                throw new AppException(ExceptionEnum.RecordAlreadyExist);
+                throw new AppException(ExceptionEnum.RecordEmailAlreadyExist);
 
             var phoneExists = await _userManager.FindByAnyAsync(input.PhoneNumber);
             if (phoneExists != null)
-                throw new AppException(ExceptionEnum.RecordAlreadyExist);
+                throw new AppException(ExceptionEnum.RecordPhoneAlreadyExist);
 
             var userExists = await _userManager.FindByAnyAsync(input.UserName);
             if (userExists != null)
-                throw new AppException(ExceptionEnum.RecordAlreadyExist);
+                throw new AppException(ExceptionEnum.RecordNameAlreadyExist);
             //loop for given list of attachment, and move each file from Temp path to Actual path
             //  _fileService.UploadFiles(files);
             if (input.UserAttachments == null )
@@ -377,7 +392,7 @@ namespace MTWorkHR.Application.Services
         {
             var user = await _userManager.FindByIdAsync(input.UserId);
             if (user == null)
-                throw new AppException(ExceptionEnum.RecordNotExist);
+                throw new AppException(ExceptionEnum.UserNotExist);
             var result = await _userManager.ConfirmEmailAsync(user, input.Token);
             return result.Succeeded;
         }
@@ -385,7 +400,7 @@ namespace MTWorkHR.Application.Services
         {
             var user = await _userManager.Users.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id.Equals(userId));
             if (user == null)
-                throw new AppException(ExceptionEnum.RecordNotExist);
+                throw new AppException(ExceptionEnum.UserNotExist);
 
             string code = await _userManager.GeneratePasswordResetTokenAsync(user);
             var route = "auth/ConfirmEmail";
@@ -400,7 +415,7 @@ namespace MTWorkHR.Application.Services
         {
             var user = await _userManager.Users.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id.Equals(userId));
             if (user == null)
-                throw new AppException(ExceptionEnum.RecordNotExist);
+                throw new AppException(ExceptionEnum.UserNotExist);
 
             string token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
             string codeHtmlVersion = HttpUtility.UrlEncode(token);
@@ -420,7 +435,7 @@ namespace MTWorkHR.Application.Services
                 var entity =  _userManager.Users.Include(x => x.UserAttachments).FirstOrDefault(x=> x.Id == input.Id);
 
                 if (entity == null)
-                    throw new AppException(ExceptionEnum.RecordNotExist);
+                    throw new AppException(ExceptionEnum.UserNotExist);
                 if (input.UserAttachments == null)
                     input.UserAttachments = new List<AttachmentDto>();
                 var oldAttachList = entity.UserAttachments;
@@ -510,7 +525,7 @@ namespace MTWorkHR.Application.Services
         {
             var user = await _userManager.Users.IgnoreQueryFilters().FirstOrDefaultAsync(x => x.Id == input.UserId);
             if (user == null)
-                throw new AppException(ExceptionEnum.RecordNotExist);
+                throw new AppException(ExceptionEnum.UserNotExist);
             var purpose = UserManager<ApplicationUser>.ResetPasswordTokenPurpose;
             var result = await _userManager.VerifyUserTokenAsync(user, "Default", purpose, input.Token);
             return !result;
@@ -521,7 +536,7 @@ namespace MTWorkHR.Application.Services
             var user = await _userManager.FindByIdAsync(_globalInfo.UserId);
 
             if (user == null)
-                throw new AppException(ExceptionEnum.RecordNotExist);
+                throw new AppException(ExceptionEnum.UserNotExist);
 
             if (!await _userManager.CheckPasswordAsync(user, input.OldPassword))
                 throw new AppException(ExceptionEnum.WrongCredentials);
@@ -547,7 +562,7 @@ namespace MTWorkHR.Application.Services
             }
             else
             {
-                throw new AppException(ExceptionEnum.RecordNotExist);
+                throw new AppException(ExceptionEnum.UserNotExist);
             }
         }
         public async Task<bool> VerifyOTP(VerifyOTPDto input)
@@ -560,7 +575,7 @@ namespace MTWorkHR.Application.Services
         {
             var user = await _userManager.Users.IgnoreQueryFilters().FirstOrDefaultAsync(x => x.Id == input.UserId);
             if (user == null)
-                throw new AppException(ExceptionEnum.RecordNotExist);
+                throw new AppException(ExceptionEnum.UserNotExist);
            
             string resetToken = await _userManager.GeneratePasswordResetTokenAsync(user);
 
@@ -582,7 +597,7 @@ namespace MTWorkHR.Application.Services
         {
             var entity = await _userManager.Users.FirstOrDefaultAsync(x => x.Id == userId);
             if (entity == null)
-                throw new AppException(ExceptionEnum.RecordNotExist);
+                throw new AppException(ExceptionEnum.UserNotExist);
             if (!entity.IsStopped)
             {
                 entity.IsStopped = true;
@@ -593,7 +608,7 @@ namespace MTWorkHR.Application.Services
         {
             var entity = await _userManager.Users.FirstOrDefaultAsync(x => x.Id == userId);
             if (entity == null)
-                throw new AppException(ExceptionEnum.RecordNotExist);
+                throw new AppException(ExceptionEnum.UserNotExist);
 
             entity.IsStopped = false;
             entity.AccessFailedCount = 0;

+ 13 - 8
MTWorkHR.Core/Global/AppExceptions.cs

@@ -26,14 +26,19 @@ namespace MTWorkHR.Core.Global
             {14, "Tenant expected!" },
             {15, "Tenant cannot be zero!" },
             {16, "Attachments Required" },
-            {17, "Could Not Move Files" },
-            {18, "Mapper Issue" },
-            {19, "InCorrect File Length" },
-			{20, "Wrong or expired OTP" },
-			{21, "Empty Response" },
-			{22, "Error Sending SMS" },
-            {23, "Invalid Captcha" },
-            {24, "Account Locked" },
+            {14, "Could Not Move Files" },
+            {15, "Mapper Issue" },
+            {16, "InCorrect File Length" },
+			{17, "Wrong or expired OTP" },
+			{18, "Empty Response" },
+			{19, "Error Sending SMS" },
+            {20, "Invalid Captcha" },
+            {21, "Account Locked" },
+            {22, "Invalid File Type" },
+            {23, "No Vacation Balance" },
+            {24, "Email Not Exist" },
+            {25, "Phone Already Exist" },
+            {26, "User Not Exist" },
         };
     }
 }

+ 14 - 15
MTWorkHR.Core/Global/Enum/ExceptionEnum.cs

@@ -20,20 +20,19 @@ namespace MTWorkHR.Core.Global
         RecordDeleteFailed = 10,
         RecordNameAlreadyExist = 11,
         RecordEmailAlreadyExist = 12,
-        TenancyNameAlreadyExist = 13,
-        TenantExpected = 14,
-        TenantNotZero = 15,
-        AttachmentsRequired = 16,
-        CouldNotMoveFiles = 17,
-        MapperIssue = 18,
-        InCorrectFileLength = 19,
-		WrongOTP = 20,
-		EmptyResponse=21,
-		ErrorSendingSMS=22,
-        InvalidCaptcha = 23,
-		AccountLocked = 24,
-        InvalidFileType = 25,
-        FileLengthNotCorrect= 26,
-
+        AttachmentsRequired = 13,
+        CouldNotMoveFiles = 14,
+        MapperIssue = 15,
+        InCorrectFileLength = 16,
+		WrongOTP = 17,
+		EmptyResponse=18,
+		ErrorSendingSMS=19,
+        InvalidCaptcha = 20,
+		AccountLocked = 21,
+        InvalidFileType = 22,
+        NoVacationBalance = 23,
+        EmailNotExist = 24,
+        RecordPhoneAlreadyExist = 25,
+        UserNotExist=26,
     }
 }

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

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

+ 1 - 1
MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs

@@ -31,7 +31,7 @@ namespace MTWorkHR.Infrastructure
             
             services.AddDbContext<HRDataContext>(options =>
                 options.UseSqlServer(
-                    config.ConnectionStrings.MTWorkHRConnectionString  //configuration.GetSection("ConnectionString:MTWorkHRConnectionString").Value
+                    config.ConnectionStrings.LocalConnectionString  //configuration.GetSection("ConnectionString:MTWorkHRConnectionString").Value
                     ));
            
             services.AddIdentity<ApplicationUser, ApplicationRole>().AddEntityFrameworkStores<HRDataContext>().AddDefaultTokenProviders();

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


+ 42 - 0
MTWorkHR.Infrastructure/Migrations/20240825112941_altrUserPosition.cs

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

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

@@ -2764,6 +2764,9 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Property<bool>("PhoneNumberConfirmed")
                         .HasColumnType("bit");
 
+                    b.Property<string>("Position")
+                        .HasColumnType("nvarchar(max)");
+
                     b.Property<long?>("QualificationId")
                         .HasColumnType("bigint");