public CommonPlaneLog ConvertPlaneLog(PlaneLog PlaneLog) { Station station = null; if (PlaneLog.Station != null) { station = ConvertStation(PlaneLog.Station); } return(new CommonPlaneLog() { Id = PlaneLog.Id, Plane = ConvertPlane(PlaneLog.Plane), Station = station, PlaneAction = PlaneLog.PlaneAction, Time = PlaneLog.Time }); }
public async Task AddLog(Station commonStation, StationChangedEventArgs args) { using (var context = new DataContext()) { DbStation station = context.Stations.First(station => station.Id == commonStation.Id); DbPlane plane = context.Planes.FirstOrDefault(plane => plane.FlightNumber == args.Plane.FlightNumber); if (plane != null) { PlaneLog log = new PlaneLog() { Plane = plane, Station = station, Time = args.EventTime, PlaneAction = args.PlaneAction }; context.PlanesLog.Add(log); await context.SaveChangesAsync(); } } }