public async Task <User> GetUser(string username, string password) { var collection = _mongo.GetCollection <User>(); var users = collection.Find <User>(user => user.Username == username && user.Password == password); return(await users.FirstAsync()); }
public async Task <IEnumerable <Comment> > GetAllComments() { var collection = _mongo.GetCollection <Comment>(); var comments = collection.Find <Comment>(_ => true); return(await comments.ToListAsync()); }
public async Task UpsertDocumentAsync <T>(Expression <Func <T, bool> > filter, T document) where T : class { var collection = _mongo.GetCollection <T>(); await collection.ReplaceOneAsync(filter, document, new UpdateOptions { IsUpsert = true }); }