public Guid AddFlight(Flight flight)
        {
            lock (_writeReadLock)
            {
                var saved = false;
                while (!saved)
                {
                    try
                    {
                        if (_terminalContextDb.Flights.Count() > 100)
                        {
                            DeleteMultiply(50);
                        }

                        // if (flight.Id == Guid.Empty) flight.Id = Guid.NewGuid();
                        flight.Created = DateTime.Now;
                        _terminalContextDb.Add(flight);
                        _terminalContextDb.SaveChanges();

                        return(flight.Id);
                    }
                    catch (DbUpdateConcurrencyException ex)
                    {
                        foreach (var entry in ex.Entries)
                        {
                            if (entry.Entity is Flight)
                            {
                                var proposedValues = entry.CurrentValues;
                                var databaseValues = entry.GetDatabaseValues();

                                foreach (var property in proposedValues.Properties)
                                {
                                    var proposedValue = proposedValues[property];
                                    var databaseValue = databaseValues[property];

                                    // TODO: decide which value should be written to database
                                    // proposedValues[property] = <value to be saved>;
                                }

                                // Refresh original values to bypass next concurrency check
                                entry.OriginalValues.SetValues(databaseValues);
                            }
                            else
                            {
                                throw new NotSupportedException(
                                          "Don't know how to handle concurrency conflicts for "
                                          + entry.Metadata.Name);
                            }
                        }
                    }
                }
                return(Guid.Empty);
            }
        }
        public bool AddFlight(Flight flight)
        {
            //try
            //{
            _terminalContextDb.Add(flight);
            _terminalContextDb.SaveChanges();
            return(true);
            //}
            //catch (Exception ex)
            //{

            //    throw ex;
            //}
        }
 public bool AddLogMsg(LogMsg log)
 {
     lock (_writeReadLock)
     {
         try
         {
             log.Id       = Guid.NewGuid();
             log.Created  = DateTime.Now;
             log.Modified = null;
             _terminalContextDb.Add(log);
             _terminalContextDb.SaveChanges();
             return(true);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }