Bladeren bron

Fix Register file issue by using IFormFile

zinab_elgendy 2 maanden geleden
bovenliggende
commit
56098cea7f

+ 13 - 13
MTWorkHR.Application/Dtos/Identity/UserDto.cs

@@ -12,11 +12,11 @@ namespace MTWorkHR.Application.Models
     public class UserDto
     {
         public string? Id { get; set; }
-       
+
         [Required]
         public string FirstName { get; set; }
         public DateTime DateOfBirth { get; set; }
-       
+
         public string IdNumber { get; set; }
         public string LastName { get; set; }
         [Required]
@@ -36,7 +36,7 @@ namespace MTWorkHR.Application.Models
         [MinLength(6)]
         public string UserName { get; set; }
         public string? Password { get; set; }
-      
+
         public int? QualificationId { get; set; }
         public int? UniversityId { get; set; }
         public int? JobTitleId { get; set; }
@@ -56,19 +56,19 @@ namespace MTWorkHR.Application.Models
         public bool IsCheckedIn { get; set; }
         public bool IsCheckedOut { get; set; }
         public string? ProfileImagePath { get; set; }
-        public FormFile? ProfileImage { get; set; }
-        public FormFile? CVAttach { get; set; }
-        public FormFile? PassportAttach { get; set; }
-        public FormFile? EduCertificateAttach { get; set; }
-        public FormFile? ExperienceCertificateAttach { get; set; }
-        public FormFile? ProfCertificateAttach { get; set; }
+        public IFormFile? ProfileImage { get; set; }
+        public IFormFile? CVAttach { get; set; }
+        public IFormFile? PassportAttach { get; set; }
+        public IFormFile? EduCertificateAttach { get; set; }
+        public IFormFile? ExperienceCertificateAttach { get; set; }
+        public IFormFile? ProfCertificateAttach { get; set; }
         //Company attach
-        public FormFile? CommercialRegAttach { get; set; }
-        public FormFile? TaxDeclarationAttach { get; set; }
-        public FormFile? IdAttach { get; set; }
+        public IFormFile? CommercialRegAttach { get; set; }
+        public IFormFile? TaxDeclarationAttach { get; set; }
+        public IFormFile? IdAttach { get; set; }
 
         public IList<UserRoleDto>? UserRoles { get; set; }
         public IList<AttachmentDto>? UserAttachments { get; set; }
-        public UserAddressDto? UserAddress{ get; set; }
+        public UserAddressDto? UserAddress { get; set; }
     }
 }

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

@@ -48,6 +48,8 @@ namespace MTWorkHR.Application.Models
         public string? Position { get; set; }
         public long? CompanyId { get; set; }
         public string? ProfileImagePath { get; set; }
+        public bool IsCheckedIn { get; set; }
+        public bool IsCheckedOut { get; set; }
         public AttachmentDto? ProfileImage { get; set; }
 
         public AttachmentDto? CVAttach { get; set; }
@@ -56,6 +58,12 @@ namespace MTWorkHR.Application.Models
         public AttachmentDto? ExperienceCertificateAttach { get; set; }
         public AttachmentDto? ProfCertificateAttach { get; set; }
 
+
+        public AttachmentDto? CommercialRegAttach { get; set; }
+        public AttachmentDto? TaxDeclarationAttach { get; set; }
+        public AttachmentDto? IdAttach { get; set; }
+
+
         public IList<UserRoleDto>? UserRoles { get; set; }
         public IList<AttachmentDto>? UserAttachments { get; set; }
         public UserAddressDto? UserAddress { get; set; }

+ 6 - 6
MTWorkHR.Application/Dtos/User/CompanyDto.cs

@@ -25,12 +25,12 @@ namespace MTWorkHR.Application.Models
         public string? CountryName { get; set; }
         public UserTypeEnum? UserType { get; set; }
         public CompanyUserDto? CompanyUser { get; set; }
-        public FormFile? ProfileImage { get; set; }
-        public FormFile? CommercialRegAttach { get; set; }
-        public FormFile? TaxDeclarationAttach { get; set; }
-        public FormFile? PassportAttach { get; set; }
-        public FormFile? ExperienceCertificateAttach { get; set; }
-        public FormFile? IdAttach { get; set; }
+        public IFormFile? ProfileImage { get; set; }
+        public IFormFile? CommercialRegAttach { get; set; }
+        public IFormFile? TaxDeclarationAttach { get; set; }
+        public IFormFile? PassportAttach { get; set; }
+        public IFormFile? ExperienceCertificateAttach { get; set; }
+        public IFormFile? IdAttach { get; set; }
         public string? CreateUser { get; set; }
         public bool IsSuspended { get; set; }
 

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

@@ -15,6 +15,7 @@ namespace MTWorkHR.Application.Services.Interfaces
         Task<List<CompanyDto>> GetAllCompanies();
         Task<CompanyDto> GetById();
         Task<CompanyDto> GetById(long companyId);
+        Task<UpdateCompanyDto> GetByIdForUpdate(long companyId);
         Task Suspend(long companyId);
         Task<UpdateCompanyDto> Update(UpdateCompanyDto input);
 

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

@@ -12,6 +12,8 @@ namespace MTWorkHR.Application.Identity
     {
         Task<PagingResultDto<UserAllDto>> GetAll(UserPagingInputDto PagingInputDto);
         Task<UserDto> GetById(string userId);
+        Task<UserUpdateDto> GetByIdForUpdate(string userId);
+
         Task<UserDto> GetByEmail(string email);
         Task<UserDto> GetById();
         Task<List<UserDto>> GetAllEmployees();

+ 26 - 0
MTWorkHR.Application/Services/User/CompanyService.cs

@@ -77,6 +77,32 @@ namespace MTWorkHR.Application.Services
             return companyResponse;
         }
 
+
+        public async Task<UpdateCompanyDto> GetByIdForUpdate(long companyId)
+        {
+            var companyResponse = new UpdateCompanyDto();
+            if (companyId > 0)
+            {
+                var entity = await _unitOfWork.Company.GetByIdWithAllChildren(companyId);
+                if (entity == null)
+                    throw new AppException(ExceptionEnum.RecordAlreadyExist);
+
+                companyResponse = MapperObject.Mapper.Map<UpdateCompanyDto>(entity);
+                var userDto = await _userService.GetByIdForUpdate(entity.UserId);
+                companyResponse.CommercialRegAttach = userDto.CommercialRegAttach;
+                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;
+        }
+
         public async  Task<List<CompanyDto>> GetAllCompanies()
         {
             var Companys = await _unitOfWork.Company.GetAllAsync();

+ 12 - 10
MTWorkHR.Application/Services/User/UserService.cs

@@ -181,15 +181,15 @@ namespace MTWorkHR.Application.Services
                         case 5:
                             response.ProfCertificateAttach = attach;
                             break;
-                        //case 6:
-                        //    response.CommercialRegAttach = file;
-                        //    break;
-                        //case 7:
-                        //    response.TaxDeclarationAttach = file;
-                        //    break;
-                        //case 8:
-                        //    response.IdAttach = file;
-                        //    break;
+                        case 6:
+                            response.CommercialRegAttach = attach;
+                            break;
+                        case 7:
+                            response.TaxDeclarationAttach = attach;
+                            break;
+                        case 8:
+                            response.IdAttach = attach;
+                            break;
                         case 9:
                             response.ProfileImage = attach;
                             response.ProfileImagePath = attach.FilePath;
@@ -197,7 +197,9 @@ namespace MTWorkHR.Application.Services
                     }
                     attach.Content = new byte[0];
                 }
-
+            var attendance = await _unitOfWork.Attendance.GetAttendanceByUserId(id, DateTime.UtcNow.Date);
+            response.IsCheckedIn = attendance != null && attendance.CheckInTime.HasValue;
+            response.IsCheckedOut = attendance != null && attendance.CheckOutTime.HasValue;
             return response;
         }