zinab_elgendy пре 1 месец
родитељ
комит
54f4847eb8

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

@@ -62,8 +62,8 @@ namespace MTWorkHR.API.Chat
                 var online = onlineUsers.FirstOrDefault(u=>  u.UserId == emp.Id);
                 var profileImg = "";
                 var lastMessage = await GetLastMessage(emp.Id);
-                var lastMsg = lastMessage.Content;
-                var lastMsgDate = lastMessage.CreateDate;
+                var lastMsg = lastMessage?.Content;
+                var lastMsgDate = lastMessage?.CreateDate;
                 var unseenCount = 0;
                 var chatUser = new ChatUserDto(emp.Id, emp.FirstName + " " + emp.LastName, online?.SignalrId, emp.Email, online != null ? true : false, profileImg, unseenCount,lastMsg,lastMsgDate);
             }

+ 2 - 2
MTWorkHR.Application/Dtos/User/ChatUserDto.cs

@@ -19,7 +19,7 @@ namespace MTWorkHR.Application.Models
         public bool IsOnline { get; set; }
         public string? ProfileImage { get; set; }
         public string? LastMessage { get; set; }
-        public string? LastMessageDate { get; set; }
+        public DateTime? LastMessageDate { get; set; }
         public int? UnseenCount { get; set; }
         public ChatUserDto(string someId, string someName, string someConnId)
         {
@@ -28,7 +28,7 @@ namespace MTWorkHR.Application.Models
             ConnectionId = someConnId;
         }
 
-        public ChatUserDto(string userId, string userName, string ConnId, string email, bool isOnline, string profileImg, int? unseenCount,string lastMessage, string lastMessageDate)
+        public ChatUserDto(string userId, string userName, string ConnId, string email, bool isOnline, string profileImg, int? unseenCount,string lastMessage, DateTime? lastMessageDate)
         {
             UserId = userId;
             UserName = userName;