public ChatMessagesResponse(ChatMessages chatMessages, int count, int userId) { this.Date = chatMessages.Date; this.LatestChat = chatMessages.Message; this.LatestUser = chatMessages.Sender.Name; if (chatMessages.ReceiverId == userId) { this.ReceiverId = chatMessages.SenderId; this.ReceiverName = chatMessages.Sender.Name; this.ReceiverImage = chatMessages.Sender.Image; } else { this.ReceiverId = chatMessages.ReceiverId; this.ReceiverName = chatMessages.Receiver.Name; this.ReceiverImage = chatMessages.Receiver.Image; } this.RoomId = chatMessages.RoomId; this.UnRead = count; }