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.FindPhraseInPhraseListCriteria criteria) { //INITIALIZE RetrieverId = Guid.NewGuid(); RetrievedPhrases = null; RetrievedSinglePhrase = null; var retrievedPhrase = FindPhraseInPhraseList(criteria.PhraseText, criteria.LanguageText, criteria.Phrases); //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 (criteria.GetPhraseFromDB && retrievedPhrase != null && retrievedPhrase.IsChild) { var nonChildVersion = PhraseEdit.GetPhraseEdit(retrievedPhrase.Id); RetrievedSinglePhrase = nonChildVersion; } else { RetrievedSinglePhrase = retrievedPhrase; } }
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); } } }