protected static bool UpdateVocabulary(VocModel Voc) { var oldVoc = Vocabularies.First(c => c.Id == Voc.Id).ToModel(); int field = 0; string ColumnsToUpdate = string.Empty; CheckFieldUpdate("Words", Voc.Text, oldVoc.Text, ref field, ref ColumnsToUpdate); CheckFieldUpdate("Answer", Voc.Answer, oldVoc.Answer, ref field, ref ColumnsToUpdate); CheckFieldUpdate("Definition", Voc.Definition, oldVoc.Definition, ref field, ref ColumnsToUpdate); CheckFieldUpdate("PtBr", Voc.PtBr, oldVoc.PtBr, ref field, ref ColumnsToUpdate); CheckQuestionChanges(Voc, oldVoc, ref field, ref ColumnsToUpdate); if (ColumnsToUpdate.IsEmpty()) { return(Errors.ThrowErrorMsg(ErrorType.NullOrEmpty, ColumnsToUpdate)); } string query = string.Format(UpdateSQL, Model.Voc.ToDesc(), ColumnsToUpdate, Voc.Id); if (!SendQuery(query)) { return(false); } return(true); }
private void AddVocabularyCommandHandler() { int weekOfYear = DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear(DateTime.Now, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Monday); string defaultName = string.Format("{0:MMdd}.Vocabulary{0:yyyy}.{1:0#}", DateTime.Now, weekOfYear); var strVocabularyName = InputBox.ShowDialog("Please, insert name of new Vocabulary", defaultName); if (string.IsNullOrEmpty(strVocabularyName)) { return; } if (Vocabularies.Any(v => string.Compare(v.FileName, strVocabularyName, true) == 0)) { MessageBox.ShowDialog(string.Format("Vocabulary '{0}' already exists.", strVocabularyName), "Warning"); } else { Vocabularies.Add(new VocabularyListViewModel(dataService, dialogService) { FileName = strVocabularyName }); dataService.Set(new VocabularyRecord[0], strVocabularyName); } AddVocabularyCommand.RaiseCanExecuteChanged(); }
public async Task GetVocabularyWordsIncludesQueryParameters() { var vocabularyId = Guid.NewGuid(); await target.Vocabularies.Get(Vocabularies.For(vocabularyId, page: new PagingInfo(1, 1), type: WordType.StopWord)); Assert.Equal(HttpMethod.Get, handler.Request.Method); Assert.Equal(new Uri(baseUri, $"vocabulary/{vocabularyId}?type=StopWord&page=1&pageSize=1"), handler.Request.RequestUri); }
public async Task GetVocabularyWordsWithDefaultParmetersUsesCorrectUrl() { var vocabularyId = Guid.NewGuid(); await target.Vocabularies.Get(Vocabularies.For(vocabularyId)); Assert.Equal(HttpMethod.Get, handler.Request.Method); Assert.Equal(new Uri(baseUri, $"vocabulary/{vocabularyId}?pageSize=50"), handler.Request.RequestUri); }
/// <summary> /// Вызвать перед удалением слова. /// </summary> public virtual void OnDelete() { Vocabularies.ForEach(x => x.RemoveWord(this)); HealthRecords .Select(x => x.Doctor) .Distinct() .ForEach(x => x.RemoveWordFromCache(this)); }
/// <summary> /// Will inverse selection icon of selected vocabs. If methods is used for initialization of UI, /// Only the "not visible" items will be colors, no inversion will take place. /// </summary> /// <param name="inItem">The item to retrieve vocabularies property from</param> /// <param name="inContainer">The item container in which the background will be changed</param> /// <param name="forInit">Bool value for intiliasation or interaction</param> public void setPicklistValueIcon(SymbolIcon inIcon, object inItem, bool forInit) { #region Set if (inItem != null && inIcon != null) { //Build a color brush for rejected picklist values SolidColorBrush rejectedColorBrush = new SolidColorBrush(); Windows.UI.Color rejectedColor = Windows.UI.Colors.Red; rejectedColorBrush.Color = rejectedColor; SolidColorBrush selectedColorBrush = new SolidColorBrush(); Windows.UI.Color selectedColor = Windows.UI.Colors.LawnGreen; selectedColorBrush.Color = selectedColor; //Find if current item is rejected and modify background accordingly Vocabularies valueVoc = inItem as Vocabularies; string currentVisibility = valueVoc.Visibility; if (forInit) { if (currentVisibility == Dictionaries.DatabaseLiterals.boolNo) { inIcon.Symbol = Symbol.Cancel; inIcon.Foreground = rejectedColorBrush; } else { inIcon.Symbol = Symbol.Accept; inIcon.Foreground = selectedColorBrush; } } else { if (currentVisibility == Dictionaries.DatabaseLiterals.boolNo) { valueVoc.Visibility = Dictionaries.DatabaseLiterals.boolYes; inIcon.Symbol = Symbol.Accept; inIcon.Foreground = selectedColorBrush; } else { valueVoc.Visibility = Dictionaries.DatabaseLiterals.boolNo; inIcon.Symbol = Symbol.Cancel; inIcon.Foreground = rejectedColorBrush; } } } #endregion }
protected static bool RemoveVocabulary(VocVM Voc) { string query = string.Format(RemoveSQL, Model.Voc.ToDesc(), Voc.Id); if (!SendQuery(query)) { return(false); } Vocabularies.Remove(Voc); return(true); }
public virtual Vocabulary AddVoc(Vocabulary voc) { if (!Vocabularies.Contains(voc)) { var sv = new SpecialityVocabularies(this, voc); SvHelper.Add(sv); voc.AddSpecVoc(sv); OnVocsChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, voc)); } return(voc); }
private void Refresh() { var files = dataService.GetFiles(); Vocabularies.Clear(); foreach (var file in files) { Vocabularies.Add(new VocabularyListViewModel(dataService, dialogService) { FileName = file }); } ; }
private void CreateVocabularyList(string fileName) { if (string.IsNullOrEmpty(fileName)) { return; } if (Vocabularies.Any(v => string.Compare(v.FileName, fileName, true) == 0)) { return; } var vocabularyList = new VocabularyListViewModel(dataService, dialogService) { FileName = fileName }; Vocabularies.Add(vocabularyList); vocabularyList.SaveCommand.Execute(null); }
protected static bool InsertVocabulary(VocModel Voc) { string query = string.Format(InsertSQL + "'{1}', '{2}', {3}, '{4}', '{5}', {6})", Model.Voc.ToDesc(), Voc.Text, Voc.Answer, Null, Null, Voc.Importance, Voc.IsActive); if (!SendQuery(query)) { return(false); } var inserted = GetLast(Model.Voc.ToDesc()); Vocabularies.Add(inserted.Tables[0].AsEnumerable(). Select(GetDatarowVocabulary()).First().ToVM()); return(true); }
private List <string> CreateSuggestionList() { Vocabularies vocabularyModel = new Vocabularies(); string vocQuerySelect = "SELECT * FROM " + Dictionaries.DatabaseLiterals.TableDictionary; string vocQueryWhere = " WHERE CODETHEME = 'LITHDETAIL'"; string vocQueryVisibility = " AND " + Dictionaries.DatabaseLiterals.TableDictionary + "." + Dictionaries.DatabaseLiterals.FieldDictionaryVisible + " = '" + Dictionaries.DatabaseLiterals.boolYes + "'"; string vocFinalQuery = vocQuerySelect + vocQueryWhere + vocQueryVisibility; List <object> vocResults = accessData.ReadTable(vocabularyModel.GetType(), vocFinalQuery); var outResults = new List <string>(); foreach (Vocabularies tmp in vocResults) { outResults.Add(tmp.RelatedTo.ToString() + " ; " + tmp.Code.ToString()); } return(outResults); }
/// <summary> /// Will push back textbox values into the list view of picklist terms /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void PicklistValueAddIcon_Tapped(object sender, TappedRoutedEventArgs e) { if (_picklistEditEnableDisable) { //Get current vocab in text box Vocabularies currentVocab = _addModifyObject as Vocabularies; //Refresh list view with vocab bool vocabInList = false; for (int i = 0; i < _picklistValues.Count; i++) { //For existing vocab in list if (_picklistValues[i].Code == currentVocab.Code) { _picklistValues[i] = currentVocab; vocabInList = true; break; } } //If vocab is new if (!vocabInList) { _picklistValues.Add(currentVocab); _picklistValueCodes.Add(currentVocab.Code); _picklistValueCodesNew.Add(currentVocab.Code); } _picklistValues.Sort(); //Sort using a custom extension RaisePropertyChanged("PicklistValues"); //Refresh text box _addModifyTerm = string.Empty; _addModifyObject = new Vocabularies(); RaisePropertyChanged("AddModifyTerm"); RaisePropertyChanged("AddModifyObject"); } }
/// <summary> /// Will manager user term selection and process it in the textbox control /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void picklistValues_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListViewBase senderBase = sender as ListViewBase; if (senderBase.SelectedItems.Count == 1) { Vocabularies selectedTerm = senderBase.SelectedItem as Vocabularies; if (selectedTerm.Editable == Dictionaries.DatabaseLiterals.boolYes || selectedTerm.Editable == null) { _addModifyTerm = selectedTerm.Description; _addModifyObject = selectedTerm; RaisePropertyChanged("AddModifyObject"); RaisePropertyChanged("AddModifyTerm"); _picklistEditEnableDisable = true; RaisePropertyChanged("PicklistEditEnableDisable"); } else { //Clear tag _addModifyObject = new Vocabularies(); RaisePropertyChanged("AddModifyObject"); _picklistEditEnableDisable = false; RaisePropertyChanged("PicklistEditEnableDisable"); } } else if (senderBase.SelectedItems.Count == 0 || senderBase.SelectedItems.Count > 1) { //Clear tag _addModifyObject = new Vocabularies(); RaisePropertyChanged("AddModifyObject"); _picklistEditEnableDisable = true; RaisePropertyChanged("PicklistEditEnableDisable"); } }