public void DataPortal_Create(Criteria.PhraseTextLanguageTextPairsCriteria criteria) { //INITIALIZE TRANSLATION CREATOR RetrieverId = Guid.NewGuid(); Translation = TranslationEdit.NewTranslationEdit(); //FILL TRANSLATION.PHRASES WITH EMPTY PHRASES for (int i = 0; i < criteria.PhraseTextLanguageTextPairs.Count; i++) { Translation.Phrases.AddNew(); } //FILL IN THE PHRASE DATA for (int j = 0; j < criteria.PhraseTextLanguageTextPairs.Count; j++) { //EXTRACT DATA FROM TUPLE var pair = criteria.PhraseTextLanguageTextPairs[j]; var phraseText = pair.Item1; var languageText = pair.Item2; //ENTER DATA INTO THE BLANK PHRASES var phraseEdit = Translation.Phrases[j]; phraseEdit.Text = phraseText; //DO THE LANGUAGE //TRY TO GET LANGUAGE EDIT FROM DB var allLanguages = LanguageList.GetAll(); var results = from languageEdit in allLanguages where languageEdit.Text == languageText select languageEdit; if (results.Count() > 0) { //THE LANGUAGE ALREADY EXISTS (OMG I'M TIRED AND THIS IS TERRIBLE) var childLanguageEdit = results.First(); phraseEdit.Language = childLanguageEdit; } else { //THE LANGUAGE DOES NOT EXIST YET phraseEdit.Language.Id = Guid.NewGuid(); phraseEdit.Language.Text = languageText; } } //SAVE THE TRANSLATION (SYNC CUZ WE'RE ON THE SERVER) Translation = Translation.Save(); }
public static Guid GetDefaultLanguageId() { var allLanguages = LanguageList.GetAll(); Guid defaultLanguageId = Guid.Empty; try { defaultLanguageId = (from language in allLanguages where language.Text == DalResources.DefaultEnglishLanguageText select language).First().Id; } catch (Exception ex) { throw new DataAccess.Exceptions.GeneralDataAccessException(ex); } return(defaultLanguageId); }