private static async Task <IEnumerable <DataIUser> > GetUserVkFriends(DataIUser user)
        {
            IList <DataIUser> friends = new List <DataIUser>();

            try
            {
                Account acc     = Account.Deserialize(user.SerializeInfo.ToString());
                var     request = new OAuth2Request("GET", new Uri("https://api.vk.com/method/friends.get"), null, acc);

                request.Parameters.Add("fields", "nickname,photo_200");
                request.Parameters.Add("order", "hints");

                var res = await request.GetResponseAsync();

                var responseText = res.GetResponseText();

                var listFriendsIds = JsonConvert.DeserializeObject <XamarinSocialApp.Droid.Data.VkData.VkUsers>(responseText);

                foreach (var friend in listFriendsIds.response)
                {
                    friends.Add(new DataUser()
                    {
                        UserPhoto     = friend.photo_200,
                        FirstName     = friend.first_name,
                        LastName      = friend.last_name,
                        SerializeInfo = user.SerializeInfo,
                        Uid           = friend.uid
                    });
                }
            }
            catch (Exception)
            {
            }
            return(friends);
        }
        public async Task <IEnumerable <DataIUser> > GetUserTwitterFriends(DataIUser user)
        {
            IList <DataIUser> friends = new List <DataIUser>();

            try
            {
                TwitterContext context = this.GetTwitterContext(user.SerializeInfo);

                var friendship =
                    await
                        (from friend in context.Friendship
                        where friend.Type == FriendshipType.FollowersList &&
                        friend.UserID == user.Uid
                        select friend)
                    .SingleOrDefaultAsync();

                if (friendship != null && friendship.Users != null)
                {
                    friendship.Users.ForEach(friend =>
                                             friends.Add(new DataUser()
                    {
                        UserPhoto     = friend.ProfileImageUrl.Replace("normal", "bigger"),
                        FirstName     = friend.ScreenNameResponse,
                        Uid           = friend.UserIDResponse,
                        SerializeInfo = user.SerializeInfo,
                        SocialNetwork = user.SocialNetwork
                    }));
                }
            }
            catch (Exception)
            {
            }
            return(friends);
        }
        public async Task <IDialog> GetDialogWithFriend(DataIUser user, enSocialNetwork socialNetwork, IUser friend)
        {
            IDialog dialog = null;

            try
            {
                switch (socialNetwork)
                {
                case enSocialNetwork.VK:
                    dialog = await GetVkDialogWithFriend(user, friend);

                    break;

                case enSocialNetwork.Twitter:
                    dialog = await GetTwitterDialogWithFriend(user, friend);

                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
            }

            this.StopRequest();

            return(dialog);
        }
        public async Task <bool> SendMessage(DataIUser user, DataIUser friend, string message, enSocialNetwork socialNetwork)
        {
            try
            {
                this.StartRequest();

                switch (socialNetwork)
                {
                case enSocialNetwork.VK:
                    await SendVkMessage(user, friend, message);

                    break;

                case enSocialNetwork.Twitter:
                    await SendTwitterMessage(user, friend, message);

                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                this.StopRequest();
            }

            return(true);
        }
        private async Task <IDialog> GetVkDialogWithFriend(DataIUser user, IUser friend)
        {
            IDialog dialog = null;

            try
            {
                Account acc = Account.Deserialize(user.SerializeInfo.ToString());

                this.StartRequest();

                var request = new OAuth2Request("GET", new Uri("https://api.vk.com/method/messages.getHistory"), null, acc);

                request.Parameters.Add("user_id", friend.Uid);
                request.Parameters.Add("count", "200");

                var res = await request.GetResponseAsync();

                var responseText = res.GetResponseText();

                var msg = JsonConvert.DeserializeObject <XamarinSocialApp.Droid.Data.VkData.VkMessagesResponse>(responseText);
                msg.Response.RemoveAt(0);

                IList <XamarinSocialApp.Droid.Data.VkData.MessageInDialog> msg1
                    = new List <XamarinSocialApp.Droid.Data.VkData.MessageInDialog>();
                foreach (var item in msg.Response)
                {
                    msg1.Add(JsonConvert.DeserializeObject <XamarinSocialApp.Droid.Data.VkData.MessageInDialog>(item.ToString()));
                }

                IList <IMessage> messages = new List <IMessage>();

                foreach (var item in msg1)
                {
                    messages.Add(new DataMessage()
                    {
                        Content = item.Body, Sender = item.UserId == user.Uid ? user : friend
                    });
                }

                dialog = new XamarinSocialApp.UI.Data.Implementations.Entities.Databases.Dialog(user, messages);
            }
            catch (Exception)
            {
            }

            return(dialog);
        }
        private static async Task <IEnumerable <IDialog> > GetVkDialogs(DataIUser user)
        {
            IList <IDialog> dialogs = new List <IDialog>();

            try
            {
                Account acc     = Account.Deserialize(user.SerializeInfo.ToString());
                var     request = new OAuth2Request("GET", new Uri("https://api.vk.com/method/messages.getDialogs"), null, acc);

                request.Parameters.Add("count", "200");
                request.Parameters.Add("v", "5.37");

                var res = await request.GetResponseAsync();

                var responseText = res.GetResponseText();

                var msg = JsonConvert.DeserializeObject <XamarinSocialApp.Droid.Data.VkData.VkDialogsResponse>(responseText);


                foreach (var item in msg.Response.Messages)
                {
                    IUser userDialog = new User()
                    {
                        Uid           = item.Message.UserId,
                        SerializeInfo = user.SerializeInfo
                    };
                    DateTime start = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);

                    string dateMessage = start.AddSeconds(item.Message.DateMessage).ToLocalTime().ToString();
                    //var userDialog = await GetUserInfoRequest(item.Message.UserId, acc, socialNetwork);
                    dialogs.Add(new DataDialogs(userDialog, new List <IMessage>()
                    {
                        new DataMessage()
                        {
                            Content = item.Message.Body, DateMessage = dateMessage
                        }
                    }));
                }
            }
            catch (Exception)
            {
            }

            return(dialogs);
        }
        public async Task <IEnumerable <IDialog> > GetDialogs(DataIUser user, enSocialNetwork socialNetwork)
        {
            IEnumerable <IDialog> dialogs = null;

            switch (socialNetwork)
            {
            case enSocialNetwork.VK:
                dialogs = await GetVkDialogs(user);

                break;

            case enSocialNetwork.Twitter:
                dialogs = await GetTwitterDialogs(user);

                break;
            }
            return(dialogs);
        }
        private async Task <bool> SendTwitterMessage(DataIUser user, DataIUser friend, string message)
        {
            try
            {
                TwitterContext context = this.GetTwitterContext(user.SerializeInfo);

                var sentMessage = await context.NewDirectMessageAsync(Convert.ToUInt64(friend.Uid), message);

                if (sentMessage == null)
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
        private async Task <bool> SendVkMessage(DataIUser user, DataIUser friend, string Message)
        {
            try
            {
                Account acc     = Account.Deserialize(user.SerializeInfo.ToString());
                var     request = new OAuth2Request("GET", new Uri("https://api.vk.com/method/messages.send"), null, acc);

                request.Parameters.Add("user_id", friend.Uid);
                request.Parameters.Add("message", Message);

                var res1 = await request.GetResponseAsync();

                var responseText = res1.GetResponseText();
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
        public async Task <IEnumerable <DataIUser> > GetUserFriends(DataIUser user, enSocialNetwork socialNetwork)
        {
            IEnumerable <DataIUser> dialogs = null;

            switch (socialNetwork)
            {
            case enSocialNetwork.VK:
                dialogs = await GetUserVkFriends(user);

                break;

            case enSocialNetwork.Twitter:
                dialogs = await GetUserTwitterFriends(user);

                break;

            default:
                break;
            }

            return(dialogs);
        }
        public async Task <IEnumerable <IDialog> > GetTwitterDialogs(DataIUser user)
        {
            IList <IDialog> dialogs = new List <IDialog>();

            try
            {
                TwitterContext context = this.GetTwitterContext(user.SerializeInfo);

                var twitterDialogs = await
                                         (from dm in context.DirectMessage
                                         where dm.Type == DirectMessageType.SentTo
                                         select dm)
                                     .ToListAsync();

                foreach (var msg in twitterDialogs)
                {
                    IUser userDialog = new User()
                    {
                        Uid           = msg.SenderID.ToString(),
                        FirstName     = msg.SenderScreenName,
                        SerializeInfo = user.SerializeInfo,
                        SocialNetwork = user.SocialNetwork
                    };

                    dialogs.Add(new DataDialogs(userDialog, new List <IMessage>()
                    {
                        new DataMessage()
                        {
                            Content = msg.Text, DateMessage = msg.CreatedAt.ToString()
                        }
                    }));
                }
            }
            catch (Exception)
            {
            }

            return(dialogs);
        }
		public async Task<IEnumerable<DataIUser>> GetUserTwitterFriends(DataIUser user)
		{
			IList<DataIUser> friends = new List<DataIUser>();
			try
			{
				TwitterContext context = this.GetTwitterContext(user.SerializeInfo);

				var friendship =
								await
								(from friend in context.Friendship
								 where friend.Type == FriendshipType.FollowersList &&
											 friend.UserID == user.Uid
								 select friend)
								.SingleOrDefaultAsync();

				if (friendship != null && friendship.Users != null)
					friendship.Users.ForEach(friend =>
																			friends.Add(new DataUser()
																				{
																					UserPhoto =  friend.ProfileImageUrl.Replace("normal", "bigger"),
																					FirstName = friend.ScreenNameResponse,
																					Uid = friend.UserIDResponse,
																					SerializeInfo = user.SerializeInfo,
																					SocialNetwork = user.SocialNetwork
																				}));

			}
			catch (Exception)
			{
			}
			return friends;
		}
		private static async Task<IEnumerable<DataIUser>> GetUserVkFriends(DataIUser user)
		{
			IList<DataIUser> friends = new List<DataIUser>();
			try
			{
				Account acc = Account.Deserialize(user.SerializeInfo.ToString());
				var request = new OAuth2Request("GET", new Uri("https://api.vk.com/method/friends.get"), null, acc);

				request.Parameters.Add("fields", "nickname,photo_200");
				request.Parameters.Add("order", "hints");

				var res = await request.GetResponseAsync();
				var responseText = res.GetResponseText();

				var listFriendsIds = JsonConvert.DeserializeObject<XamarinSocialApp.Droid.Data.VkData.VkUsers>(responseText);

				foreach (var friend in listFriendsIds.response)
				{
					friends.Add(new DataUser()
					{
						UserPhoto = friend.photo_200,
						FirstName = friend.first_name,
						LastName = friend.last_name,
						SerializeInfo = user.SerializeInfo,
						Uid = friend.uid
					});
				}
			}
			catch (Exception)
			{
			}
			return friends;
		}
		private static async Task<IEnumerable<IDialog>> GetVkDialogs(DataIUser user)
		{
			IList<IDialog> dialogs = new List<IDialog>();
			try
			{
				Account acc = Account.Deserialize(user.SerializeInfo.ToString());
				var request = new OAuth2Request("GET", new Uri("https://api.vk.com/method/messages.getDialogs"), null, acc);

				request.Parameters.Add("count", "200");
				request.Parameters.Add("v", "5.37");

				var res = await request.GetResponseAsync();
				var responseText = res.GetResponseText();

				var msg = JsonConvert.DeserializeObject<XamarinSocialApp.Droid.Data.VkData.VkDialogsResponse>(responseText);


				foreach (var item in msg.Response.Messages)
				{
					IUser userDialog = new User()
					{
						Uid = item.Message.UserId,
						SerializeInfo = user.SerializeInfo
					};
					DateTime start = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);

					string dateMessage = start.AddSeconds(item.Message.DateMessage).ToLocalTime().ToString();				
					//var userDialog = await GetUserInfoRequest(item.Message.UserId, acc, socialNetwork);
					dialogs.Add(new DataDialogs(userDialog, new List<IMessage>() 
				{ 
					new DataMessage() { Content = item.Message.Body, DateMessage = dateMessage } 
				}));
				}
			}
			catch (Exception)
			{
			}

			return dialogs;
		}
		public async Task<IEnumerable<DataIUser>> GetUserFriends(DataIUser user, enSocialNetwork socialNetwork)
		{
			IEnumerable<DataIUser> dialogs = null;
			switch (socialNetwork)
			{
				case enSocialNetwork.VK:
					dialogs = await GetUserVkFriends(user);
					break;

				case enSocialNetwork.Twitter:
					dialogs = await GetUserTwitterFriends(user);
					break;

				default:
					break;
			}

			return dialogs;
		}
		public async Task<IEnumerable<IDialog>> GetDialogs(DataIUser user, enSocialNetwork socialNetwork)
		{
			IEnumerable<IDialog> dialogs = null;
			switch(socialNetwork)
			{
				case enSocialNetwork.VK:
					dialogs = await GetVkDialogs(user);
					break;

				case enSocialNetwork.Twitter:
					dialogs = await GetTwitterDialogs(user);
					break;
										
			}
			return dialogs;
		}
		public async Task<IEnumerable<IDialog>> GetTwitterDialogs(DataIUser user)
		{
			IList<IDialog> dialogs = new List<IDialog>();
			try
			{
				TwitterContext context = this.GetTwitterContext(user.SerializeInfo);

				var twitterDialogs = await
						(from dm in context.DirectMessage
						 where dm.Type == DirectMessageType.SentTo
						 select dm)
						.ToListAsync();

				foreach (var msg in twitterDialogs)
				{
					IUser userDialog = new User()
					{
						Uid = msg.SenderID.ToString(),
						FirstName = msg.SenderScreenName,
						SerializeInfo = user.SerializeInfo, 
						SocialNetwork = user.SocialNetwork
					};

					dialogs.Add(new DataDialogs(userDialog, new List<IMessage>()
					{ 
						new DataMessage() { Content = msg.Text, DateMessage = msg.CreatedAt.ToString() } 
					}));
				}
			}
			catch (Exception)
			{
			}

			return dialogs;
		}
		private async Task<bool> SendTwitterMessage(DataIUser user, DataIUser friend, string message)
		{
			try
			{
				TwitterContext context = this.GetTwitterContext(user.SerializeInfo);

				var sentMessage = await context.NewDirectMessageAsync(Convert.ToUInt64(friend.Uid), message);

				if (sentMessage == null)
					return false;
			}
			catch (Exception)
			{
				return false;
			}

			return true;
		}
		private async Task<bool> SendVkMessage(DataIUser user, DataIUser friend, string Message)
		{
			try
			{
				Account acc = Account.Deserialize(user.SerializeInfo.ToString());
				var request = new OAuth2Request("GET", new Uri("https://api.vk.com/method/messages.send"), null, acc);

				request.Parameters.Add("user_id", friend.Uid);
				request.Parameters.Add("message", Message);

				var res1 = await request.GetResponseAsync();
				var responseText = res1.GetResponseText();
			}
			catch (Exception)
			{
				return false;
			}

			return true;
		}
		public async Task<IEnumerable<IDialog>> GetDialogWithFriend(DataIUser user, enSocialNetwork socialNetwork)
		{
			IList<IDialog> dialogs = new List<IDialog>();

			try
			{
				Account acc = Account.Deserialize(user.SerializeInfo);
				var request = new OAuth2Request("GET", new Uri("https://api.vk.com/method/messages.getHistory"), null, acc);

				request.Parameters.Add("user_id", user.Uid);

				var res = await request.GetResponseAsync();
				var responseText = res.GetResponseText();

				var msg = JsonConvert.DeserializeObject<XamarinSocialApp.Droid.Data.VkData.VkMessagesResponse>(responseText);
				msg.Response.RemoveAt(0);

				IList<XamarinSocialApp.Droid.Data.VkData.MessageInDialog> msg1
					= new List<XamarinSocialApp.Droid.Data.VkData.MessageInDialog>();
				foreach (var item in msg.Response)
				{
					msg1.Add(JsonConvert.DeserializeObject<XamarinSocialApp.Droid.Data.VkData.MessageInDialog>(item.ToString()));
				}

				foreach (var item in msg1)
				{
					dialogs.Add(new DataDialogs(user, new List<IMessage>() 
				{ 
					new DataMessage() { Content = item.Body } 
				}));
				}
			}
			catch (Exception ex)
			{

			}

			return dialogs;
		}
		public async Task<bool> SendMessage(DataIUser user, DataIUser friend, string message, enSocialNetwork socialNetwork)
		{
			try
			{
				this.StartRequest();

				switch (socialNetwork)
				{
					case enSocialNetwork.VK:
						await SendVkMessage(user, friend, message);
						break;

					case enSocialNetwork.Twitter:
						await SendTwitterMessage(user, friend, message);
						break;

					default:
						break;
				}
			}
			catch (Exception ex)
			{
				return false;
			}
			finally
			{
				this.StopRequest();
			}

			return true;
		}
        private async Task <DataIUser> LoginToTwitter()
        {
            DataIUser resultUser = null;

            LinqToTwitter.User twitterUser = null;
            try
            {
                TaskCompletionSource <int> ts = new TaskCompletionSource <int>();

                var auth = new OAuth1Authenticator(
                    consumerKey: "YVgafJLg6figpxcFTx9oBhXDw",
                    consumerSecret: "AdNdiuHSHIf5hN6HWnVrC9u6bnW3vVirjEhAFrfabacPIQdh98",
                    requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                    //https://api.twitter.com/oauth/authorize
                    authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                    accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                    callbackUrl: new Uri("https://oauth.vk.com/blank.html"));

                auth.AllowCancel = true;

                auth.Completed += (s, ee) =>
                {
                    if (!ee.IsAuthenticated)
                    {
                        ts.SetResult(0);
                        return;
                    }

                    var twitterCtx = GetTwitterContext();

                    var accounts =
                        from acct in twitterCtx.Account
                        where acct.Type == AccountType.VerifyCredentials
                        select acct;

                    LinqToTwitter.Account account = accounts.SingleOrDefault();

                    twitterUser = account.User;

                    #region unused requests

                    //var searchResponses = (from search in ctx.Search
                    //											 where search.Type == SearchType.Search
                    //											 && search.Query == searchText
                    //											 select search).SingleOrDefault();

                    //var tweets = from tweet in searchResponses.Statuses
                    //						 select new Message
                    //						 {
                    //							 Value = tweet.Text,
                    //							 Id = tweet.TweetIDs,
                    //							 ImageUri = tweet.User.ProfileImageUrl,
                    //							 UserName = tweet.User.ScreenNameResponse,
                    //							 Name = tweet.User.Name,
                    //							 CreatedAt = tweet.CreatedAt,
                    //							 ReTweets = tweet.RetweetCount,
                    //							 Favorite = tweet.FavoriteCount.Value
                    //						 };

                    //var followers = (from follower in twitterCtx.Friendship
                    //								 where follower.Type == FriendshipType.FollowersList &&
                    //											 follower.UserID == "3620214675"
                    //								 select follower).SingleOrDefault();

                    #endregion

                    string uid       = twitterUser.UserIDResponse;
                    string firstName = twitterUser.ScreenNameResponse;

                    TwitterData.TwitterUser twUser = new TwitterData.TwitterUser();
                    twUser.ConsumerKey      = twitterCtx.Authorizer.CredentialStore.ConsumerKey;
                    twUser.ConsumerSecret   = twitterCtx.Authorizer.CredentialStore.ConsumerSecret;
                    twUser.OAuthToken       = twitterCtx.Authorizer.CredentialStore.OAuthToken;
                    twUser.OAuthTokenSecret = twitterCtx.Authorizer.CredentialStore.OAuthTokenSecret;

                    twUser.UserID     = ulong.Parse(uid);
                    twUser.ScreenName = firstName;

                    resultUser = new User()
                    {
                        FirstName     = firstName,
                        Uid           = uid,
                        SerializeInfo = JsonConvert.SerializeObject(twUser),
                        SocialNetwork = enSocialNetwork.Twitter
                    };

                    ts.SetResult(0);
                };

                var intent = auth.GetUI(Forms.Context);
                Forms.Context.StartActivity(intent);
                await ts.Task;
            }
            catch (Exception)
            {
            }
            return(resultUser);
        }
		private async Task<IDialog> GetTwitterDialogWithFriend(DataIUser user, DataIUser friend)
		{
			IDialog dialog = null;
			IUser userInDialog = null;
			IList<IMessage> messages = new List<IMessage>();
 
			try
			{
				TwitterContext context = this.GetTwitterContext(user.SerializeInfo);

				var receivedMessages = await
						(from dm in context.DirectMessage
						 where dm.Type == DirectMessageType.SentTo
						 select dm).OrderByDescending(x => x.CreatedAt)
						.ToListAsync();

				var sentMessages = await
						(from dm in context.DirectMessage
						 where dm.Type == DirectMessageType.SentBy
						 select dm).OrderByDescending(x => x.CreatedAt)
						.ToListAsync();

				foreach (var message in receivedMessages)
				{
					if (message.SenderID.ToString() == friend.Uid)
					{
						userInDialog = new User() { FirstName = message.Sender.ScreenNameResponse };
						messages.Add(new DataMessage() { Content = message.Text, Sender = userInDialog, DateMessage = message.CreatedAt.ToString() });
					}
				}

				foreach (var message in sentMessages)
				{
					if (message.RecipientID.ToString() == friend.Uid)
					{
						userInDialog = new User() { FirstName = message.Sender.ScreenNameResponse };
						messages.Add(new DataMessage() { Content = message.Text, Sender = userInDialog, DateMessage = message.CreatedAt.ToString() });
					}
				}

				messages = messages.OrderByDescending(x => x.DateMessage).ToList();

				dialog = new XamarinSocialApp.UI.Data.Implementations.Entities.Databases.Dialog(user, messages);
			}
			catch (Exception)
			{
			}

			return dialog;
		}
		private async Task<DataIUser> GetTwitterInfoRequest(DataIUser user)
		{
			return user;
		}
        private async Task <IDialog> GetTwitterDialogWithFriend(DataIUser user, DataIUser friend)
        {
            IDialog          dialog       = null;
            IUser            userInDialog = null;
            IList <IMessage> messages     = new List <IMessage>();

            try
            {
                TwitterContext context = this.GetTwitterContext(user.SerializeInfo);

                var receivedMessages = await
                                           (from dm in context.DirectMessage
                                           where dm.Type == DirectMessageType.SentTo
                                           select dm).OrderByDescending(x => x.CreatedAt)
                                       .ToListAsync();

                var sentMessages = await
                                       (from dm in context.DirectMessage
                                       where dm.Type == DirectMessageType.SentBy
                                       select dm).OrderByDescending(x => x.CreatedAt)
                                   .ToListAsync();

                foreach (var message in receivedMessages)
                {
                    if (message.SenderID.ToString() == friend.Uid)
                    {
                        userInDialog = new User()
                        {
                            FirstName = message.Sender.ScreenNameResponse
                        };
                        messages.Add(new DataMessage()
                        {
                            Content = message.Text, Sender = userInDialog, DateMessage = message.CreatedAt.ToString()
                        });
                    }
                }

                foreach (var message in sentMessages)
                {
                    if (message.RecipientID.ToString() == friend.Uid)
                    {
                        userInDialog = new User()
                        {
                            FirstName = message.Sender.ScreenNameResponse
                        };
                        messages.Add(new DataMessage()
                        {
                            Content = message.Text, Sender = userInDialog, DateMessage = message.CreatedAt.ToString()
                        });
                    }
                }

                messages = messages.OrderByDescending(x => x.DateMessage).ToList();

                dialog = new XamarinSocialApp.UI.Data.Implementations.Entities.Databases.Dialog(user, messages);
            }
            catch (Exception)
            {
            }

            return(dialog);
        }
 private async Task <DataIUser> GetTwitterInfoRequest(DataIUser user)
 {
     return(user);
 }
		public async Task<IDialog> GetDialogWithFriend(DataIUser user, enSocialNetwork socialNetwork, IUser friend)
		{
			IDialog dialog = null;

			try
			{
				switch (socialNetwork)
				{
					case enSocialNetwork.VK:
						dialog = await GetVkDialogWithFriend(user, friend);
						break;

					case enSocialNetwork.Twitter:
						dialog = await GetTwitterDialogWithFriend(user, friend);
						break;

					default:
						break;
				}
			}
			catch (Exception ex)
			{
			}

			this.StopRequest();

			return dialog;
		}
		public async Task<IEnumerable<IDialog>> GetDialogs(DataIUser user, enSocialNetwork socialNetwork)
		{
			Account acc = Account.Deserialize(user.SerializeInfo);
			var request = new OAuth2Request("GET", new Uri("https://api.vk.com/method/messages.getDialogs"), null, acc);

			request.Parameters.Add("count", "200");
			request.Parameters.Add("v", "5.37");

			var res = await request.GetResponseAsync();
			var responseText = res.GetResponseText();

			var msg = JsonConvert.DeserializeObject<XamarinSocialApp.Droid.Data.VkData.VkDialogsResponse>(responseText);

			IList<IDialog> dialogs = new List<IDialog>();

			foreach (var item in msg.Response.Messages)
			{
				IUser userDialog = new User() { Uid = item.Message.UserId, SerializeInfo = user.SerializeInfo };
				//var userDialog = await GetUserInfoRequest(item.Message.UserId, acc, socialNetwork);
				dialogs.Add(new DataDialogs(userDialog, new List<IMessage>() 
				{ 
					new DataMessage() { Content = item.Message.Body } 
				}));
			}

			return dialogs;
		}
		private async Task<IDialog> GetVkDialogWithFriend(DataIUser user, IUser friend)
		{
			IDialog dialog = null;
			try
			{
				Account acc = Account.Deserialize(user.SerializeInfo.ToString());

				this.StartRequest();

				var request = new OAuth2Request("GET", new Uri("https://api.vk.com/method/messages.getHistory"), null, acc);

				request.Parameters.Add("user_id", friend.Uid);
				request.Parameters.Add("count", "200");

				var res = await request.GetResponseAsync();
				var responseText = res.GetResponseText();

				var msg = JsonConvert.DeserializeObject<XamarinSocialApp.Droid.Data.VkData.VkMessagesResponse>(responseText);
				msg.Response.RemoveAt(0);

				IList<XamarinSocialApp.Droid.Data.VkData.MessageInDialog> msg1
					= new List<XamarinSocialApp.Droid.Data.VkData.MessageInDialog>();
				foreach (var item in msg.Response)
				{
					msg1.Add(JsonConvert.DeserializeObject<XamarinSocialApp.Droid.Data.VkData.MessageInDialog>(item.ToString()));
				}

				IList<IMessage> messages = new List<IMessage>();

				foreach (var item in msg1)
				{
					messages.Add(new DataMessage() { Content = item.Body, Sender = item.UserId == user.Uid ? user : friend });
				}

				dialog = new XamarinSocialApp.UI.Data.Implementations.Entities.Databases.Dialog(user, messages);
			}
			catch (Exception)
			{
			}

			return dialog;
		}
		public async Task<IEnumerable<DataIUser>> ShowUserFriends(DataIUser user, enSocialNetwork enSocialNetwork)
		{
			Account acc = Account.Deserialize(user.SerializeInfo);
			var request = new OAuth2Request("GET", new Uri("https://api.vk.com/method/friends.get"), null, acc);

			request.Parameters.Add("fields", "nickname");
			request.Parameters.Add("order", "hints");

			var res = await request.GetResponseAsync();
			var responseText = res.GetResponseText();

			var listFriendsIds = JsonConvert.DeserializeObject<XamarinSocialApp.Droid.Data.VkData.VkUsers>(responseText);

			IList<DataIUser> friends = new List<DataIUser>();

			foreach (var friend in listFriendsIds.response)
			{
				friends.Add(new DataUser() { FirstName = friend.first_name, LastName = friend.last_name });
			}

			return friends;
		}