public IActionResult Delete(int ID) { LandingSystem deletedLandingSystem = repository.DeleteLandingSystem(ID); if (deletedLandingSystem != null) { TempData["message"] = $"{deletedLandingSystem.Name} was deleted"; } return(RedirectToAction("List")); }
public IActionResult Edit(LandingSystem landingSystem) { if (ModelState.IsValid) { repository.SaveLandingSystem(landingSystem); TempData["message"] = $"{landingSystem.Name} has been saved...{landingSystem.LandingSystemID}"; return(RedirectToAction("List")); } else { // there is something wrong with the data values return(View(landingSystem)); } }
public virtual void UnregisterFromSystems(MyCubeBlock block) { // Note: ResourceDistributor, WeaponSystem and TemrminalSystem can be null on closing (they are not in the ship but in the logical group). That's why they are null-checked if (ResourceDistributor != null) { ProfilerShort.Begin("Unregister Power producer"); var powerProducer = block.Components.Get <MyResourceSourceComponent>(); if (powerProducer != null) { ResourceDistributor.RemoveSource(powerProducer); } ProfilerShort.BeginNextBlock("Unregister Power consumer"); var powerConsumer = block.Components.Get <MyResourceSinkComponent>(); if (!(block is MyThrust) && powerConsumer != null) { ResourceDistributor.RemoveSink(powerConsumer); } ProfilerShort.End(); var socketOwner = block as IMyRechargeSocketOwner; if (socketOwner != null) { socketOwner.RechargeSocket.ResourceDistributor = null; } } ProfilerShort.Begin("Unregister gun object"); if (WeaponSystem != null) { var weapon = block as IMyGunObject <MyDeviceBase>; if (weapon != null) { WeaponSystem.Unregister(weapon); } } ProfilerShort.BeginNextBlock("Unregister functional block"); if (TerminalSystem != null) { var functionalBlock = block as MyTerminalBlock; if (functionalBlock != null) { TerminalSystem.Remove(functionalBlock); } } // CH: We probably don't need to unregister controller blocks here. It's done in ShipController's OnUnregisteredFromGridSystems /*ProfilerShort.BeginNextBlock("Unregister controller block"); * if (ControlSystem != null) * { * var controllableBlock = block as MyShipController; * if (controllableBlock != null && controllableBlock.ControllerInfo.Controller != null) * ControlSystem.RemoveControllerBlock(controllableBlock); * }*/ ProfilerShort.BeginNextBlock("Unregister inventory block"); var inventoryBlock = (block != null && block.HasInventory) ? block : null; if (inventoryBlock != null && inventoryBlock.HasInventory) { ConveyorSystem.Remove(inventoryBlock); } ProfilerShort.BeginNextBlock("Unregister conveyor block"); var conveyorBlock = block as IMyConveyorEndpointBlock; if (conveyorBlock != null) { ConveyorSystem.RemoveConveyorBlock(conveyorBlock); } ProfilerShort.BeginNextBlock("Unregister segment block"); var segmentBlock = block as IMyConveyorSegmentBlock; if (segmentBlock != null) { ConveyorSystem.RemoveSegmentBlock(segmentBlock); } ProfilerShort.BeginNextBlock("Unregister Reflector light"); var reflectorLight = block as MyReflectorLight; if (reflectorLight != null) { ReflectorLightSystem.Unregister(reflectorLight); } if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT) { ProfilerShort.BeginNextBlock("Unregister wheel"); var wheel = block as MyMotorSuspension; if (wheel != null) { WheelSystem.Unregister(wheel); } } ProfilerShort.BeginNextBlock("Unregister landing gear"); var gear = block as IMyLandingGear; if (gear != null) { LandingSystem.Unregister(gear); } ProfilerShort.BeginNextBlock("Unregister gyro"); var gyro = block as MyGyro; if (gyro != null) { GyroSystem.Unregister(gyro); } ProfilerShort.BeginNextBlock("Unregister camera"); var camera = block as MyCameraBlock; if (camera != null) { CameraSystem.Unregister(camera); } ProfilerShort.BeginNextBlock("block.OnUnregisteredFromGridSystems()"); block.OnUnregisteredFromGridSystems(); ProfilerShort.End(); }
public virtual void RegisterInSystems(MyCubeBlock block) { if (ResourceDistributor != null) { var powerProducer = block.Components.Get <MyResourceSourceComponent>(); if (powerProducer != null) { ResourceDistributor.AddSource(powerProducer); } var powerConsumer = block.Components.Get <MyResourceSinkComponent>(); if (!(block is MyThrust) && powerConsumer != null) { ResourceDistributor.AddSink(powerConsumer); } var socketOwner = block as IMyRechargeSocketOwner; if (socketOwner != null) { socketOwner.RechargeSocket.ResourceDistributor = ResourceDistributor; } } if (WeaponSystem != null) { var weapon = block as IMyGunObject <MyDeviceBase>; if (weapon != null) { WeaponSystem.Register(weapon); } } if (TerminalSystem != null) { var functionalBlock = block as MyTerminalBlock; if (functionalBlock != null) { TerminalSystem.Add(functionalBlock); } } // CH: We probably don't need to register controller blocks here. Block that's being added to a grid should not have a controller set var controllableBlock = block as MyShipController; Debug.Assert(controllableBlock == null || controllableBlock.ControllerInfo.Controller == null, "Controller of added block is not null. Call Cestmir"); /*if (ControlSystem != null) * { * var controllableBlock = block as MyShipController; * if (controllableBlock != null && controllableBlock.ControllerInfo.Controller != null) * ControlSystem.AddControllerBlock(controllableBlock); * }*/ var inventoryBlock = (block != null && block.HasInventory) ? block : null; if (inventoryBlock != null) { ConveyorSystem.Add(inventoryBlock); } var conveyorBlock = block as IMyConveyorEndpointBlock; if (conveyorBlock != null) { conveyorBlock.InitializeConveyorEndpoint(); ConveyorSystem.AddConveyorBlock(conveyorBlock); } var segmentBlock = block as IMyConveyorSegmentBlock; if (segmentBlock != null) { segmentBlock.InitializeConveyorSegment(); ConveyorSystem.AddSegmentBlock(segmentBlock); } var reflectorLight = block as MyReflectorLight; if (reflectorLight != null) { ReflectorLightSystem.Register(reflectorLight); } if (MyFakes.ENABLE_WHEEL_CONTROLS_IN_COCKPIT) { var wheel = block as MyMotorSuspension; if (wheel != null) { WheelSystem.Register(wheel); } } var landingGear = block as IMyLandingGear; if (landingGear != null) { LandingSystem.Register(landingGear); } var gyro = block as MyGyro; if (gyro != null) { GyroSystem.Register(gyro); } var camera = block as MyCameraBlock; if (camera != null) { CameraSystem.Register(camera); } block.OnRegisteredToGridSystems(); }