public int RegisterTransfer(Transfer transfer) { Log("Transfer registered."); if (transfer.Drone != null) { DronePost.DataModel.Drone droneInBase = _db.Drones.Include("Model").First(d => d.Id == transfer.Drone.Id); droneInBase.Latitude = transfer.Drone.Latitude; droneInBase.Longitude = transfer.Drone.Longitude; _db.SaveChanges(); transfer.Drone = droneInBase; } if (transfer.ArrivalStation != null) { DronePost.DataModel.Station stationInBase = _db.Stations.First(s => s.Id == transfer.ArrivalStation.Id); transfer.ArrivalStation = stationInBase; } if (transfer.DepartureStation != null) { DronePost.DataModel.Station stationInBase = _db.Stations.First(s => s.Id == transfer.DepartureStation.Id); transfer.DepartureStation = stationInBase; } _db.Transfers.Add(transfer); _db.SaveChanges(); return(0); }
public bool AddDrone(DronePost.DataModel.Drone drone) { try { Drone newDrone = new Drone(drone, _messageHandler); _drones.Add(newDrone); HostDrone(newDrone); return(true); } catch (Exception ex) { return(false); } }