public void SendAirplaneToArchiveList(Airplane airplane, Station station) { airplane.ExitedLastStationDateTime = DateTime.Now; repository.UpdateAirplane(airplane); FlightsArchive archive = new FlightsArchive { Airplane = airplane, Station = station, EnteredStartingStationDateTime = airplane.EnteredStartingStationDateTime, ExitedLastStationDateTime = DateTime.Now }; AllFlightsArchiveInAirport.Add(archive); repository.AddAirplaneToArchive(archive); AService.Invoke("SendFlightsArchiveToClient", AllFlightsArchiveInAirport); }
public void AddAirplaneToArchive(FlightsArchive AirplaneArchive) { using (var context = new AirportProjectDb()) { FlightsArchive fl = JsonConvert.DeserializeObject <FlightsArchive>(JsonConvert.SerializeObject(AirplaneArchive)); fl.AirplaneId = AirplaneArchive.Airplane.Id; fl.StationId = AirplaneArchive.Station.Id; fl.Station = null; fl.Airplane = null; context.FlightsArchives.Add(fl); context.SaveChanges(); } }