Пример #1
0
        public ActionResult GetNewMessages(GetNewMessagesRequestModel request)
        {
            int        parentChatroomId = request.ParentChatroomId;
            int        chatroomId       = request.ChatroomId;
            List <int> existingIds      = request.ExistingMessageIds;

            GetNewMessagesResponseModel response = new GetNewMessagesResponseModel();

            var user = UserService.GetUser(request.UserId);

            if (user == null || user.Role == Models.User_Model.RoleLevel.Blocked)
            {
                response.Logout = true;
            }
            else
            {
                var messageInformationModels = ChatroomService.GetNewMessagesInformation(parentChatroomId, chatroomId, existingIds);

                foreach (var messageInformationModel in messageInformationModels)
                {
                    if (messageInformationModel.IntendedForUserId != -1)
                    {
                        if (messageInformationModel.IntendedForUserId == request.UserId)
                        {
                            response.MessagesInformation.Add(messageInformationModel);
                        }
                    }
                    else
                    {
                        response.MessagesInformation.Add(messageInformationModel);
                    }
                }
            }
            return(Json(response));
        }