Example #1
0
        /// <summary>
        ///     Adds tag to the tags collection if it already isnt there.
        ///     If the tag is in database, than it returns empty string, otherwise the commited tag.
        /// </summary>
        private static String AddTagToSettings(String tag, bool isDatabaseFavorite)
        {
            if (AutoCaseTags)
            {
                tag = ToTitleCase(tag);
            }
            if (Tags(isDatabaseFavorite).Contains(tag))
            {
                return(String.Empty);
            }

            if (!isDatabaseFavorite)
            {
                GetSection().Tags.AddByName(tag);
                SaveImmediatelyIfRequested();
            }
            else
            {
                using (TerminalsObjectContext dc = TerminalsObjectContext.Create())
                {
                    dc.Groups.AddObject(new Sql.Groups()
                    {
                        Name = tag
                    });
                    dc.SaveChanges();
                }
            }

            return(tag);
        }
Example #2
0
        /// <summary>
        ///     Removes the tag from settings, but doesnt send the Tag removed event
        /// </summary>
        private static String DeleteTagFromSettings(String tagToDelete, bool isDatabaseFavorite)
        {
            if (AutoCaseTags)
            {
                tagToDelete = ToTitleCase(tagToDelete);
            }

            if (!isDatabaseFavorite)
            {
                GetSection().Tags.DeleteByName(tagToDelete);
                SaveImmediatelyIfRequested();
            }
            else
            {
                using (TerminalsObjectContext dc = TerminalsObjectContext.Create())
                {
                    Sql.Groups group = dc.Groups.Where(x => x.Name == tagToDelete).FirstOrDefault();

                    dc.Groups.DeleteObject(group);
                    dc.SaveChanges();
                }
            }

            return(tagToDelete);
        }
Example #3
0
 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();
         }
     }
 }
Example #4
0
        /// <summary>
        ///     Adds favorite to the database, but doesnt fire the changed event
        /// </summary>
        private static void AddFavoriteToSettings(FavoriteConfigurationElement favorite)
        {
            if (!favorite.IsDatabaseFavorite)
            {
                GetSection().Favorites.Add(favorite);
                SaveImmediatelyIfRequested();
            }
            else
            {
                using (TerminalsObjectContext dc = TerminalsObjectContext.Create())
                {
                    Connections connection = favorite.ToConnection(dc);

                    if (!dc.Connections.Contains(connection))
                    {
                        dc.Connections.AddObject(connection);
                    }

                    dc.SaveChanges();
                }
            }
        }
Example #5
0
        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);
        }