Пример #1
0
		public bool DealExists(Deal deal){
			var builder = Builders<BsonDocument>.Filter;
			var filter = builder.Eq ("product_name", deal.product_name) & 
				         builder.Eq ("store_name", deal.store_name) &
					     builder.Eq ("expiry_date", deal.expiry_date) &
					     builder.Eq ("price", deal.price);

			return deals_collection.Find (filter).ToList().Count != 0;
		}
Пример #2
0
		public bool AddDeal(string user, Deal deal){
			string user_name = DbUtils.GetUserName (user);
			if (user_name.Equals(DbUtils.NO_SUCH_USER))
				return false;

			if (DealExists (deal)) {
				return false;
			}

			deal.submitter_name = user_name;
			var document = deal.ToBsonDocument ();
			deals_collection.InsertOne (document);

			return true;
		}