コード例 #1
0
 /// <summary>
 /// http://msdn.microsoft.com/en-us/library/hh286405(v=VS.92).aspx
 /// </summary>
 public static void DatabaseDeleteHistory(TranslatorHistory historyForDelete)
 {
     // Get a handle for the to-do item bound to the button.
     //TranslatorHistory historyForDelete = data.DataContext as TranslatorHistory;
     App.ViewModel.DeleteTranslatorHistory(historyForDelete);
     App.ViewModel.SaveChangesToDB();
 }
コード例 #2
0
        // Add a translator history to the database and collections.
        public void AddTranslatorHistory(TranslatorHistory newTranslatorHistory)
        {
            // Add a to-do item to the data context.
            translatorDB.History.InsertOnSubmit(newTranslatorHistory);

            // Save changes to the database.
            translatorDB.SubmitChanges();

            AllTranslatorHistory.Add(newTranslatorHistory);
        }
コード例 #3
0
        /// <summary>
        /// http://msdn.microsoft.com/en-us/library/hh286405(v=VS.92).aspx
        /// </summary>
        public static void DatabaseAddHistory(int fromLanguageIndex, string fromLanguage, string fromLanguageCode, string fromText, int toLanguageIndex, string toLanguage, string toLanguageCode, string toText)
        {
            Debug.WriteLine("Calling DatabaseAddHistory");
            // Create a new to-do item.
            TranslatorHistory newTranslatorHistory = new TranslatorHistory
            {
                FromLanguageIndex = fromLanguageIndex,
                FromLanguage      = fromLanguage,
                FromLanguageCode  = fromLanguageCode,
                FromText          = fromText,
                ToLanguageIndex   = toLanguageIndex,
                ToLanguage        = toLanguage,
                ToLanguageCode    = toLanguageCode,
                ToText            = toText,
                IsFavorite        = false
            };

            // Add the item to the ViewModel.
            App.ViewModel.AddTranslatorHistory(newTranslatorHistory);
            App.ViewModel.SaveChangesToDB();
        }
コード例 #4
0
        // Add a translator history to the database and collections.
        public void UpdateTranslatorHistoryFavorite(TranslatorHistory updateTranslatorHistory)
        {
            var updateHistoryInDB = (from TranslatorHistory history in translatorDB.History
                                     where history.HistoryId == updateTranslatorHistory.HistoryId
                                     select history).ToList()[0];

            // Add a to-do item to the data context.
            // toggle favorite
            if (updateTranslatorHistory.IsFavorite == true)
            {
                updateHistoryInDB.IsFavorite = false;
                FavoriteTranslatorHistory.Remove(updateTranslatorHistory);
            }
            else
            {
                updateHistoryInDB.IsFavorite = true;
                FavoriteTranslatorHistory.Add(updateTranslatorHistory);
            }

            // Save changes to the database.
            translatorDB.SubmitChanges();
        }
コード例 #5
0
        // Remove a translator history from the database and collections.
        public void DeleteTranslatorHistory(TranslatorHistory historyForDelete)
        {
            if (historyForDelete.IsFavorite == true)
            {
                // remove from both list boxes
                // Remove the to-do item from the "all" observable collection.
                AllTranslatorHistory.Remove(historyForDelete);
                FavoriteTranslatorHistory.Remove(historyForDelete);
            }
            else
            {
                // only remove from main listbox
                // Remove the to-do item from the "all" observable collection.
                AllTranslatorHistory.Remove(historyForDelete);
            }


            // Remove the to-do item from the data context.
            translatorDB.History.DeleteOnSubmit(historyForDelete);

            // Save changes to the database.
            translatorDB.SubmitChanges();
        }
コード例 #6
0
 /// <summary>
 /// http://msdn.microsoft.com/en-us/library/bb907191.aspx
 /// </summary>
 /// <param name="translatorHistory"></param>
 public static void DatabaseUpdateHistoryFavorite(TranslatorHistory translatorHistory)
 {
     App.ViewModel.UpdateTranslatorHistoryFavorite(translatorHistory);
     App.ViewModel.SaveChangesToDB();
 }