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); }
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); } }
internal static void DeleteService(Rbr_Db pDb, ServiceDto pService) { if (pService.ServiceType == ServiceType.Retail) { InventoryLotRow[] _inventoryLotRows = pDb.InventoryLotCollection.GetByService_id(pService.ServiceId); if (_inventoryLotRows.Length > 0) { throw new Exception("Inventory exists for Service [" + pService.DisplayName + "]; Cannot delete."); } } CustomerRouteManager.Delete(pDb, pService.DefaultRoute); Delete(pDb, pService.ServiceId); //pDb.AddChangedObject(new ServiceKey(TxType.Delete, pService.ServiceId)); if (pService.PayphoneSurcharge != null) { pDb.PayphoneSurchargeCollection.DeleteByPrimaryKey(pService.PayphoneSurchargeId); } pDb.ScheduleCollection.DeleteByPrimaryKey(pService.SweepScheduleId); }
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); }