public void CreateNewCandidate(TodoStudent stu) { stu.DefaultToNone(); var collection = db.GetCollection <BsonDocument>("candidate"); var doc = stu.UserToBson(); collection.InsertOne(doc); }
//-------------------------------------------UPDATE METHODS------------------------------------------------------------------- public TodoStudent UpdateUserInfo(string email, TodoStudent newStu) { TodoStudent stu = GetUserByEmail(email); newStu = newStu.DefaultToExisting(stu); var collection = db.GetCollection <BsonDocument>("candidate"); var doc = newStu.UserToBson(); var search = new BsonDocument("Email", email); BsonDocument found; found = collection.Find(search).First(); collection.ReplaceOne(found, doc); return(newStu); }