Ejemplo n.º 1
0
        public static async void UpdateOrCreateATC(VatsimClientATC controller)
        {
            using (var db = new VatsimDbContext())
            {
                var _controller = await db.Controllers.FindAsync(controller.Cid, controller.Callsign, controller.TimeLogon);

                // didn't find the pilot
                if (_controller == null)
                {
                    db.Add(controller);
                    db.SaveChanges();
                    Log.Information($"Added Controller: {controller} to DB");
                }
                else
                {
                    DateTime old_time = VatsimDataState.GetDateTimeFromVatsimTimeStamp(_controller.TimeLogon);
                    DateTime new_time = VatsimDataState.GetDateTimeFromVatsimTimeStamp(controller.TimeLogon);
                    if (new_time > old_time)
                    {
                        db.Add(controller);
                        Log.Information($"Added Controller: {controller} to DB");
                        db.SaveChanges();
                    }
                    else
                    {
                        _controller.Update(controller);
                        db.Update(_controller);
                        db.SaveChanges();
                        Log.Information($"Updated Controller: {controller} in DB");
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void Update(VatsimClientATC controller)
 {
     this.Cid                  = controller.Cid;
     this.Callsign             = controller.Callsign;
     this.AtisMessage          = controller.AtisMessage;
     this.Clienttype           = controller.Clienttype;
     this.Facilitytype         = controller.Facilitytype;
     this.Frequency            = controller.Frequency;
     this.Latitude             = controller.Latitude;
     this.Longitude            = controller.Longitude;
     this.Protrevision         = controller.Protrevision;
     this.Rating               = controller.Rating;
     this.Realname             = controller.Realname;
     this.Server               = controller.Server;
     this.TimeLastAtisReceived = controller.TimeLastAtisReceived;
     this.TimeLogon            = controller.TimeLogon;
     this.Visualrange          = controller.Visualrange;
 }
        public VatsimClientATC GetVatsimClientATCFromRecord()
        {
            VatsimClientATC atc = new VatsimClientATC();

            atc.Callsign             = this.Callsign;
            atc.Cid                  = this.Cid;
            atc.Clienttype           = this.Clienttype;
            atc.Facilitytype         = this.Facilitytype;
            atc.Frequency            = this.Frequency;
            atc.Latitude             = this.Latitude;
            atc.Longitude            = this.Longitude;
            atc.Protrevision         = this.Protrevision;
            atc.Rating               = this.Rating;
            atc.Realname             = this.Realname;
            atc.Server               = this.Server;
            atc.TimeLastAtisReceived = this.TimeLastAtisReceived;
            atc.TimeLogon            = this.TimeLogon;
            atc.Visualrange          = this.Visualrange;

            return(atc);
        }