Exemplo n.º 1
0
        /// <summary>
        /// Add Command used to add items to the blacklist
        /// </summary>
        /// <param name="objToAdd">String word to add to blacklist</param>
        /// <returns></returns>
        public bool Add(object objToAdd)
        {
            if (SelectedSession == null)
            {
                ShowFeedback("No Session selected", FeedbackType.Info);
                return(false);
            }

            try
            {
                string wordToAdd = objToAdd as string;
                string feedback  = "";
                //set new blacklist and update the VM collection
                bool result = SelectedSession.AddToBlacklist(UnitOfWork, wordToAdd, ref feedback);
                BlacklistList = new ObservableCollection <string>(SelectedSession.Blacklist.Split(' '));
                CommonPhrases = SelectedSession.CalcCommonPhraseIdentification();
                //show appropriate feedback
                if (result)
                {
                    ShowFeedback($"{wordToAdd} added to blacklist.", FeedbackType.Success);
                    return(true);
                }
                else
                {
                    ShowFeedback(feedback, FeedbackType.Error);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ShowFeedback(ex.Message, FeedbackType.Error);
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Remove command used to remove items from blacklist
 /// </summary>
 /// <param name="objToRemove">String word to remove from blacklist</param>
 /// <returns></returns>
 public bool Remove(object objToRemove)
 {
     if (SelectedSession == null)
     {
         ShowFeedback("No Session selected", FeedbackType.Info);
         return(false);
     }
     try
     {
         string wordToRemove = objToRemove as string;
         string feedback     = "";
         bool   result       = SelectedSession.RemoveFromBlacklist(UnitOfWork, wordToRemove, ref feedback);
         BlacklistList = new ObservableCollection <string>(SelectedSession.Blacklist.Split(' '));
         CommonPhrases = SelectedSession.CalcCommonPhraseIdentification();
         if (result)
         {
             ShowFeedback($"{wordToRemove} Removed from blacklist.", FeedbackType.Success);
             return(true);
         }
         else
         {
             ShowFeedback(feedback, FeedbackType.Error);
             return(false);
         }
     }
     catch (Exception ex)
     {
         ShowFeedback(ex.Message, FeedbackType.Error);
         return(false);
     }
 }