Пример #1
0
        public bool Update(ObstacleModel obstacleModel)
        {
            var original = DatabaseManager.Instance.Obstacle.Find(obstacleModel.ObsStudy);

            if (original != null)
            {
                DatabaseManager.Instance.Entry(original).CurrentValues.SetValues(ToDbModel(obstacleModel));
                DatabaseManager.Instance.SaveChanges();
                return(true);
            }

            return(false);
        }
Пример #2
0
        private Obstacle ToDbModel(ObstacleModel obstacleModel)
        {
            var contactDb = new Obstacle
            {
                ObsStudy               = obstacleModel.ObsStudy,
                ObsType                = obstacleModel.ObsType,
                ObsLongitudeDms        = obstacleModel.ObsLongitudeDms,
                ObsLatitudeDms         = obstacleModel.ObsLongitudeDms,
                ObsLatitudeHemisphere  = obstacleModel.ObsLatitudeHemisphere,
                ObsLongitudeHemisphere = obstacleModel.ObsLongitudeHemisphere,
                ObsAglHeight           = obstacleModel.ObsAglHeight,
                ObsMslHeight           = obstacleModel.ObsMslHeight,
                ObstLatitudeDd         = obstacleModel.ObsLongitudeDd,
                ObsLongitudeDd         = obstacleModel.ObsLongitudeDd,
                ObsIcao                = obstacleModel.ObsIcao
            };

            return(contactDb);
        }
Пример #3
0
        public ObstacleModel Add(ObstacleModel obstacleModel)
        {
            var obstacleDb = ToDbModel(obstacleModel);

            DatabaseManager.Instance.Obstacle.Add(obstacleDb);
            DatabaseManager.Instance.SaveChanges();

            obstacleModel = new ObstacleModel
            {
                ObsStudy               = obstacleModel.ObsStudy,
                ObsType                = obstacleModel.ObsType,
                ObsLongitudeDms        = obstacleModel.ObsLongitudeDms,
                ObsLatitudeDms         = obstacleModel.ObsLongitudeDms,
                ObsLatitudeHemisphere  = obstacleModel.ObsLatitudeHemisphere,
                ObsLongitudeHemisphere = obstacleModel.ObsLongitudeHemisphere,
                ObsAglHeight           = obstacleModel.ObsAglHeight,
                ObsMslHeight           = obstacleModel.ObsMslHeight,
                ObstLatitudeDd         = obstacleModel.ObsLongitudeDd,
                ObsLongitudeDd         = obstacleModel.ObsLongitudeDd,
                ObsIcao                = obstacleModel.ObsIcao
            };
            return(obstacleModel);
        }