internal static CustomerAcctSupportMapDto[] GetAllCustomerAcctSupportMaps(Rbr_Db pDb, int pVendorId)
        {
            ArrayList _list = new ArrayList();

            //get mapped
            CustomerAcctSupportMapRow[] _customerAcctSupportMapRows = pDb.CustomerAcctSupportMapCollection.GetByVendor_id(pVendorId);
            foreach (CustomerAcctSupportMapRow _customerAcctSupportMapRow in _customerAcctSupportMapRows)
            {
                CustomerAcctDto _customerAcct = CustomerAcctManager.GetAcct(pDb, _customerAcctSupportMapRow.Customer_acct_id);
                _list.Add(mapToCustomerAcctSupportMap(_customerAcctSupportMapRow, _customerAcct));
            }

            //get unmapped too, as not Assigned
            CustomerAcctDto[] _unmappedCustomerAccts = CustomerAcctManager.GetUnmapped(pDb, pVendorId);
            foreach (CustomerAcctDto _unmappedCustomerAcct in _unmappedCustomerAccts)
            {
                _list.Add(mapToCustomerAcctSupportMap(null, _unmappedCustomerAcct));
            }

            if (_list.Count > 1)
            {
                //TODO: should we sort it by Assigned as well???
                _list.Sort(new GenericComparer(CustomerAcctSupportMapDto.CustomerAcctName_PropName, System.ComponentModel.ListSortDirection.Ascending));
            }
            return((CustomerAcctSupportMapDto[])_list.ToArray(typeof(CustomerAcctSupportMapDto)));
        }
        internal static CustomerAcctSupportMapDto GetCustomerAcctSupportMap(Rbr_Db pDb, short pCustomerAcctId, int pVendorId)
        {
            CustomerAcctSupportMapRow _customerAcctSupportMapRow = pDb.CustomerAcctSupportMapCollection.GetByPrimaryKey(pCustomerAcctId, pVendorId);
            CustomerAcctDto           _customerAcct = CustomerAcctManager.GetAcct(pDb, pCustomerAcctId);

            return(mapToCustomerAcctSupportMap(_customerAcctSupportMapRow, _customerAcct));
        }
示例#3
0
        //-------------------------------------------------- Privates -------------------------------------------------------------

        RetailAccountDto get(Rbr_Db pDb, RetailAccountRow pRetailAccountRow)
        {
            if (pRetailAccountRow != null)
            {
                CustomerAcctRow _customerAcctRow = CustomerAcctManager.Get(pDb, pRetailAccountRow.Customer_acct_id);
                return(get(pDb, _customerAcctRow.Service_id, pRetailAccountRow));
            }
            return(null);
        }
示例#4
0
 static bool hasPayments(Rbr_Db pDb, int pPersonId)
 {
     if (CustomerAcctManager.HasPayments(pDb, pPersonId))
     {
         return(true);
     }
     if (RetailAccountManager.HasPayments(pDb, pPersonId))
     {
         return(true);
     }
     return(false);
 }
示例#5
0
        static void attachAccessNumbers(Rbr_Db pDb, CustomerAcctDto pCustomerAcct, IEnumerable <AccessNumberListRow> pAccessNumberRowsFromView)
        {
            foreach (var _accessNumberRowFromView in pAccessNumberRowsFromView)
            {
                _accessNumberRowFromView.Customer_acct_id = pCustomerAcct.CustomerAcctId;
                _accessNumberRowFromView.Service_id       = pCustomerAcct.ServiceDto.ServiceId;
                var _accessNumberRowFromDb = pDb.AccessNumberListCollection.GetByPrimaryKey(_accessNumberRowFromView.Access_number);
                if (_accessNumberRowFromDb == null || _accessNumberRowFromDb.IsCustomer_acct_idNull)
                {
                    pDb.AccessNumberListCollection.Insert(_accessNumberRowFromView);

                    //-- Add retail_dial_peers
                    var _endpointRows = pDb.EndPointCollection.GetByCustomerAcctId(pCustomerAcct.CustomerAcctId, new[] { Status.Pending, Status.Active, Status.Blocked, Status.Archived });
                    foreach (var _endpointRow in _endpointRows)
                    {
                        var _dialPeerRow = new DialPeerRow
                        {
                            End_point_id     = _endpointRow.End_point_id,
                            Prefix_in        = _accessNumberRowFromView.Access_number.ToString(),
                            Customer_acct_id = pCustomerAcct.CustomerAcctId
                        };
                        CustomerAcctManager.AddDialPeer(pDb, _dialPeerRow, _endpointRow);
                    }
                    continue;
                }

                if (_accessNumberRowFromDb.Customer_acct_id != pCustomerAcct.CustomerAcctId)
                {
                    var _otherCustomerAcctRow = pDb.CustomerAcctCollection.GetByPrimaryKey(_accessNumberRowFromDb.Customer_acct_id);
                    throw new Exception(string.Format("Access Number={0} already in use by other Customer Account={1}", _accessNumberRowFromView.Access_number, _otherCustomerAcctRow.Name));
                }

                _accessNumberRowFromDb.Customer_acct_id = pCustomerAcct.CustomerAcctId;
                _accessNumberRowFromDb.Service_id       = pCustomerAcct.ServiceDto.ServiceId;
                _accessNumberRowFromDb.ScriptType       = _accessNumberRowFromView.ScriptType;
                _accessNumberRowFromDb.ScriptLanguage   = _accessNumberRowFromView.ScriptLanguage;
                _accessNumberRowFromDb.Surcharge        = _accessNumberRowFromView.Surcharge;
                _accessNumberRowFromDb.SurchargeType    = _accessNumberRowFromView.SurchargeType;
                pDb.AccessNumberListCollection.Update(_accessNumberRowFromDb);
                //pDb.AddChangedObject(new AccessNumberKey(TxType.Delete, _accessNumberRowFromDb.Access_number));
            }
        }
示例#6
0
        internal static void UpdatePrefixType(Rbr_Db pDb, EndPointRow pEndpointRow, short pNewPrefixTypeId)
        {
            if (pEndpointRow == null)
            {
                throw new Exception("Invalid operation: Endpoint should not be NULL.");
            }

            bool _endpointHasDialPeers = CustomerAcctManager.GetDialPeerCountByEndpointId(pDb, pEndpointRow.End_point_id) > 0;

            if (_endpointHasDialPeers)
            {
                throw new Exception("Invalid operation: expecting Endpoint without DialPeers.");
            }

            //pDb.AddChangedObject(new EndpointKey(TxType.Delete, pEndpointRow.Ip_address_range));

            pEndpointRow.Prefix_in_type_id = pNewPrefixTypeId;
            pDb.EndPointCollection.Update(pEndpointRow);

            //pDb.AddChangedObject(new EndpointKey(TxType.Add, pEndpointRow.Ip_address_range));
        }
示例#7
0
        static void detachAccessNumbers(Rbr_Db pDb, CustomerAcctDto pCustomerAcct, ICollection <AccessNumberListRow> pAccessNumberRowsFromView, IEnumerable <AccessNumberListRow> pAccessNumberRowsFromDb)
        {
            foreach (var _accessNumberRowFromDb in pAccessNumberRowsFromDb)
            {
                if (deleted(_accessNumberRowFromDb, pAccessNumberRowsFromView))
                {
                    _accessNumberRowFromDb.IsCustomer_acct_idNull = true;
                    _accessNumberRowFromDb.IsService_idNull       = true;
                    pDb.AccessNumberListCollection.DeleteByPrimaryKey(_accessNumberRowFromDb.Access_number);
                    //pDb.AddChangedObject(new AccessNumberKey(TxType.Delete, _accessNumberRowFromDb.Access_number));

                    //-- Remove retail_dial_peers
                    var _dialPeerRows = CustomerAcctManager.GetDialPeersByAcctId(pDb, pCustomerAcct.CustomerAcctId);
                    foreach (var _dialPeerRow in _dialPeerRows)
                    {
                        if (_dialPeerRow.Prefix_in == _accessNumberRowFromDb.Access_number.ToString())
                        {
                            CustomerAcctManager.DeleteDialPeer(pDb, _dialPeerRow.End_point_id, _dialPeerRow.Prefix_in);
                        }
                    }
                    //pDb.AddChangedObject(new CustomerAcctKey(TxType.Delete, pCustomerAcct.CustomerAcctId));
                }
            }
        }