public JsonResult GetAnomalies(DateTime from, DateTime to, int areacode) { List <Anomalies> result = new List <Anomalies>(); try { Mongo mongo = new Mongo(); IMongoCollection <Anomalies> collection = mongo.ConnectToAnomaly("Traffic_Anomalies", "Anomalies"); result = collection.Find(Builders <Anomalies> .Filter.Where(x => x.date <to && x.date> from && x.stationid == areacode)).ToList(); } catch (Exception e) { System.IO.File.WriteAllText("Error.txt", e.Message); } return(Json(result)); }