using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using EQNetwork;
using EQNetwork.Objects;
using EQNetwork.Services;
using EQNetwork.Utility;

namespace EQNetwork.Controllers
{
    public class User_FacebookFindFriends_Controller
    {
        private EQProcess _eq;

        public string Search;
        public Db.SocialSearchType SocialSearchType = Db.SocialSearchType.SearchAll;
        public PagingParameters PagingParameters;

        public List<Friend> Friends = new List<Friend>();
        public bool? HasMore = null;

        public User_FacebookFindFriends_Controller(EQProcess eq) { _eq = eq; }

        public void Start(Action<EQException> onComplete)
        {
            HasMore = null;
            _eq.UserService.FacebookFindFriends(Search, SocialSearchType, PagingParameters,
                (List<Friend> friends, bool hasMore, EQException ex) => // onComplete
                {
                    Friends = friends;
                    HasMore = hasMore;
                    onComplete(ex);
                });
        }

        public void More(Action<EQException> onComplete)
        {
            if (HasMore == false)
                return;

            HasMore = null;
            PagingParameters.NextPage();

            _eq.UserService.FacebookFindFriends(Search, SocialSearchType, PagingParameters,
                (List<Friend> friends, bool hasMore, EQException ex) => // onComplete
                {
                    Friends = friends;
                    HasMore = hasMore;
                    onComplete(ex);
                });
        }
    }
}
