public int IsEventStackUpdated()
        {
            int userId;
            var userIdString = GetSessionVariable("UserId");

            if (System.Int32.TryParse(userIdString, out userId))
            {
                var isEventStackUpdated = RemoteProcedureCallClass.GetBaseChannel().IsEventStackUpdated(userId);
                return(isEventStackUpdated);
            }
            return(-1);
        }
        public DialogButtonInfo[] GetDialogButtonInfo()
        {
            int userId;
            var userIdString = GetSessionVariable("UserId");

            if (System.Int32.TryParse(userIdString, out userId))
            {
                var resultJson = RemoteProcedureCallClass.GetBaseChannel().GetDialogButtonInfo(userId);
                var result     = resultJson.FromJson <DialogButtonInfo[]>();
                return(result);
            }
            return(new DialogButtonInfo[0]);
        }
        public EventType[] GetAllEvents()
        {
            int userId;
            var userIdString = GetSessionVariable("UserId");

            if (System.Int32.TryParse(userIdString, out userId))
            {
                var resultJson = RemoteProcedureCallClass
                                 .GetBaseChannel()
                                 .GetAllEvents(userId);
                EventType[] result =
                    resultJson?.FromJson <EventType[]>();
                return(result);
            }
            return(new EventType[0]);
        }
        public int IsLogUpdated()
        {
            int    userId;
            string userIdString = GetSessionVariable("UserId");

            if (System.Int32.TryParse(userIdString, out userId))
            {
                bool result = RemoteProcedureCallClass
                              .GetBaseChannel()
                              .IsLogUpdated(userId);
                return(result ? 1 : 0);
            }
            else
            {
                return(-1);
            }
        }
        public string UpdateLogData()
        {
            int    userId;
            string userIdString = GetSessionVariable("UserId");

            if (System.Int32.TryParse(userIdString, out userId))
            {
                string result = RemoteProcedureCallClass
                                .GetBaseChannel()
                                .UpdateLogData(userId);
                return(result);
            }
            else
            {
                return("");
            }
        }
        public string GetAllUserCommunicationEvents()
        {
            int    userId;
            string userIdString = GetSessionVariable("UserId");

            if (System.Int32.TryParse(userIdString, out userId))
            {
                string result = RemoteProcedureCallClass
                                .GetBaseChannel()
                                .GetAllUserCommunicationEvents(userId);
                return(result);
            }
            else
            {
                return("");
            }
        }
        public MessageInfo[] GetDialogForUser([FromBody] int companionId)
        {
            int    userId;
            string userIdString = GetSessionVariable("UserId");

            if (System.Int32.TryParse(userIdString, out userId))
            {
                var resultJson = RemoteProcedureCallClass
                                 .GetBaseChannel()
                                 .GetDialogForUser(new DialogId()
                {
                    UserId = userId, CompanionId = companionId
                });
                var result = resultJson.FromJson <MessageInfo[]>();
                return(result);
            }
            return(new MessageInfo[0]);
        }
        public void SendMessage(SendMessageStruct toSend)
        {
            int userId;
            var userIdString = GetSessionVariable("UserId");

            if (System.Int32.TryParse(userIdString, out userId))
            {
                RemoteProcedureCallClass.GetBaseChannel()
                .SendMessage(
                    new MessageToAdd()
                {
                    UserId      = userId,
                    CompanionId = toSend.CompanionId,
                    Message     = new Message()
                    {
                        Content = toSend.Message, Time = System.DateTime.Now
                    }
                });
            }
        }