public ActionResult <IEnumerable <Missile> > Get(MissileStatus?status = null) { var missiles = status != null? missileService.Get(status.Value) : missileService.Get(); return(Ok(missiles)); }
public IActionResult Post([FromBody] Missile missile) { if (missile?.ServiceIdentityNumber == null) { return(BadRequest()); } var missileFromDatabase = missileService.Get(missile.ServiceIdentityNumber); if (missileFromDatabase == null) { return(BadRequest()); } var deploymentPlatform = deploymentPlatformService.Get(missileFromDatabase.DeploymentPlatformId); if (deploymentPlatform == null) { return(BadRequest()); } var eventMessage = new LaunchMissileEvent { MissileId = missileFromDatabase.MissileId, MissileServiceIdentityNumber = missile.ServiceIdentityNumber, MissileName = missileFromDatabase.Name, LaunchDate = DateTime.UtcNow, DeploymentPlatformLocation = deploymentPlatform.Location, TargetLocation = missile.TargetLocation }; // Publish launch missile message var launchMissileQueue = configuration .GetValue <String>("MessageBusSettings:Queues:LaunchCenterQueue"); messageBus.PublishMessage(launchMissileQueue, eventMessage); // Update status of the missile to 'Launched' var updateStatus = missileService.Update(missile.ServiceIdentityNumber, MissileStatus.Launched); if (updateStatus) { return(Ok()); } return(BadRequest()); }