2 커밋 7b62a7d24a ... 0b50605141

작성자 SHA1 메시지 날짜
  zinab_elgendy 0b50605141 Merge branch 'master' into TimeZone 3 달 전
  zinab_elgendy eae50fa9c7 timeZone to the header , and convert any time string to the utc 3 달 전

+ 49 - 59
MTWorkHR.API/Swagger/HeaderOperationFilter.cs

@@ -1,4 +1,5 @@
-using Microsoft.OpenApi.Models;
+using Microsoft.OpenApi.Any;
+using Microsoft.OpenApi.Models;
 using Swashbuckle.AspNetCore.SwaggerGen;
 using System;
 using System.Collections.Generic;
@@ -12,58 +13,16 @@ namespace MTWorkHR.API.Swagger
         {
             operation.Parameters ??= new List<OpenApiParameter>();
 
-            //if (context.MethodInfo.GetCustomAttribute(typeof(SwaggerHeaderAttribute)) is SwaggerHeaderAttribute attribute)
-            //{
-            var parameters = new string[] { "lang" };
+            var parameters = new string[] { "lang", "timeZone" };
 
             var existingParams = operation.Parameters.Where(p =>
                 p.In == ParameterLocation.Header && parameters.Contains(p.Name)).ToList();
 
-            foreach (var param in existingParams)// remove description from [FromHeader] argument attribute
+            foreach (var param in existingParams)
             {
                 operation.Parameters.Remove(param);
             }
 
-            //operation.Parameters.Add(new OpenApiParameter
-            //{
-            //    Name = "branch",
-            //    In = ParameterLocation.Header,
-            //    Description = "current acive branch",
-            //    Required = false,
-
-            //    // this schema commented because it is working in swagger but not working in openapi-generator-cli, we use the Content instead below
-            //    //Schema = string.IsNullOrEmpty("")
-            //    //    ? null
-            //    //    : new OpenApiSchema
-            //    //    {
-            //    //        Type = "String",
-            //    //        Default = new OpenApiString("")
-            //    //    },
-            //    Content = new Dictionary<string, OpenApiMediaType>
-            //            {
-            //                {
-            //                    "text/plain", new OpenApiMediaType
-            //                    {
-            //                        Schema = new OpenApiSchema
-            //                        {
-            //                            Type = "string",
-            //                            Required = new HashSet<string>{ "string" },
-            //                            Properties = new Dictionary<string, OpenApiSchema>
-            //                            {
-            //                                {
-            //                                    "string", new OpenApiSchema()
-            //                                    {
-            //                                        Type = "string",
-            //                                        Format = "text"
-            //                                    }
-            //                                }
-            //                            }
-            //                        }
-            //                    }
-            //                }
-            //            }
-            //});
-
             operation.Parameters.Add(new OpenApiParameter
             {
                 Name = "lang",
@@ -71,31 +30,62 @@ namespace MTWorkHR.API.Swagger
                 Description = "current active lang",
                 Required = false,
                 Content = new Dictionary<string, OpenApiMediaType>
+                {
+                    {
+                        "text/plain", new OpenApiMediaType
                         {
+                            Schema = new OpenApiSchema
                             {
-                                "text/plain", new OpenApiMediaType
+                                Type = "string",
+                                Required = new HashSet<string>{ "string" },
+                                Default = new OpenApiString("en"),
+                                Properties = new Dictionary<string, OpenApiSchema>
                                 {
-                                    Schema = new OpenApiSchema
                                     {
-                                        Type = "string",
-                                        Required = new HashSet<string>{ "string" },
-                                        Properties = new Dictionary<string, OpenApiSchema>
+                                        "string", new OpenApiSchema()
                                         {
-                                            {
-                                                "string", new OpenApiSchema()
-                                                {
-                                                    Type = "string",
-                                                    Format = "text"
-                                                }
-                                            }
+                                            Type = "string",
+                                            Format = "text"
                                         }
                                     }
                                 }
                             }
                         }
+                    }
+                }
             });
 
-            //}
+            operation.Parameters.Add(new OpenApiParameter
+            {
+                Name = "timeZone",
+                In = ParameterLocation.Header,
+                Description = "current active time zone",
+                Required = false,
+                Content = new Dictionary<string, OpenApiMediaType>
+                {
+                    {
+                        "text/plain", new OpenApiMediaType
+                        {
+                            Schema = new OpenApiSchema
+                            {
+                                Type = "string",
+                                Required = new HashSet<string>{ "string" },
+                                Default = new OpenApiString("UTC"),
+                                Properties = new Dictionary<string, OpenApiSchema>
+                                {
+                                    {
+                                        "string", new OpenApiSchema()
+                                        {
+                                            Type = "string",
+                                            Format = "text"
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            });
         }
     }
 
@@ -114,4 +104,4 @@ namespace MTWorkHR.API.Swagger
             IsRequired = isRequired;
         }
     }
-}
+}

+ 3 - 3
MTWorkHR.Application/Chat/ChatHub.cs

@@ -254,7 +254,7 @@ namespace MTWorkHR.API.Chat
                         UserId = userId,
                         UserName = userName,
                         SignalrId = currSignalrID,
-                        TimeStamp = DateTime.Now
+                        TimeStamp = DateTime.UtcNow
                     };
                     var newConnection = await _unitOfWork.HubConnection.AddAsync(currUser);
 
@@ -325,7 +325,7 @@ namespace MTWorkHR.API.Chat
                         UserId = userId,
                         UserName = userName,
                         SignalrId = currSignalrID,
-                        TimeStamp = DateTime.Now
+                        TimeStamp = DateTime.UtcNow
                     };
                     var newConnection = await _unitOfWork.HubConnection.AddAsync(currUser);
 
@@ -364,7 +364,7 @@ namespace MTWorkHR.API.Chat
         //        {
         //            UserId = _globalInfo.UserId,
         //            SignalrId = currSignalrID,
-        //            TimeStamp = DateTime.Now
+        //            TimeStamp = DateTime.UtcNow
         //        };
         //        var newConnection = await _unitOfWork.HubConnection.AddAsync(currUser);
 

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

@@ -32,6 +32,7 @@ namespace MTWorkHR.Application.Filters
          //   var allowedBranchs = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("branchs").Value;
            // var branch = context.HttpContext.Request.Headers.FirstOrDefault(x => x.Key == "branch").Value;
             var lang = context.HttpContext.Request.Headers.FirstOrDefault(x => x.Key == "lang").Value;
+            var timeZone = context.HttpContext.Request.Headers.FirstOrDefault(x => x.Key == "timezone").Value;
            // var tenantLong = string.IsNullOrEmpty(tenant.ToString()) ? (long?)null : long.Parse(tenant);
             //var branchLong = string.IsNullOrEmpty(branch.ToString()) ? (long?)null : long.Parse(branch);
             var token = context.HttpContext.Request.Headers.FirstOrDefault(x => x.Key == "Authorization").Value;
@@ -49,7 +50,7 @@ namespace MTWorkHR.Application.Filters
 
 
             var globalInfo = context.HttpContext.RequestServices.GetService<GlobalInfo>();
-            globalInfo.SetValues( userName, userId, companyId !=null && companyId != "" ? long.Parse(companyId) : null , token, lang);
+            globalInfo.SetValues( userName, userId, companyId !=null && companyId != "" ? long.Parse(companyId) : null , token, lang, timeZone);
 
             var userManager = context.HttpContext.RequestServices.GetService<ApplicationUserManager>();
             bool hasAllowAnonymousFlag = context.ActionDescriptor.EndpointMetadata

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

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

+ 1 - 1
MTWorkHR.Application/Services/Auth/AuthService.cs

@@ -94,7 +94,7 @@ namespace MTWorkHR.Identity.Services
                 issuer: _configuration.JwtSettings.Issuer,
                 audience: _configuration.JwtSettings.Audience,
                 claims: claims,
-                expires: DateTime.Now.AddMinutes(_configuration.JwtSettings.DurationInMinutes),
+                expires: DateTime.UtcNow.AddMinutes(_configuration.JwtSettings.DurationInMinutes),
                 signingCredentials: signingCredentials
                 );
             return jwtSecurityToken;

+ 2 - 2
MTWorkHR.Application/Services/Base/OTPService.cs

@@ -53,8 +53,8 @@ namespace MTWorkHR.Application.Services
 			{
 				OTP = oneTimePassword,
 				UserId = userId,
-				CreateDate = DateTime.Now,
-				ExpireDate = DateTime.Now.AddMinutes(appSettings.OTPSettings.ExpirePeriodInMinutes)
+				CreateDate = DateTime.UtcNow,
+				ExpireDate = DateTime.UtcNow.AddMinutes(appSettings.OTPSettings.ExpirePeriodInMinutes)
 			};
 			await unitOfWork.LoginOTP.AddAsync(loginOTP);
 			await unitOfWork.CompleteAsync();

+ 4 - 4
MTWorkHR.Application/Services/Contract/ContractService.cs

@@ -235,7 +235,7 @@ namespace MTWorkHR.Application.Services
 
                 response.TeamList = teamsList;
                 //_____________Get vacation balance
-                var vacationAllocations = await _unitOfWork.OrderAllocation.GetUserAllocations(entity.UserId, 1, 1, entity.Id, DateTime.Now.Year);
+                var vacationAllocations = await _unitOfWork.OrderAllocation.GetUserAllocations(entity.UserId, 1, 1, entity.Id, DateTime.UtcNow.Year);
                 var remainVacations = vacationAllocations;
                 response.RestVacations = remainVacations == null ? entity.VacationDays : remainVacations.NumberOfDays;
                 response.SpentVacations = entity.VacationDays - response.RestVacations;
@@ -254,7 +254,7 @@ namespace MTWorkHR.Application.Services
                 if(entity.ContractTypeId == (int)ContractTypeEnum.EmployeeContract)
                 {
                     var lastInvoice = Invoices.LastOrDefault();
-                    var diffDate = DateTime.Now.Date - entity.StartDate.Value.Date;
+                    var diffDate = DateTime.UtcNow.Date - entity.StartDate.Value.Date;
                     if(lastInvoice != null)
                     {
                         if (entity.BillingCycle == "Monthly")
@@ -297,7 +297,7 @@ namespace MTWorkHR.Application.Services
         {
             try 
             { 
-                await _orderAllocationService.Create(new OrderAllocationDto { ContractId = contractId, EmployeeId = employeeId, OrderTypeId = 1, LeaveTypeId = 1, NumberOfDays = noVacationDays, Period = DateTime.Now.Year });
+                await _orderAllocationService.Create(new OrderAllocationDto { ContractId = contractId, EmployeeId = employeeId, OrderTypeId = 1, LeaveTypeId = 1, NumberOfDays = noVacationDays, Period = DateTime.UtcNow.Year });
                // var orderTypes = await _unitOfWork.OrderType.GetAllAsync();
                // var leaveTypes = await _unitOfWork.LeaveType.GetAllAsync();
                 //foreach (var orderType in orderTypes.Item1)
@@ -313,7 +313,7 @@ namespace MTWorkHR.Application.Services
                 //                OrderTypeId = (int)orderType.Id,
                 //                LeaveTypeId = (int)leaveType.Id,
                 //                NumberOfDays = leaveType.DefaultDays > 0 ? leaveType.DefaultDays : orderType.DefaultDays,
-                //                Period = DateTime.Now.Year
+                //                Period = DateTime.UtcNow.Year
                 //            }
                 //            );
                 //        }

+ 33 - 4
MTWorkHR.Application/Services/User/AttendanceService.cs

@@ -16,6 +16,7 @@ using System.Linq.Dynamic.Core;
 using System.Linq;
 using Microsoft.AspNetCore.Http;
 using MTWorkHR.Core.Entities.Base;
+using System;
 
 namespace MTWorkHR.Application.Services
 {
@@ -174,12 +175,30 @@ namespace MTWorkHR.Application.Services
                 input.AttendanceDate = input.CheckInTime.Value.Date;
             var oldEntity = await _unitOfWork.Attendance.GetAttendanceByUserId(input.UserId, input.AttendanceDate);
             if (oldEntity is null)
-            {
-                var entitiy = MapperObject.Mapper.Map<Attendance>(input);
-                if (entitiy is null)
+            {              
+                if (input.CheckInTime.HasValue)
+                {
+                    if (input.CheckInTime.Value.Kind != DateTimeKind.Utc)
+                    {
+                        var timeZone = TimeZoneInfo.FindSystemTimeZoneById(GlobalInfo.timeZone);
+                        DateTime utcDateTime = TimeZoneInfo.ConvertTimeToUtc(input.CheckInTime.Value, timeZone);
+                        input.CheckInTime = utcDateTime;
+                    }
+                }
+                if (input.CheckOutTime.HasValue)
+                {
+                    if (input.CheckOutTime.Value.Kind != DateTimeKind.Utc)
+                    {
+                        var timeZone = TimeZoneInfo.FindSystemTimeZoneById(GlobalInfo.timeZone);
+                        DateTime utcDateTime = TimeZoneInfo.ConvertTimeToUtc(input.CheckOutTime.Value, timeZone);
+                        input.CheckOutTime = utcDateTime;
+                    }
+                }
+                var entity = MapperObject.Mapper.Map<Attendance>(input);
+                if (entity is null)
                     throw new AppException(ExceptionEnum.MapperIssue);
 
-                var newEntity = await _unitOfWork.Attendance.AddAsync(entitiy);
+                var newEntity = await _unitOfWork.Attendance.AddAsync(entity);
                 var Success = await _unitOfWork.CompleteAsync();
 
                 var response = Mapper.MapperObject.Mapper.Map<AttendanceDto>(newEntity);
@@ -207,6 +226,16 @@ namespace MTWorkHR.Application.Services
                 entity = await _unitOfWork.Attendance.GetAttendanceByUserId(input.UserId, input.AttendanceDate);
             if (entity is null)
                 throw new AppException(ExceptionEnum.RecordNotExist);
+
+            if (input.CheckOutTime.HasValue)
+            {
+                if (input.CheckOutTime.Value.Kind != DateTimeKind.Utc)
+                {
+                    var timeZone = TimeZoneInfo.FindSystemTimeZoneById(GlobalInfo.timeZone);
+                    DateTime utcDateTime = TimeZoneInfo.ConvertTimeToUtc(input.CheckOutTime.Value, timeZone);
+                    input.CheckOutTime = utcDateTime;
+                }
+            }
             entity.CheckOutTime = input.CheckOutTime;
             entity.LeaveType = input.LeaveType;
             entity.LeaveReason = input.LeaveReason;

+ 60 - 2
MTWorkHR.Application/Services/User/MeetingService.cs

@@ -7,6 +7,7 @@ using MTWorkHR.Core.UnitOfWork;
 using MTWorkHR.Application.Services.Interfaces;
 using MTWorkHR.Core.Entities;
 using System.Linq.Dynamic.Core;
+using System.Globalization;
 
 namespace MTWorkHR.Application.Services
 {
@@ -41,6 +42,13 @@ namespace MTWorkHR.Application.Services
                 throw new AppException(ExceptionEnum.MapperIssue);
             }
             entity.MeetingUsers = input.MeetingUserIds?.Select(s => new MeetingUser { AssignedUserId = s, AssignedUserName = _userService.GetUserFullName(s).Result }).ToList();
+            //-----------Time conversion to utc
+            var startTime = DateTime.Parse( entity.StartTime);
+
+            entity.StartTime = ConvertToUtc(entity.StartTime, entity.MeetingDate);
+            entity.EndTime = ConvertToUtc(entity.EndTime, entity.MeetingDate);
+
+
 
             var team = await _unitOfWork.Meeting.AddAsync(entity);
             await _unitOfWork.CompleteAsync();
@@ -60,8 +68,8 @@ namespace MTWorkHR.Application.Services
             entity.Title = input.Title;
             entity.MeetingLink = input.MeetingLink;
             entity.MeetingDate = input.MeetingDate;
-            entity.StartTime = input.StartTime;
-            entity.EndTime = input.EndTime;
+            entity.StartTime = ConvertToUtc(input.StartTime, input.MeetingDate);
+            entity.EndTime = ConvertToUtc(input.EndTime, input.MeetingDate);
             entity.RepeatId = input.RepeatId;
             var oldUsers = entity.MeetingUsers?.Select(s => s.AssignedUserId);
 
@@ -119,6 +127,56 @@ namespace MTWorkHR.Application.Services
             return response;
         }
 
+
+        /// <summary>
+        /// Converts a local time and date to UTC based on the specified time zone.
+        /// </summary>
+        /// <param name="startTime">Time string (e.g., "7:00 PM").</param>
+        /// <param name="date">Date as DateTime (e.g., 2025-04-22).</param>
+        /// <param name="timeZoneId">Time zone ID (e.g., "Eastern Standard Time").</param>
+        /// <returns>UTC DateTime with Kind = DateTimeKind.Utc.</returns>
+        /// <exception cref="ArgumentException">Thrown if timeZoneId or input formats are invalid.</exception>
+        public static string ConvertToUtc(string startTime, DateTime date)
+        {
+            string timeZoneId = GlobalInfo.timeZone;
+            if (string.IsNullOrWhiteSpace(startTime))
+            {
+                throw new ArgumentException("Start time cannot be null or empty.");
+            }
+
+            if (string.IsNullOrWhiteSpace(timeZoneId))
+            {
+                throw new ArgumentException("Time zone ID cannot be null or empty.");
+            }
+
+            try
+            {
+                // Parse the time string
+                DateTime parsedTime = DateTime.Parse(startTime, new CultureInfo("en-US"), DateTimeStyles.NoCurrentDateDefault);
+
+                // Combine date from DateTime and time from parsedTime
+                DateTime localDateTime = new DateTime(
+                    date.Year, date.Month, date.Day,
+                    parsedTime.Hour, parsedTime.Minute, parsedTime.Second, parsedTime.Millisecond,
+                    DateTimeKind.Unspecified);
+
+                // Get source time zone
+                TimeZoneInfo sourceTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
+
+                // Convert to UTC
+                DateTime utcDateTime = TimeZoneInfo.ConvertTimeToUtc(localDateTime, sourceTimeZone);
+
+                return utcDateTime.ToShortTimeString();
+            }
+            catch (TimeZoneNotFoundException)
+            {
+                throw new ArgumentException($"Invalid time zone ID: {timeZoneId}");
+            }
+            catch (FormatException)
+            {
+                throw new ArgumentException("Invalid time format. Use 'h:mm tt' (e.g., '7:00 PM').");
+            }
+        }
         //public override async Task Delete(long id)
         //{
         //    var entity = await _unitOfWork.Meeting.GetByIdAsync(id);

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

@@ -43,7 +43,7 @@ namespace MTWorkHR.Application.Services
                 var orderType = await _unitOfWork.OrderType.GetByIdAsync(input.OrderTypeId);
                 var leaveType = input.LeaveTypeId.HasValue && input.LeaveTypeId > 0 ? await _unitOfWork.LeaveType.GetByIdAsync(input.LeaveTypeId.Value) : null;
                 var employees = await _user.GetAllEmployees();
-                var period = DateTime.Now.Year;
+                var period = DateTime.UtcNow.Year;
                 var allocations = new List<OrderAllocation>();
                 foreach (var emp in employees)
                 {

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

@@ -214,7 +214,7 @@ namespace MTWorkHR.Application.Services
         }
         public override async Task<OrderRequestDto> Create(OrderRequestDto input)
         {
-            var period = DateTime.Now.Year;
+            var period = DateTime.UtcNow.Year;
             input.LeaveTypeId = (input.LeaveTypeId != null && input.LeaveTypeId > 0 ) ? input.LeaveTypeId : null;
             input.OrderStatus = (input.OrderStatus != null && input.OrderStatus > 0 ) ? input.OrderStatus : ApprovalStatusEnum.Pending;
             if (string.IsNullOrEmpty( input.RequestingEmployeeId))
@@ -332,7 +332,7 @@ namespace MTWorkHR.Application.Services
                     var contract = await _unitOfWork.Contract.GetLatestActiveContract(orderRequest.RequestingEmployeeId);
                     contractId = contract.Id;
                 }
-                var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(orderRequest.RequestingEmployeeId, orderRequest.OrderTypeId, orderRequest.LeaveTypeId, contractId.Value, DateTime.Now.Year);
+                var allocation = await _unitOfWork.OrderAllocation.GetUserAllocations(orderRequest.RequestingEmployeeId, orderRequest.OrderTypeId, orderRequest.LeaveTypeId, contractId.Value, DateTime.UtcNow.Year);
                 if (allocation != null)
                 {
                     int daysRequested = !orderRequest.EndDate.HasValue ? 1 : (int)(orderRequest.EndDate.Value - orderRequest.StartDate).TotalDays;

+ 4 - 4
MTWorkHR.Application/Services/User/UserService.cs

@@ -139,7 +139,7 @@ namespace MTWorkHR.Application.Services
                    
                 }
             
-            var attendance = await _unitOfWork.Attendance.GetAttendanceByUserId(id, DateTime.Now.Date);
+            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;
@@ -486,7 +486,7 @@ namespace MTWorkHR.Application.Services
                 user.UserType = (int)UserTypeEnum.Employee;//default if not selected
             }
             _unitOfWork.BeginTran();
-            user.CreateDate = DateTime.Now;
+            user.CreateDate = DateTime.UtcNow;
             //saving user
             var result = await _userManager.CreateAsync(user, input.Password);
             if (!result.Succeeded)
@@ -669,7 +669,7 @@ namespace MTWorkHR.Application.Services
                 MapperObject.Mapper.Map(input, entity);
 
                 _unitOfWork.BeginTran();
-                entity.UpdateDate = DateTime.Now;
+                entity.UpdateDate = DateTime.UtcNow;
                 //saving user
                 var result = await _userManager.UpdateAsync(entity);
                 if (!result.Succeeded)
@@ -714,7 +714,7 @@ namespace MTWorkHR.Application.Services
 
 
                 entity.CompanyId = companyId;
-                entity.UpdateDate = DateTime.Now;
+                entity.UpdateDate = DateTime.UtcNow;
 
                 //saving user
                 var result = await _userManager.UpdateAsync(entity);

+ 1 - 1
MTWorkHR.Core/Entities/Logging/SMSLog.cs

@@ -7,7 +7,7 @@ namespace MTWorkHR.Core.Entities
     {
         [Key]
         public int Id { get; set; }
-        public DateTime? CreatedDate { get; set; } = DateTime.Now;
+        public DateTime? CreatedDate { get; set; } = DateTime.UtcNow;
         [MaxLength(450)]
         public string UserId { get; set; }
 

+ 3 - 1
MTWorkHR.Core/Global/GlobalInfo.cs

@@ -13,14 +13,16 @@ namespace MTWorkHR.Core.Global
         public UserTypeEnum UserType { get; set; }
         public long? CompanyId { get; set; }
         public static string lang { get; set; } = "en";
+        public static string timeZone { get; set; } = "utc";
         public string Token { get; set; }
 
-        public void SetValues(string UserName, string UserId, long? CompanyId, string token, string lang)
+        public void SetValues(string UserName, string UserId, long? CompanyId, string token, string lang, string timeZone)
         {
             this.UserName = UserName;
             this.UserId = UserId;
             this.CompanyId = CompanyId;
             GlobalInfo.lang = lang;
+            GlobalInfo.timeZone = timeZone;
             this.Token = token;
         }
     }

+ 2 - 2
MTWorkHR.Infrastructure/DBContext/HRDataContext.cs

@@ -118,7 +118,7 @@ namespace MTWorkHR.Infrastructure.DBContext
                     if (change.Entity is IAudit)
                     {
                         ((IAudit)change.Entity).CreateUser = _globalInfo.UserId;
-                        ((IAudit)change.Entity).CreateDate = DateTime.Now;
+                        ((IAudit)change.Entity).CreateDate = DateTime.UtcNow;
                     }
                     if ( _globalInfo.CompanyId > 0 && change.Entity is IHaveCompany)
                     {
@@ -139,7 +139,7 @@ namespace MTWorkHR.Infrastructure.DBContext
                         && ((change.Entity is IFullAudit && !((IFullAudit)change.Entity).IsDeleted) || change.Entity is not IFullAudit))
                     {
                         ((IAudit)change.Entity).UpdateUser = _globalInfo.UserId;
-                        ((IAudit)change.Entity).UpdateDate = DateTime.Now;
+                        ((IAudit)change.Entity).UpdateDate = DateTime.UtcNow;
                     }
 
                     if (change.Entity is IFullAudit && ((IFullAudit)change.Entity).IsDeleted)

+ 2 - 2
MTWorkHR.Infrastructure/Reports/ContractPdfGenerator.cs

@@ -35,7 +35,7 @@ namespace MTWorkHR.Infrastructure.Reports
                     PdfFont regularFont = PdfFontFactory.CreateFont(iText.IO.Font.Constants.StandardFonts.HELVETICA);
 
                     // Timestamp and Title
-                    document.Add(new Paragraph($"{DateTime.Now:dd/MM/yyyy HH:mm:ss} .")
+                    document.Add(new Paragraph($"{DateTime.UtcNow:dd/MM/yyyy HH:mm:ss} .")
                         .SetFont(regularFont)
                         .SetFontSize(10));
                     document.Add(new Paragraph("Employee Contract")
@@ -344,7 +344,7 @@ namespace MTWorkHR.Infrastructure.Reports
 //            .SetTextAlignment(TextAlignment.CENTER));
 
 //        // Parties
-//        document.Add(new Paragraph($"\nThis contract is made on {DateTime.Now:MMMM dd, yyyy}, between:")
+//        document.Add(new Paragraph($"\nThis contract is made on {DateTime.UtcNow:MMMM dd, yyyy}, between:")
 //            .SetFont(regularFont));
 //        document.Add(new Paragraph()
 //            .Add(new Text("Party A: ").SetFont(boldFont))

+ 1 - 1
MTWorkHR.Infrastructure/Repositories/Auth/LoginOTPRepository.cs

@@ -22,7 +22,7 @@ namespace MTWorkHR.Infrastructure.Repositories
 		public async Task<bool> VerifyOTP(string userId, string oTP)
 		{
 			bool result = false;
-			var loginOTP = await dbSet.AsQueryable().OrderByDescending(x => x.CreateDate).FirstOrDefaultAsync(x => x.UserId == userId && x.ExpireDate >= DateTime.Now);
+			var loginOTP = await dbSet.AsQueryable().OrderByDescending(x => x.CreateDate).FirstOrDefaultAsync(x => x.UserId == userId && x.ExpireDate >= DateTime.UtcNow);
 			if (loginOTP.OTP == oTP)
 				result = true;
 			return result;

+ 2 - 2
MTWorkHR.Infrastructure/Repositories/Contract/ContractRepository.cs

@@ -32,8 +32,8 @@ namespace MTWorkHR.Infrastructure.Repositories
             return await dbSet
                 .FirstOrDefaultAsync(x => x.UserId == userId 
                 && x.ContractStatusId == (int)ContractStatusEnum.Approved
-                && x.StartDate <= DateTime.Now.Date
-                && (x.EndDate == null || x.EndDate < DateTime.Now.Date));
+                && x.StartDate <= DateTime.UtcNow.Date
+                && (x.EndDate == null || x.EndDate < DateTime.UtcNow.Date));
         }