Ejemplo n.º 1
0
        public IActionResult Delete(int id)
        {
            if (id == 0)
            {
                return(BadRequest());
            }
            var from_db   = _db.Users.FirstOrDefault(db => db.Id == id);
            var isPartner = _db.Partners.FirstOrDefault(db => db.UserId == id);

            if (from_db == null)
            {
                return(BadRequest());
            }

            if (isPartner != null)
            {
                var haveMoney = _db.Banks.FirstOrDefault(db => db.Id == isPartner.BankId);
                if (haveMoney != null && haveMoney.Karta != 0)
                {
                    return(BadRequest("You can not delete your Accout cause your have a money"));
                }
                _db.Partners.Remove(isPartner);
            }
            _db.Remove(from_db);
            _db.SaveChanges();
            return(Ok());
        }
        public IActionResult Delete(int id)
        {
            if (id == 0)
            {
                return(BadRequest());
            }
            var from_db = _db.Tickets.FirstOrDefault(db => db.Id == id);

            if (from_db == null)
            {
                return(BadRequest());
            }
            _db.Remove(from_db);
            _db.SaveChanges();
            return(Ok());
        }