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 Station(DronePost.DataModel.Station station) { Id = station.Id; Address = station.Address; Longitude = station.Longitude; Latitude = station.Latitude; Name = station.Name; }
public void GivePackageToRecipient(Customer customer, Package package) { Log($"customer {customer.Id} trying to take package {package.Id}."); CoreServiceClient core = new CoreServiceClient(); DronePost.DataModel.Station departureStation = new DronePost.DataModel.Station() { Address = this.Address, Id = this.Id, Latitude = this.Latitude, Longitude = this.Longitude, Name = this.Name }; core.RegisterTransfer(new Transfer() { DepartureStation = departureStation, DepartureTime = DateTime.Now, Package = package }); Log($"package {package.Id} was given to customer."); }
public void CheckOut(Drone drone) { Log($"drone {drone.Id} trying to check out."); CoreServiceClient core = new CoreServiceClient(); DronePost.DataModel.Station departureStation = new DronePost.DataModel.Station() { Address = this.Address, Id = this.Id, Latitude = this.Latitude, Longitude = this.Longitude, Name = this.Name }; core.RegisterTransfer(new Transfer() { DepartureStation = departureStation, DepartureTime = DateTime.Now, Drone = drone }); Log($"drone {drone.Id} checked out."); }
public void CheckIn(Drone drone) { Log($"drone {drone.Id} trying to check in."); CoreServiceClient core = new CoreServiceClient(); DronePost.DataModel.Station arrivalStation = new DronePost.DataModel.Station() { Address = this.Address, Id = this.Id, Latitude = this.Latitude, Longitude = this.Longitude, Name = this.Name }; core.RegisterTransfer(new Transfer() { ArrivalStation = arrivalStation, ArrivalTime = DateTime.Now, Drone = drone }); Log($"drone {drone.Id} checked in."); }