internal static BaseRouteDto GetProperRoute(Rbr_Db pDb, int pCallingPlanId, int pCountryId)
        {
            var _properRouteRow = GetProper(pDb, pCallingPlanId, pCountryId);

            if (_properRouteRow == null)
            {
                return(null);
            }

            var _callingPlan   = CallingPlanManager.GetCallingPlan(pDb, pCallingPlanId);
            var _country       = CallingPlanManager.GetCountry(pDb, pCountryId);
            var _dialCodeCount = CallingPlanManager.GetDialCodeCount(pDb, _properRouteRow.Route_id);
            var _routeState    = (_dialCodeCount > 0) ? RouteState.Valid : RouteState.NoDialCodes;

            return(mapToBaseRoute(_properRouteRow, _country, _callingPlan, _routeState));
        }
        //internal static BaseRouteDto[] MapToBaseRoutes(Rbr_Db pDb, RouteRow[] pRouteRows, CountryRow[] pCountryRows, CallingPlanRow pCallingPlanRow) {
        //  ArrayList _list = new ArrayList();
        //  if (pRouteRows != null) {
        //    foreach (RouteRow _routeRow in pRouteRows) {
        //      CountryRow _countryRow = getCountry(_routeRow.Country_id, pCountryRows);
        //      int _dialCodeCount = pDb.DialCodeCollection.GetCount( /*_routeRow.Calling_plan_id,*/ _routeRow.Route_id);
        //      RouteState _routeState = ( _dialCodeCount > 0 ) ? RouteState.Valid : RouteState.NoDialCodes;
        //      BaseRouteDto _baseRoute = MapToBaseRoute(_routeRow, _countryRow, pCallingPlanRow, _routeState);
        //      _list.Add(_baseRoute);
        //    }
        //  }
        //  return (BaseRouteDto[])_list.ToArray(typeof(BaseRouteDto));
        //}

        public static BaseRouteDto MapToBaseRoute(Rbr_Db pDb, RouteRow pRouteRow)          //}, CountryRow pCountryRow, CallingPlanRow pCallingPlanRow, RouteState pRouteState) {
        {
            if (pRouteRow == null)
            {
                return(null);
            }

            var _baseRoute = new BaseRouteDto();

            _baseRoute.BaseRouteId   = pRouteRow.Route_id;
            _baseRoute.Name          = pRouteRow.Name;
            _baseRoute.BaseStatus    = pRouteRow.RouteStatus;
            _baseRoute.CallingPlan   = CallingPlanManager.GetCallingPlan(pDb, pRouteRow.Calling_plan_id);
            _baseRoute.Country       = CallingPlanManager.GetCountry(pDb, pRouteRow.Country_id);
            _baseRoute.RoutingNumber = pRouteRow.Routing_number;
            _baseRoute.Version       = pRouteRow.Version;
            _baseRoute.RouteState    = RouteState.Valid;

            return(_baseRoute);
        }
        internal static BaseRouteDto GetBaseRoute(Rbr_Db pDb, int pBaseRouteId)
        {
            if (pBaseRouteId == 0)
            {
                return(null);
            }

            var _routeRow = Get(pDb, pBaseRouteId);

            if (_routeRow == null)
            {
                return(null);
            }
            var _callingPlan = CallingPlanManager.GetCallingPlan(pDb, _routeRow.Calling_plan_id);
            var _country     = CallingPlanManager.GetCountry(pDb, _routeRow.Country_id);

            var _dialCodeCount = pDb.DialCodeCollection.GetCount(_routeRow.Route_id);
            var _routeState    = (_dialCodeCount > 0) ? RouteState.Valid : RouteState.NoDialCodes;

            return(mapToBaseRoute(_routeRow, _country, _callingPlan, _routeState));
        }