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); } }
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); } }