public async Task <KnowledgeModel> SaveAsync(KnowledgeModel entity) { var collection = MongoClientManager.DataBase.GetCollection <KnowledgeModel>(CollectionNames.Knowledge); await collection.InsertOneAsync(entity as KnowledgeModel); Console.WriteLine("document added: " + entity.ToJson()); var filter = new BsonDocument(); Console.WriteLine("count:" + collection.CountDocuments(filter).ToString()); return(entity); }
public async Task <KnowledgeModel> UpdateAsync(KnowledgeModel entity) { var collection = MongoClientManager.DataBase.GetCollection <KnowledgeModel>(CollectionNames.Knowledge); await collection.ReplaceOneAsync(d => d.ID == entity.ID, entity); Console.WriteLine("document updated: " + entity.ToJson()); var filter = new BsonDocument(); Console.WriteLine("count:" + collection.CountDocuments(filter).ToString()); return(entity); }