Example #1
0
        public static async Task <TranslationCreator> CreateNewAsync(
            Criteria.PhraseTextLanguageTextPairsCriteria criteria)
        {
            var result = await DataPortal.CreateAsync <TranslationCreator>(criteria);

            return(result);
        }
Example #2
0
        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();
        }