Ejemplo n.º 1
0
 public Account ReadAccount(int id)
 {
     if ((int)account.AccountLevel <= 1 && id <= 0)
     {
         throw new NotImplementedException();
     }
     return(AccountMehod.Read(id));
 }
Ejemplo n.º 2
0
 public List <Account> ReadAccount()
 {
     if ((int)account.AccountLevel <= 1)
     {
         throw new NotImplementedException();
     }
     return(AccountMehod.Read());
 }
Ejemplo n.º 3
0
 public List <Account> FindAccount(string search)
 {
     if ((int)account.AccountLevel <= 1)
     {
         throw new NotImplementedException();
     }
     return(AccountMehod.Find(search));
 }
Ejemplo n.º 4
0
        public bool UpdateAccount(int id, string fullname, string address, string phone)
        {
            bool isValid = !IsStringEmpty(fullname) && id > 0 && (account.ID == id || account.AccountLevel >= AccountLevelEnums.Librarian);

            if (!isValid)
            {
                return(false);
            }
            AccountMehod.Update(new Account(fullname, address, phone, id));
            return(true);
        }
Ejemplo n.º 5
0
        public bool RemoveAccount(int id)
        {
            bool isvalid = account.ID != id && account.AccountLevel >= AccountLevelEnums.Librarian;

            if (!isvalid)
            {
                return(false);
            }
            AccountMehod.Remove(id);
            return(true);
        }
Ejemplo n.º 6
0
        public bool SignIn(string fullname, string address, string phone, AccountLevelEnums level, string username, string password)
        {
            bool isValid = !IsStringEmpty(fullname, username, password) && password.Length >= 8 && level != 0 && (account.AccountLevel >= level || level == AccountLevelEnums.Patron);

            if (!isValid)
            {
                return(false);
            }
            if (AccountMehod.CountUsername(username) != 0)
            {
                return(false);
            }
            AccountMehod.Add(new Account(fullname, address, phone, DateTime.Today, level, username, password));
            return(true);
        }
Ejemplo n.º 7
0
        public bool Login(string username, string password)
        {
            bool isValid = !IsStringEmpty(username, password);

            if (!isValid)
            {
                return(false);
            }

            int id = AccountMehod.Login(username, password);

            if (id > 0)
            {
                _account = AccountMehod.Read(id);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 8
0
        public bool ChangePassword(string username, string oldPassword, string newPassword)
        {
            bool isValid = !IsStringEmpty(username, oldPassword, newPassword);

            if (!isValid)
            {
                return(false);
            }
            try
            {
                AccountMehod.ChangePassword(username, oldPassword, newPassword);
            }
            catch (NotImplementedException)
            {
                return(false);
            }

            return(true);
        }