The following C# code accepts two parameter username and password from API using ajax    
public Login[] checkLogin(models.Login log)
{
    Boolean flag = false;
    connection obj = new connection();
    IMongoDatabase server = obj.getConnection();
    var collection = server.GetCollection<models.Login>("login");
    string param = "{'username':'" + log.username + "','password':'"+ log.password +"'}";
    List<Login> result = new List<Login>();
    var check =  collection.Find(param);
    foreach(var emp in check.ToList())
    {
        result.Add(emp);
    }    
    if(result == null)  
        flag = false;   
    else
        flag = true;
    return result.ToArray();
}
I want to check the username and password from my MongoDB database. I am trying to find method but don't know how to check the value if it is available or not.
 
    