public bool DeleteRenterByIdentity(string identity)
        {
            bool result;
            var  searchRenter = _context.NGTHUEs.FirstOrDefault(renter => renter.CMND == identity);

            if (searchRenter == null)
            {
                result = false;
            }
            else
            {
                try
                {
                    _context.NGTHUEs.Remove(searchRenter);
                    _context.SaveChanges();
                    result = true;
                }
                catch (Exception e)
                {
                    result = false;
                    throw e;
                }
            }
            return(result);
        }
Beispiel #2
0
        public bool UpdateRenterByIdentity(NGTHUE updateInfo)
        {
            bool result;
            var  searchRenter = _context.NGTHUEs.FirstOrDefault(renter => renter.CMND == updateInfo.CMND);

            if (searchRenter == null)
            {
                try
                {
                    searchRenter = updateInfo;
                    _context.SaveChanges();
                    result = true;
                }
                catch (Exception e)
                {
                    result = false;
                    throw e;
                }
            }
            else
            {
                result = false;
            }

            return(result);
        }
Beispiel #3
0
        public bool SaveAccount(ACCOUNT newAccount)
        {
            bool result;
            var  searchAccount = _context.ACCOUNTs.FirstOrDefault(acc => acc.IDUSER == newAccount.IDUSER);

            if (searchAccount == null)
            {
                try
                {
                    _context.ACCOUNTs.Add(newAccount);
                    _context.SaveChanges();
                    result = true;
                }
                catch (Exception e)
                {
                    result = false;
                    throw e;
                }
            }
            else
            {
                result = false;
            }
            return(result);
        }
        public bool InsertNewRenter(NGTHUE newRenter)
        {
            bool result;
            var  searchRenter = _context.NGTHUEs.FirstOrDefault(renter => renter.CMND == newRenter.CMND);

            if (searchRenter != null)
            {
                result = false;
            }
            else
            {
                try
                {
                    _context.NGTHUEs.Add(newRenter);
                    _context.SaveChanges();
                    result = true;
                }
                catch (Exception e)
                {
                    result = false;
                    throw e;
                }
            }
            return(result);
        }
        public bool DeleteAccountByName(string userName)
        {
            bool result;
            var  searchUser = _context.ACCOUNTs.FirstOrDefault(acc => acc.IDUSER == userName);

            if (searchUser != null)
            {
                try
                {
                    _context.ACCOUNTs.Remove(searchUser);
                    _context.SaveChanges();
                    result = true;
                }
                catch (Exception e)
                {
                    result = false;
                    throw e;
                }
            }
            else
            {
                result = false;
            }
            return(result);
        }