예제 #1
0
        public List <UserChatViewModel> GetServiceProviderUser(int CurrentUserID)
        {
            List <UserChatViewModel> LstUserChat = new List <UserChatViewModel>();
            var query = _uow.Query <User>()
                        .Where(x => x.Is_SProvider &&
                               x.User_Id != CurrentUserID)
                        .ToList();

            foreach (var obj in query)
            {
                UserChatViewModel UserChat = new UserChatViewModel();
                UserChat.User = obj;
                var LstMssg = _chatMessageService.Get().Where(x =>
                                                              x.FromUserId == obj.User_Id &&
                                                              x.ToUserId == CurrentUserID ||
                                                              (
                                                                  x.FromUserId == CurrentUserID &&
                                                                  x.ToUserId == obj.User_Id
                                                              )
                                                              ).ToList();
                UserChat.ChatMessages.AddRange(LstMssg);
                LstUserChat.Add(UserChat);
            }
            return(LstUserChat);
        }