Пример #1
0
        public async Task <IActionResult> Notify([FromBody] NotificationDto dto)
        {
            await _mongoFactory.GetCollection <Notification>()
            .InsertOneAsync(new Notification(dto.Name, dto.Description, dto.Price, dto.CategoryId));

            return(Ok());
        }
Пример #2
0
        public void OverrideWithCustomDriver()
        {
            var firstDriver = this.MongoDBDriver;
            var newDriver   = new MongoDBDriver <BsonDocument>(MongoFactory.GetCollection <BsonDocument>(MongoDBConfig.GetConnectionString(), MongoDBConfig.GetDatabaseString(), null, MongoDBConfig.GetCollectionString()));

            this.TestObject.OverrideMongoDBDriver(newDriver);

            Assert.AreNotEqual(firstDriver, this.MongoDBDriver);
            Assert.AreEqual(newDriver, this.MongoDBDriver);
            Assert.IsFalse(this.MongoDBDriver.IsCollectionEmpty());
        }
Пример #3
0
        public void CanUseMultipleWithFunc()
        {
            var newCollection = MongoFactory.GetCollection <BsonDocument>(MongoDBConfig.GetConnectionString(), MongoDBConfig.GetDatabaseString(), MongoDBConfig.GetCollectionString());

            MongoDriverManager <BsonDocument> newDriver = new MongoDriverManager <BsonDocument>(() => newCollection, this.TestObject);

            this.ManagerStore.Add("test", newDriver);

            Assert.AreNotEqual(this.TestObject.MongoDBDriver, (MongoDriverManager <BsonDocument>) this.ManagerStore["test"]);
            Assert.AreNotEqual(this.TestObject.MongoDBManager.Get(), ((MongoDriverManager <BsonDocument>) this.ManagerStore["test"]).Get());
            Assert.AreEqual(newCollection, ((MongoDriverManager <BsonDocument>) this.ManagerStore["test"]).GetMongoDriver().Collection);
        }
Пример #4
0
 public async Task Handle(NotificationIntegrationEvent @event)
 {
     await _mongoFactory.GetCollection <Notification>()
     .InsertOneAsync(new Notification(@event.Name, @event.Description, @event.Price, @event.CategoryId));
 }