Example #1
0
        static ServiceDto getService(Rbr_Db pDb, ServiceRow pServiceRow, short pCustomerAcctId)
        {
            if (pServiceRow == null)
            {
                return(null);
            }
            AccessNumberListRow[] _accessNumberRows;
            if (pCustomerAcctId > 0)
            {
                _accessNumberRows = pDb.AccessNumberListCollection.GetByCustomer_acct_id(pCustomerAcctId);
            }
            else
            {
                _accessNumberRows = pDb.AccessNumberListCollection.GetByService_id(pServiceRow.Service_id);
            }

            var _defaultRoutingPlan = RoutingManager.GetRoutingPlan(pDb, pServiceRow.Default_routing_plan_id);

            PayphoneSurchargeRow _payphoneSurchargeRow = null;

            if (!pServiceRow.IsPayphone_surcharge_idNull)
            {
                _payphoneSurchargeRow = pDb.PayphoneSurchargeCollection.GetByPrimaryKey(pServiceRow.Payphone_surcharge_id);
            }

            //if (pServiceRow.IsRatingEnabled) {
            //NOTE: DefaultRatingInfo is always created no metter what
            //and it should be loaded as well no metter what
            var _defaultRatingInfo = getDefaultServiceRatingInfo(pDb, pServiceRow.Service_id);
            //}

            var _service = mapToService(pServiceRow, _defaultRoutingPlan, _payphoneSurchargeRow, _accessNumberRows, _defaultRatingInfo);

            //NOTE: DefaultServiceRoute's ID = [negative] -ServiceId
            var _defaultWholesaleRouteRow = pDb.WholesaleRouteCollection.GetByPrimaryKey(-pServiceRow.Service_id);

            _service.DefaultRoute = CustomerRouteManager.Get(pDb, _service, _service.DefaultRoutingPlanId, _defaultWholesaleRouteRow);
            return(_service);
        }