Ejemplo n.º 1
0
 public WordTranslationsDto(WordTranslations wt)
 {
     this.id               = wt.Id.ToString();
     this.word             = wt.Word;
     this.translationWords = wt.TranslationWords;
     this.translationCards = wt.TranslationCards;
 }
 public async Task AddTranslations(string word, string wordLanguage, string translationsLanguage, string translationWords, string transaltionCards) {
     IMongoCollection<WordTranslations> collection = GetCollection(wordLanguage, translationsLanguage);
     WordTranslations entity = new WordTranslations {
         Id = MongoDB.Bson.ObjectId.GenerateNewId(),
         Word = word,
         TranslationWords = translationWords,
         TranslationCards = transaltionCards
     };
     var filter = Builders<WordTranslations>.Filter.Eq(wt => wt.Word, word);
     WordTranslations wordTranslations = await collection.Find(filter).SingleOrDefaultAsync();
     if (wordTranslations == null) {
         await collection.InsertOneAsync(entity);
     } else {
         entity.Id = wordTranslations.Id;
         await collection.ReplaceOneAsync(filter, entity);
     }
 }
Ejemplo n.º 3
0
        public async Task AddTranslations(string word, string wordLanguage, string translationsLanguage, string translationWords, string transaltionCards)
        {
            IMongoCollection <WordTranslations> collection = GetCollection(wordLanguage, translationsLanguage);
            WordTranslations entity = new WordTranslations {
                Id               = MongoDB.Bson.ObjectId.GenerateNewId(),
                Word             = word,
                TranslationWords = translationWords,
                TranslationCards = transaltionCards
            };
            var filter = Builders <WordTranslations> .Filter.Eq(wt => wt.Word, word);

            WordTranslations wordTranslations = await collection.Find(filter).SingleOrDefaultAsync();

            if (wordTranslations == null)
            {
                await collection.InsertOneAsync(entity);
            }
            else
            {
                entity.Id = wordTranslations.Id;
                await collection.ReplaceOneAsync(filter, entity);
            }
        }
Ejemplo n.º 4
0
 public WordTranslationsDto(WordTranslations wt)
 {
     this.id = wt.Id.ToString();
     this.word = wt.Word;
     this.translationWords = wt.TranslationWords;
     this.translationCards = wt.TranslationCards;
 }