using System.Collections.Generic;
using MECF.Framework.Common.Account.Extends;
using MECF.Framework.Common.Account.Permissions;
using MECF.Framework.UI.Core.Accounts;
using OpenSEMI.ClientBase.ServiceProvider;

namespace MECF.Framework.UI.Client.ClientBase
{
    public class RoleAccountProvider : IProvider
    {
        private static RoleAccountProvider _Instance = null;
        public static RoleAccountProvider Instance
        {
            get
            {
                if (_Instance == null)
                {
                    _Instance = new RoleAccountProvider();
                    _Instance.Create();
                }
                return _Instance;
            }
        }

        public void Create()
        {

        }

        #region Account Operations

        public List<AccountEx> GetAccounts()
        {
            return AccountClient.Instance.Service.GetAccounts();
        }

        public bool UpdateAccount(AccountEx p_newAccount)
        {
            return AccountClient.Instance.Service.UpdateAccountEx(p_newAccount);
        }

        public bool DeleteAccount(string p_strUserID)
        {
            return AccountClient.Instance.Service.DeleteAccountEx(p_strUserID);
        }
        
        #endregion

        #region Roles Operations

        public List<Role> GetRoles()
        {
            return AccountClient.Instance.Service.GetRoles();
        }

        public bool UpdateRole(Role p_newRole)
        {
            return AccountClient.Instance.Service.UpdateRole(p_newRole);
        }

        public bool DeleteRole(string p_strRoleID)
        {
            return AccountClient.Instance.Service.DeleteRole(p_strRoleID);
        }

        public string GetAvailableID()
        {
            return AccountClient.Instance.Service.GetAvailableRoleID();
        }

        #endregion

        #region Permission Operations

        public List<AppMenu> GetAccessibleMenusByRole(string roleId)
        {
            return AccountClient.Instance.Service.GetAccessibleMenusByRole(roleId);
        }

        public MenuPermissionEnum GetMenuPermission(string roleId, string menuName)
        {
            return AccountClient.Instance.Service.GetMenuPermission(roleId, menuName);
        }

        #endregion
    }
}
