public void DataPortal_Create(PhraseEdit criteria) { //INITIALIZE RetrieverId = Guid.NewGuid(); RetrievedPhrases = null; RetrievedSinglePhrase = null; //GET ALL PHRASES (FOR THIS USER ONLY) PhraseList allPhrases = PhraseList.GetAll(); var retrievedPhrase = FindPhraseInPhraseList(criteria.Text, criteria.Language.Text, allPhrases); //if we directly add this retrievedPhrase, then it will be a child //we need to get the non-child version of this //RetrievedPhrases.Add(criteriaPhrase.Id, retrievedPhrase); if (retrievedPhrase != null && retrievedPhrase.IsChild) { var nonChildVersion = PhraseEdit.GetPhraseEdit(retrievedPhrase.Id); RetrievedSinglePhrase = nonChildVersion; } }
public void DataPortal_Create(Criteria.PhraseTextsCriteria criteria) { RetrieverId = Guid.NewGuid(); if (ExistenceDictionary == null) { ExistenceDictionary = new MobileDictionary <string, bool>(); } PhraseList allPhrases = PhraseList.GetAll(); var allPhrasesInLanguage = (from phrase in allPhrases where phrase.Language.Text == criteria.LanguageText select phrase); var phraseTextsNoDuplicates = criteria.PhraseTexts.Distinct(); foreach (var phraseText in phraseTextsNoDuplicates) { var count = (from phrase in allPhrasesInLanguage where phrase.Text == phraseText select phrase).Count(); var exists = count > 0; ExistenceDictionary.Add(phraseText, exists); } }
/// <summary> /// Returns the FirstOrDefault PhraseEdit in phrases matching exactly the phraseText and languageText given. /// </summary> /// <param name="phraseText">PhraseEdit.Text to match</param> /// <param name="languageText">PhraseEdit.Language.Text to match</param> /// <param name="phrases">list of phrases in which to search</param> /// <returns>First PhraseEdit matching phraseText and languageText if found, or null if none found</returns> private PhraseEdit FindPhraseInPhraseList(string phraseText, string languageText, PhraseList phrases) { return((from phrase in phrases where phrase.Text == phraseText && phrase.Language.Text == languageText select phrase).FirstOrDefault()); }
public void DataPortal_Create(Criteria.ListOfPhrasesCriteria criteria) { //WE ARE GOING TO GET ALL THE PHRASES //WE WILL THEN ITERATE THROUGH OUR CRITERIA PHRASES, POPULATING OUR //RETRIEVED PHRASES //INITIALIZE RetrieverId = Guid.NewGuid(); if (RetrievedPhrases == null) { RetrievedPhrases = new MobileDictionary <Guid, PhraseEdit>(); } ////GET ALL PHRASES (FOR THIS USER ONLY) //PhraseList allPhrases = PhraseList.GetAll(); //KEY = TEXT, VALUE = PHRASELIST CONTAINING ALL PHRASES THAT CONTAIN THE KEY TEXT var phraseLists = new Dictionary <string, PhraseList>(); for (int i = 0; i < criteria.Phrases.Count; i++) { var criteriaPhrase = criteria.Phrases[i]; //IF WE'VE ALREADY DONE THIS PHRASE, THEN GO ON TO THE NEXT ONE, SO WE DON'T DUPLICATE WORK if (RetrievedPhrases.ContainsKey(criteriaPhrase.Id)) { continue; } //INITIALIZE RETRIEVED PHRASE PhraseEdit retrievedPhrase = null; //GET ALL PHRASES THAT CONTAIN THIS PHRASE, IN ANY LANGUAGE var allPhrasesContainingPhrase = PhraseList.GetAllContainingText(criteriaPhrase.Text); //IF WE FOUND A PHRASE/MULTIPLE PHRASES, THEN WE WANT THE ONE THAT MATCHES OUR //CRITERIA PHRASE IN TEXT AND LANGUAGE if (allPhrasesContainingPhrase.Count > 0) { retrievedPhrase = (from phrase in allPhrasesContainingPhrase where phrase.Text == criteriaPhrase.Text && phrase.Language.Text == criteriaPhrase.Language.Text select phrase).FirstOrDefault(); } if (retrievedPhrase != null && retrievedPhrase.IsChild) { //WE ONLY WANT NON-CHILD VERSIONS OF PHRASE var nonChildVersion = PhraseEdit.GetPhraseEdit(retrievedPhrase.Id); RetrievedPhrases.Add(criteriaPhrase.Id, nonChildVersion); } else if (retrievedPhrase != null && !retrievedPhrase.IsChild) { //PHRASE IS ALREADY NOT A CHILD, SO ADD IT RetrievedPhrases.Add(criteriaPhrase.Id, retrievedPhrase); } else { //NO RETRIEVED PHRASE, SO ADD NULL FOR THIS CRITERIAPHRASE.ID RetrievedPhrases.Add(criteriaPhrase.Id, null); } } }
public TranslationEdit() { Phrases = PhraseList.NewPhraseListNewedUpOnly(); }