public static void AddEndpoint(EndPointRow pEndPointRow, EndpointContext pEndpointContext) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndPointRow, pEndpointContext)) { //TODO: NEW DAL - VirtualSwitch pEndPointRow.Virtual_switch_id = AppConstants.DefaultVirtualSwitchId; EndpointManager.Add(_db, pEndPointRow, pEndpointContext); //CarrierAcctManager.AddDialPeer(_db, pEndPointRow, pEndpointContext); if (pEndpointContext.CarrierAcctEPMapRowToAdd != null && pEndpointContext.CarrierAcctEPMapRowToAdd.Length > 0) { foreach (var _carrierAcctEPMapRow in pEndpointContext.CarrierAcctEPMapRowToAdd) { _carrierAcctEPMapRow.End_point_id = pEndPointRow.End_point_id; CarrierAcctManager.AddDialPeer(_db, _carrierAcctEPMapRow, pEndPointRow); } } if (pEndpointContext.CustomerAcct != null) { if (pEndpointContext.CustomerAcct.ServiceDto.AccessNumbers != null && pEndpointContext.CustomerAcct.ServiceDto.AccessNumbers.Length > 0) { foreach (var _accessNumber in pEndpointContext.CustomerAcct.ServiceDto.AccessNumbers) { var _newDialPeer = new DialPeerRow { End_point_id = pEndPointRow.End_point_id, Prefix_in = _accessNumber.Number.ToString(), Customer_acct_id = pEndpointContext.CustomerAcct.CustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _newDialPeer, pEndPointRow); } } else { var _newDialPeer = new DialPeerRow { End_point_id = pEndPointRow.End_point_id, Prefix_in = pEndpointContext.CustomerAcct.PrefixIn, Customer_acct_id = pEndpointContext.CustomerAcct.CustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _newDialPeer, pEndPointRow); } } _tx.Commit(); } } }
public static void AddDialPeersForEndpoint(short pEndpointId, string pPrefix, short pCustomerAcctId, RetailType pRetailType) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndpointId, pPrefix, pCustomerAcctId, pRetailType)) { var _endpointRow = EndpointManager.Get(_db, pEndpointId); if (_endpointRow == null) { throw new Exception(string.Format("Endpoint NOT FOUND, EndpointId={0}", pEndpointId)); } var _dialPeerRow = CustomerAcctManager.GetDialPeerRow(_db, pEndpointId, pPrefix); if (_dialPeerRow == null) { _dialPeerRow = new DialPeerRow { End_point_id = pEndpointId, Prefix_in = pPrefix, Customer_acct_id = pCustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _dialPeerRow, _endpointRow); } //-- If Retail, add accessNumber DialPeers if (pRetailType == RetailType.PhoneCard || pRetailType == RetailType.Residential) { var _accessNumberRows = ServiceManager.GetAccessNumbers(_db, pCustomerAcctId); foreach (var _accessNumberRow in _accessNumberRows) { _dialPeerRow = new DialPeerRow { End_point_id = pEndpointId, Prefix_in = _accessNumberRow.Access_number.ToString(), Customer_acct_id = pCustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _dialPeerRow, _endpointRow); } } _tx.Commit(); } } }
public static void AddDialPeers(EndPointRow[] pEndpointRows, CustomerAcctDto pCustomerAcct) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndpointRows, pCustomerAcct)) { foreach (var _endPointRow in pEndpointRows) { if (pCustomerAcct != null) { var _newDialPeer = new DialPeerRow { End_point_id = _endPointRow.End_point_id, Prefix_in = pCustomerAcct.PrefixIn, Customer_acct_id = pCustomerAcct.CustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _newDialPeer, _endPointRow); } } _tx.Commit(); } } }
public static void ReassignDialPeer(EndPointRow pEndpointRow, CustomerAcctDto pFromCustomerAcct, CustomerAcctDto pToCustomerAcct) { if (pEndpointRow.WithInPrefixes || pFromCustomerAcct.WithPrefixes || pToCustomerAcct.WithPrefixes) { throw new Exception("Invalid operation: expecting Endpoint and Customer without Prefixes ONLY."); } using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndpointRow, pFromCustomerAcct, pToCustomerAcct)) { CustomerAcctManager.DeleteDialPeer(_db, pEndpointRow.End_point_id, pFromCustomerAcct.PrefixIn); var _newDialPeerRow = new DialPeerRow { End_point_id = pEndpointRow.End_point_id, Prefix_in = pToCustomerAcct.PrefixIn, Customer_acct_id = pToCustomerAcct.CustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _newDialPeerRow, pEndpointRow); _tx.Commit(); } } }
public static void AddChangingEndpointPrefixType(EndPointRow pEndpointRow, CustomerAcctDto pCustomerAcct) { using (var _db = new Rbr_Db()) { using (var _tx = new Transaction(_db, pEndpointRow, pCustomerAcct)) { EndpointManager.UpdatePrefixType(_db, pEndpointRow, pCustomerAcct.PrefixInTypeId); var _endpointContext = new EndpointContext { CustomerAcct = pCustomerAcct }; if (_endpointContext.CustomerAcct != null) { var _newDialPeer = new DialPeerRow { End_point_id = pEndpointRow.End_point_id, Prefix_in = _endpointContext.CustomerAcct.PrefixIn, Customer_acct_id = _endpointContext.CustomerAcct.CustomerAcctId }; CustomerAcctManager.AddDialPeer(_db, _newDialPeer, pEndpointRow); } _tx.Commit(); } } }