Ejemplo n.º 1
0
        public static void DeleteAcct(CustomerAcctDto pCustomerAcct)
        {
            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pCustomerAcct)) {
                    //TODO: HasCDRs should become CustomerAcct property !!!
                    if (CDRController.HasCDRsByCustomerAcctId(pCustomerAcct.CustomerAcctId))
                    {
                        pCustomerAcct.Status = Status.Archived;
                        CustomerAcctManager.UpdateAcct(_db, pCustomerAcct);
                        return;
                    }

                    LoadBalancingMapManager.Delete(_db, pCustomerAcct);

                    if (pCustomerAcct.ServiceType == ServiceType.Retail)
                    {
                        int _retailAcctsCount = RetailAccountManager.Instance.GetCount(_db, pCustomerAcct.CustomerAcctId);
                        if (_retailAcctsCount > 0)
                        {
                            throw new Exception("Cannot delete Customer Account, it has Retail Accounts.");
                        }
                        ServiceManager.SaveAccessNumbers(_db, pCustomerAcct);                         //delete/unassign CustomerAcct's AccessNumbers...
                    }

                    CustomerAcctManager.DeleteResellAccountByCustomerAcctId(_db, pCustomerAcct.CustomerAcctId);
                    CustomerAcctManager.DeleteDialPeersByCustomerAcctId(_db, pCustomerAcct.CustomerAcctId);
                    CustomerAcctManager.DeleteAcct(_db, pCustomerAcct.CustomerAcctId);

                    //if (pCustomerAcct.ServiceDto.IsDedicated) {
                    //	ServiceManager.DeleteService(_db, pCustomerAcct.ServiceDto);
                    //}
                    _tx.Commit();
                }
            }
        }