Browse Source

fix repeated ExceptionEnum

zinab_elgendy 2 months ago
parent
commit
03b923f436

+ 4 - 4
MTWorkHR.API/appsettings.Development.json

@@ -29,10 +29,10 @@
   },
   "MailSettings": {
     "ApiKey": "SendGrid-Key",
-    "FromAddress": "eng_z@live.com",
+    "FromAddress": "Aamuarzaa@gmail.com",
     "FromName": "Hr Management System",
-    "Password": "111111111111",
-    "Host": "smtp-mail.outlook.com",
+    "Password": "Muath&111",
+    "Host": "smtp.gmail.com",
     "Port": 587,
     "TemplatePath": "C:\\Attachment\\MailTemp\\EmailTemplate.html"
   },
@@ -40,7 +40,7 @@
     "Length": 4,
     "ExpirePeriodInMinutes": 3000,
     "SendEmail": true,
-    "AllowZeros": false,
+    "AllowZeros": true,
     "MessageBody": "Dear User, Your OTP is {0}. Use this passcode to proceed.",
     "MessageSubject": "OTP"
   },

+ 4 - 4
MTWorkHR.API/appsettings.json

@@ -31,10 +31,10 @@
   },
   "MailSettings": {
     "ApiKey": "SendGrid-Key",
-    "FromAddress": "eng_z@live.com",
+    "FromAddress": "Aamuarzaa@gmail.com",
     "FromName": "Hr Management System",
-    "Password": "111111111111",
-    "Host": "smtp-mail.outlook.com",
+    "Password": "Muath&111",
+    "Host": "smtp.gmail.com",
     "Port": 587,
     "TemplatePath": "C:\\Attachment\\MailTemp\\EmailTemplate.html"
   },
@@ -42,7 +42,7 @@
     "Length": 4,
     "ExpirePeriodInMinutes": 3000,
     "SendEmail": true,
-    "AllowZeros": false,
+    "AllowZeros": true,
     "MessageBody": "Dear User, Your OTP is {0}. Use this passcode to proceed.",
     "MessageSubject": "OTP"
   },

+ 2 - 2
MTWorkHR.Application/ApplicationServiceRegistration.cs

@@ -22,8 +22,8 @@ namespace MTWorkHR.Application
 
             services.AddScoped<IAuthService, AuthService>();
             services.AddScoped<IUserService, UserService>();
-            //services.AddTransient<IFileService, FileService>();
-            services.AddScoped<IFileService, BlobFileService>();
+            services.AddTransient<IFileService, FileService>();
+          //  services.AddScoped<IFileService, BlobFileService>();
             services.AddScoped<IProjectService, ProjectService>();
             services.AddScoped<IUserTaskService, UserTaskService>();
             services.AddScoped<IUserTaskAttachmentService, UserTaskAttachmentService>();

+ 16 - 6
MTWorkHR.Application/Services/User/AttendanceService.cs

@@ -82,16 +82,17 @@ namespace MTWorkHR.Application.Services
             //      AttendanceDate = g.Key.AttendanceDate, 
             //      TotalHours = g.Sum(s=> s.TotalHours) 
             //  }).ToList();
-
-            foreach (var item in list)
+            var employeesList = list.Select(a => a.UserId).Distinct();
+            Dictionary<string, UserBasicInfoDto> employeeDictList = new Dictionary<string, UserBasicInfoDto>();
+            foreach (var RequestingEmployeeId in employeesList)
             {
-                if (item.UserId != null)
+                if (RequestingEmployeeId != null)
                 {
-                    var user = await _userService.GetUserWithAttachmentById(item.UserId);
+                    var user = await _userService.GetUserWithAttachmentById(RequestingEmployeeId);
                     if (user != null)
                     {
                         var entitiy = MapperObject.Mapper.Map<UserBasicInfoDto>(user);
-                        item.Employee = entitiy;
+                        //item.Employee = entitiy;
                         var attach = user.UserAttachments?.FirstOrDefault(a => a.AttachmentTypeId == 9);
                         if (attach != null)
                             using (var stream = new MemoryStream(attach.Content))
@@ -107,11 +108,20 @@ namespace MTWorkHR.Application.Services
                                     FileName = file.FileName
                                 };
                                 file.ContentDisposition = cd.ToString();
-                                item.Employee.ProfileImage = file;
+                                entitiy.ProfileImage = file;
+                                
                             }
+                        employeeDictList.Add(RequestingEmployeeId, entitiy);
                     }
                 }
             }
+            foreach (var item in list)
+            {
+                UserBasicInfoDto? employee;
+                bool success = employeeDictList.TryGetValue(item.UserId, out employee);
+               // var employee2 = employeeDictList[item.UserId];
+                if(success && employee != null) item.Employee = employee;
+            }
             var response = new PagingResultDto<AttendanceDto>
             {
                 Result = list ,

+ 3 - 6
MTWorkHR.Core/Global/AppExceptions.cs

@@ -22,11 +22,8 @@ namespace MTWorkHR.Core.Global
             {10, "Record delete failed!" },
             {11, "Record name already existed" },
             {12, "Record email already existed" },
-            {13, "Tenancy name already existed" },
-            {14, "Tenant expected!" },
-            {15, "Tenant cannot be zero!" },
-            {16, "Attachments Required" },
-            {14, "Could Not Move Files" },
+            {13, "Attachment Required" },
+             {14, "Could Not Move Files" },
             {15, "Mapper Issue" },
             {16, "InCorrect File Length" },
 			{17, "Wrong or expired OTP" },
@@ -39,7 +36,7 @@ namespace MTWorkHR.Core.Global
             {24, "Email Not Exist" },
             {25, "Phone Already Exist" },
             {26, "User Not Exist" },
-            {26, "User already checked in" },
+            {27, "User already checked in" },
 
         };
     }