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); }
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); }
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); }