Пример #1
0
        public UserInfo LogIn(string userName)
        {
            string uri  = UrlAddressFactory.LogIn(userName);
            var    data = GetData <UserInfo>(uri);

            return(data);
        }
Пример #2
0
        public List <UserInfo> GetUsers()
        {
            string uri  = UrlAddressFactory.GetUsers();
            var    data = GetData <List <UserInfo> >(uri);

            return(data);
        }
Пример #3
0
        public List <MessageInfo> GetUserMessages(Guid userId)
        {
            string uri  = UrlAddressFactory.GetUserMessages(userId);
            var    data = GetData <List <MessageInfo> >(uri);

            return(data);
        }
Пример #4
0
        public UserInfo GetUserByName(string userName)
        {
            string uri  = UrlAddressFactory.GetUserByName(userName);
            var    data = GetData <UserInfo>(uri);

            return(data);
        }
Пример #5
0
        public List <MessageInfo> GetAllMessages()
        {
            string uri  = UrlAddressFactory.GetAllMessages();
            var    data = GetData <List <MessageInfo> >(uri);

            return(data);
        }
Пример #6
0
        public int SendMessageToUser(MessageInfo message)
        {
            string uri          = UrlAddressFactory.SendMessageToUser();
            string jsonPostData = JsonConvert.SerializeObject(message);

            PostData(uri, jsonPostData);
            return(message.Text.Length);
        }
Пример #7
0
        public void LogOut(Guid userId)
        {
            string uri      = UrlAddressFactory.LogOut();
            var    userInfo = new UserInfo
            {
                Id       = userId,
                Name     = "name",
                IsOnline = false
            };
            string jsonPostData = JsonConvert.SerializeObject(userInfo);

            PostData(uri, jsonPostData);
        }
Пример #8
0
        public int SendMessage(string message, Guid senderId)
        {
            string uri         = UrlAddressFactory.SendMessage();
            var    messageInfo = new MessageInfo
            {
                Id          = null,
                SenderId    = senderId,
                Text        = message,
                IsDelivered = false,
                CreateDate  = null,
            };
            string jsonPostData = JsonConvert.SerializeObject(messageInfo);

            PostData(uri, jsonPostData);
            return(message.Length);
        }