Exemple #1
0
        static ServiceDto mapToService(ServiceRow pServiceRow, RoutingPlanDto pDefaultRoutingPlan, PayphoneSurchargeRow pPayphoneSurchargeRow, ICollection <AccessNumberListRow> pAccessNumberListRows, RatingInfoDto pDefaultRatingInfo)
        {
            if (pServiceRow == null)
            {
                return(null);
            }

            var _service = new ServiceDto
            {
                ServiceId            = pServiceRow.Service_id,
                Name                 = pServiceRow.Name,
                Status               = ((Status)pServiceRow.Status),
                ServiceType          = pServiceRow.ServiceType,
                RetailType           = pServiceRow.RetailType,
                IsShared             = pServiceRow.IsShared,
                RatingType           = pServiceRow.RatingType,
                PinLength            = pServiceRow.Pin_length,
                DefaultRatingInfo    = pDefaultRatingInfo,
                DefaultRoutingPlan   = pDefaultRoutingPlan,
                AccessNumbers        = mapToAccessNumbers(pAccessNumberListRows),
                PayphoneSurcharge    = RetailAccountManager.MapToPayphoneSurcharge(pPayphoneSurchargeRow),
                SweepScheduleId      = pServiceRow.Sweep_schedule_id,
                SweepFee             = pServiceRow.Sweep_fee,
                SweepRule            = pServiceRow.Sweep_rule,
                BalancePromptType    = pServiceRow.BalancePromptType,
                BalancePromptPerUnit = pServiceRow.Balance_prompt_per_unit,
                VirtualSwitchId      = pServiceRow.Virtual_switch_id
            };

            return(_service);
        }
Exemple #2
0
        internal static void AddService(Rbr_Db pDb, ServiceDto pService, int[] pSelectedBaseRouteIds)
        {
            //TODO: NEW DAL - VirtualSwitch
            pService.VirtualSwitchId = AppConstants.DefaultVirtualSwitchId;

            if (pService.RetailType == RetailType.PhoneCard)
            {
                if (pService.PayphoneSurcharge != null)
                {
                    pService.PayphoneSurcharge.PayphoneSurchargeId = RetailAccountManager.AddPayphoneSurcharge(pDb, pService.PayphoneSurcharge);
                }
            }
            else
            {
                pService.PayphoneSurcharge = null;
            }

            ServiceRow _serviceRow = mapToServiceRow(pService);

            Add(pDb, _serviceRow);
            pService.ServiceId = _serviceRow.Service_id;

            //Create Default WholesaleRoute
            int _defaultWholesaleRouteId;

            CustomerRouteManager.AddDefault(pDb, pService, out _defaultWholesaleRouteId);
            pService.DefaultRoute.RatedRouteId = _defaultWholesaleRouteId;

            CustomerRouteManager.Add(pDb, pService.ServiceId, pSelectedBaseRouteIds);
        }
Exemple #3
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);
 }
        internal static void DeleteCustomerSupportGroup(Rbr_Db pDb, int pGroupId)
        {
            CustomerSupportGroupRow _customerSupportGroupRow = pDb.CustomerSupportGroupCollection.GetByPrimaryKey(pGroupId);

            PersonRow[] _personRows = pDb.PersonCollection.GetByGroup_id(pGroupId);
            foreach (PersonRow _personRow in _personRows)
            {
                if (RetailAccountManager.HasPayments(pDb, _personRow.Person_id))
                {
                    throw new InvalidOperationException("Cannot Delete Group [" + _customerSupportGroupRow.Description + "]; At least one Representative [Login="******"] in this Group has a Payment History.");
                }
            }
            pDb.PersonCollection.DeleteByGroup_id(pGroupId);
            pDb.CustomerSupportGroupCollection.DeleteByPrimaryKey(pGroupId);
        }
Exemple #5
0
        internal static void UpdateService(Rbr_Db pDb, ServiceDto pService)
        {
            if (pService.IsRatingEnabled)
            {
                //Update Service's Default RatingInfo
                //NOTE: DefaultRatingInfo is always created on Add, no metter is RatingEnabled or not
                RatingManager.UpdateRatingInfo(pDb, pService.DefaultRatingInfo);

                //check RatingInfo for all others WholesaleRoutes, if they have no RatingInfo - create it
                //if WholesaleRoute already have Rates, just leave it as is
                WholesaleRouteRow[] _wholesaleRouteRows = pDb.WholesaleRouteCollection.GetByService_id(pService.ServiceId);
                foreach (WholesaleRouteRow _wholesaleRouteRow in _wholesaleRouteRows)
                {
                    WholesaleRateHistoryRow[] _wholesaleRateHistoryRows = pDb.WholesaleRateHistoryCollection.GetByWholesale_route_id(_wholesaleRouteRow.Wholesale_route_id);
                    if (_wholesaleRateHistoryRows.Length == 0)
                    {
                        //route has no rates, create them using Default
                        RatingManager.AddDefaultRatingInfo(pDb, _wholesaleRouteRow.Wholesale_route_id, pService.DefaultRatingInfo, RouteType.Wholesale);
                    }
                }

                if (pService.PayphoneSurcharge != null)
                {
                    if (pService.PayphoneSurcharge.PayphoneSurchargeId == 0)
                    {
                        pService.PayphoneSurcharge.PayphoneSurchargeId = RetailAccountManager.AddPayphoneSurcharge(pDb, pService.PayphoneSurcharge);
                    }
                    else
                    {
                        RetailAccountManager.UpdatePayphoneSurcharge(pDb, pService);
                    }
                }
            }
            CustomerRouteManager.Update(pDb, pService.DefaultRoute);

            ServiceRow _serviceRow = mapToServiceRow(pService);

            Update(pDb, _serviceRow);
            //pDb.AddChangedObject(new ServiceKey(TxType.Delete, pService.ServiceId));

            ServiceRow _originalServiceRow = Get(pDb, pService.ServiceId);

            if (pService.PayphoneSurcharge == null && !_originalServiceRow.IsPayphone_surcharge_idNull)
            {
                pDb.PayphoneSurchargeCollection.DeleteByPrimaryKey(_originalServiceRow.Payphone_surcharge_id);
            }
        }