public static void GetSaleHtml(MapJaJa mls, string updateDate) { mls.Html = Details(mls.nodeId); mls.MongohouseData = Mongohouse.MLSSearch(mls.nodeId.Substring(2)); #region Save to MongoDB MongoClient mongoClient = new MongoClient(MongoUrl.Create("mongodb://localhost:27017")); IMongoDatabase mongoDatabase = mongoClient.GetDatabase("RealEstate"); IMongoCollection <MapJaJa> collection = mongoDatabase.GetCollection <MapJaJa>("WaitProcessingForSaleJaJa"); IMongoCollection <MapJaJa> pcollection = mongoDatabase.GetCollection <MapJaJa>("WaitProcessingForSaleJaJaHTML"); //var FindResult = collection.Find(c => c.nodeId == mls.nodeId).First(); collection.DeleteOne(c => c.nodeId == mls.nodeId); pcollection.InsertOne(mls); #endregion }
public static void UpdateHistoricalTransaction(string address1, string address2, string city) { MongoClient mongoClient = new MongoClient(MongoUrl.Create("mongodb://localhost:27017")); IMongoDatabase mongoDatabase = mongoClient.GetDatabase("RealEstate"); IMongoCollection <HistoricalResult> collection = mongoDatabase.GetCollection <HistoricalResult>("SoldHistory"); List <HistoricalResult> mongoResult = Mongohouse.HistoricalResult(address1, address2, city); foreach (HistoricalResult o in mongoResult) { if (collection.Find(c => c.MLSNo == o.MLSNo).CountDocuments() > 0) { } else { o.Address1 = address1; o.Address2 = address2; o.City = city; collection.InsertOne(o); } } }