Exemple #1
0
 /// <summary>
 /// Add a new airport position to the db.
 /// </summary>
 /// <param name="position">The position object to add to the db.</param>
 /// <returns>True everything went well; False something went wrong.</returns>
 public bool AddNewPosition(AirportPositions position)
 {
     using (var db = new YapbtDbEntities())
     {
         try
         {
             db.AirportPositions.Add(position);
             return true;
         }
         catch (System.Exception)
         {
             return false;
             throw;
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// Remove all pushback paths belonging to a position.
        /// </summary>
        /// <param name="position">The position it will lookup for.</param>
        /// <returns>True everything was ok; False something went wrong.</returns>
        public bool RemoveAllPushbackPathOfPosition(AirportPositions position)
        {
            using (var db = new YapbtDbEntities())
            {
                Point point = new Point();

                // Find all pushback paths belonging to the position.
                var pushBackPath = db.AirportPushBackPath.Where(c => c.positionid == position.positionid).ToList();

                // If any path was found.
                if (pushBackPath.Any())
                {
                    // For each path remove the positions and the path.
                    pushBackPath.ForEach(delegate (AirportPushBackPath pushpath)
                    {
                        point.RemovePushbackPoint(pushpath);
                        db.AirportPushBackPath.Remove(pushpath);
                        db.SaveChanges();
                    });
                }

                return true;
            }
        }