public IHttpActionResult PostCMD_NAV_TARGET(int uid, CMD_NAV_Target jsObject) { CMD_NAV_Target cmd_nav_target = new CMD_NAV_Target(); cmd_nav_target.Id = jsObject.Id; cmd_nav_target.Altitude = jsObject.Altitude; cmd_nav_target.Latitude = jsObject.Latitude; cmd_nav_target.Longitude = jsObject.Longitude; cmd_nav_target.UAVId = jsObject.UAVId; if (!ModelState.IsValid) { return BadRequest(ModelState); } db.CMD_NAV_Target.Add(cmd_nav_target); db.SaveChanges(); return Ok(); }
public int GotoCommand(CMD_NAV_Target cmd) { using (var db = new NestContainer()) { Clients.Group("vehicles").sendTargetCommand(cmd, Context.ConnectionId); return cmd.Id; } }
/** * Returns -1 if the insertion into the database failed. */ public int SendCommand(CMD_NAV_Target target) { using (var db = new NestContainer()) { target = db.CMD_NAV_Target.Add(target); int result = db.SaveChanges(); if (result == 1) { //The target was added, so send the target command to the vehicles. Clients.Group("vehicles").sendTargetCommand(target, Context.ConnectionId); //Return the target ID so they know what the ID is in the database. return target.Id; } else { //Not added, return, let caller know return -1; } } }