public static async Task <MessageGroupEntity> Parse(JObject jobject, UserAccountEntity userAccountEntity)
        {
            string json = jobject["messageGroups"] != null ? jobject["messageGroups"].ToString() : null;

            if (string.IsNullOrEmpty(json))
            {
                return(null);
            }
            var a        = (JArray)JsonConvert.DeserializeObject(json);
            var messages = new List <MessageGroup>();

            foreach (JObject o in a)
            {
                messages.Add(new MessageGroup
                {
                    TotalMessages       = o["totalMessages"] != null ? (int)o["totalMessages"] : 0,
                    TotalUnseenMessages = o["totalUnseenMessages"] != null ? (int)o["totalUnseenMessages"] : 0,
                    MessageGroupId      = o["messageGroupId"] != null ? (String)o["messageGroupId"] : string.Empty,
                    MessageGroupDetail  = o["messageGroupDetail"] != null ? ParseMessageGroupDetail((JObject)o["messageGroupDetail"], userAccountEntity) : null,
                    LatestMessage       = o["latestMessage"] != null ? await ParseLatestMessage((JObject)o["latestMessage"], userAccountEntity) : null
                });
            }

            var messageGroupEntity = new MessageGroupEntity()
            {
                Size          = jobject["size"] != null ? (int)jobject["size"] : 0,
                Start         = jobject["start"] != null ? (int)jobject["start"] : 0,
                TotalResults  = jobject["totalResults"] != null ? (int)jobject["totalResults"] : 0,
                MessageGroups = messages
            };

            return(messageGroupEntity);
        }
 public AccountData(String token, String refresh, int time)
 {
     this.AccessToken  = token;
     this.RefreshToken = refresh;
     this.RefreshTime  = time;
     this.StartTime    = UserAccountEntity.GetUnixTime(DateTime.Now);
 }
        public async static Task <LatestMessage> ParseLatestMessage(JObject o, UserAccountEntity userAccountEntity)
        {
            var userManager   = new UserManager();
            var latestMessage = new LatestMessage()
            {
                MessageUid     = (int)o["messageUid"],
                SeenFlag       = (bool)o["seenFlag"],
                MessageKind    = (int)o["messageKind"],
                SenderOnlineId = (String)o["senderOnlineId"],
                ReceivedDate   = (String)o["receivedDate"],
                Body           = (String)o["body"]
            };

            latestMessage.User = await userManager.GetUser(latestMessage.SenderOnlineId, userAccountEntity);

            return(latestMessage);
        }
        public static MessageGroupDetail ParseMessageGroupDetail(JObject o, UserAccountEntity userAccountEntity)
        {
            var json    = o["members"].ToString();
            var a       = (JArray)JsonConvert.DeserializeObject(json);
            var members = (from JObject q in a
                           select new Member
            {
                OnlineId = (String)q["onlineId"],
            }).ToList();
            var messageGroupDetail = new MessageGroupDetail()
            {
                MessageGroupName = (String)o["messageGroupName"],
                MessageGroupType = (int)o["messageGroupType"],
                TotalMembers     = (int)o["totalMembers"],
                Members          = members
            };

            return(messageGroupDetail);
        }