private static void EditFavoriteInSettings(FavoriteConfigurationElement favorite, string oldName) { if (!favorite.IsDatabaseFavorite) { TerminalsConfigurationSection section = GetSection(); section.Favorites[oldName] = favorite.Clone() as FavoriteConfigurationElement; SaveImmediatelyIfRequested(); } else { using (TerminalsObjectContext dc = TerminalsObjectContext.Create()) { Sql.Connections connection = favorite.ToConnection(dc, dc.Connections.Where(x => x.Name == oldName).FirstOrDefault()); dc.SaveChanges(); } } }
private static void DeleteFavoriteFromSettings(string name, bool isDatabaseFavorite) { if (!isDatabaseFavorite) { GetSection().Favorites.Remove(name); SaveImmediatelyIfRequested(); } else { using (TerminalsObjectContext dc = TerminalsObjectContext.Create()) { Sql.Connections connection = dc.Connections.Where(x => x.Name == name).FirstOrDefault(); if (connection != null) { dc.Connections.DeleteObject(connection); } dc.SaveChanges(); } } DeleteFavoriteButton(name); }