using PDF_Office.Model.CloudDrive;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PDF_Office.ViewModels.HomePanel.CloudDrive
{
    public class CloudDriveContentViewModel : BindableBase
    {


        public DelegateCommand<CloudBoxItem> CheckDriveCommand { get; set; }
        public DelegateCommand<CloudBoxItem> CheckDriveLoginUserCommand { get; set; }

        private CloudDriveManager Manager =>CloudDriveManager.GetInstance();
        public event EventHandler<bool> IshowContentHandler;
      
        public CloudDriveContentViewModel()
        {
            CheckDriveCommand = new DelegateCommand<CloudBoxItem>(CheckDrive);
            CheckDriveLoginUserCommand = new DelegateCommand<CloudBoxItem>(CheckDriveLoginUser);
          
        }

        public void LoadUsers()
        {
            var result = Manager.LoadedUsers();

            IshowContentHandler?.Invoke(null, !result);
        }

        public async void CheckDrive(CloudBoxItem cloudDriveItem)
        {
            bool result = false;
            result = await Manager.LoginUser(cloudDriveItem.CloudDiskType);
            IshowContentHandler?.Invoke(null, !result);
        }

        public async void CheckDriveLoginUser(CloudBoxItem cloudDriveItem)
        {
            bool result = false;
            result = await Manager.LoginUser(cloudDriveItem.CloudDiskType);
        }



    }
}
