//Работа с БД public static void PostAccount(Account account) { string obj = JsonConvert.SerializeObject(account); POST(uriMyApi, obj); }
public static Account GetAccount(long instaId) { string response = GET(uriMyApi, "instaId="+instaId.ToString()); dynamic temp = JsonConvert.DeserializeObject(response); if (temp != null) { Account result = new Account((string)temp.Followers, (string)temp.Following, (string)temp.Likes, (string)temp.Media, (long)temp.InstaId, (string)temp.Start); return result; } else return null; }
//отправляет юзера серверу public void Load() { try { string response = ApiServer.UsersSelf(access_token); dynamic dyn = JsonConvert.DeserializeObject<dynamic>(response); Account account = new Account((int)dyn.data.counts.followed_by, (int)dyn.data.counts.follows, 0, (int)dyn.data.counts.media, (long)dyn.data.id) { AccessToken = access_token }; insta_id = account.InstaId.ToString(); if (ApiServer.GetAccount(account.InstaId) == null) { ApiServer.PostAccount(account); } } catch { ShowMessage(ApiServer.ErrorMessageForClient); Load(); } }