Example #1
0
        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);
        }