Пример #1
0
        public IHttpActionResult PostCMD_NAV_HOLD(int uid, CMD_NAV_Hold jsObject)
        {

            int result = 0;
            CMD_NAV_Hold cmd_nav_hold = new CMD_NAV_Hold();
            //cmd_nav_hold.Id = jsObject.Id;
            cmd_nav_hold.Altitude = jsObject.Altitude;
            cmd_nav_hold.Latitude = jsObject.Latitude;
            cmd_nav_hold.Longitude = jsObject.Longitude;
            cmd_nav_hold.UAVId = jsObject.UAVId;
            cmd_nav_hold.Time = jsObject.Time;
            cmd_nav_hold.Throttle = jsObject.Throttle;
            
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }
            

            try
            {

                db.CMD_NAV_Hold.Add(cmd_nav_hold);
               result = db.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    System.Diagnostics.Debug.Write("Entity of type " + eve.Entry.Entity.GetType().Name+" in state "+eve.Entry.State+ " has the following validation errors:");
                    foreach (var ve in eve.ValidationErrors)
                    {
                        System.Diagnostics.Debug.Write("- Property: " + ve.PropertyName + ", Error: " + ve.ErrorMessage);
                    }
                }
                throw;
            }
            if (result == 1)
            {
                return Ok();
            }
            else
            {
                return NotFound();
            }
        }
Пример #2
0
 public int HoldCommand(CMD_NAV_Hold cmd)
 {
         Clients.Group("vehicles").sendHoldCommand(cmd, Context.ConnectionId);
         System.Diagnostics.Debug.WriteLine("ID is: " + cmd.Id);
         System.Diagnostics.Debug.WriteLine("Context ID is: " + Context.ConnectionId);
         return cmd.Id;
  }