Ejemplo n.º 1
0
        public async Task Delete(StubObject stubObject)
        {
            _logger.LogDebug("Delete request, deleting: {@StubObject}", stubObject);
            var collection = _mongoClient.GetDatabase($"{nameof(StubObject)}").GetCollection <StubObject>($"{nameof(StubObject)}");
            var filter     = Builders <StubObject> .Filter.Eq("Id", stubObject.Id);

            await collection.DeleteOneAsync(filter);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Delete(StubObject packet)
        {
            try
            {
                await _database.Delete(packet);

                return(Ok());
            }
            catch (Exception e)
            {
                _logger.LogError("Failed to delete object {@Object} with error {@Exception}", packet, e.Message);
                return(Conflict());
            }
        }
Ejemplo n.º 3
0
        public void JTokenToObjectConversion_Tests()
        {
            var o = new StubObject
            {
                Firstname = "test1",
                Lastname  = "test1"
            };

            var jtoken = o.AsJToken();
            var co     = jtoken.AsObject <StubObject>();

            Assert.NotNull(co);
            Assert.Equal(o.Firstname, co.Firstname);
            Assert.Equal(o.Lastname, co.Lastname);

            jtoken = null;
            Assert.Null(jtoken.AsObject <StubObject>());
        }
Ejemplo n.º 4
0
 public async Task Update(StubObject stubObject)
 {
     _logger.LogDebug("Update request, update: {@StubObject}", stubObject);
     var collection = _mongoClient.GetDatabase($"{nameof(StubObject)}").GetCollection <StubObject>($"{nameof(StubObject)}");
     await collection.ReplaceOneAsync(doc => doc.Id == stubObject.Id, stubObject);
 }
Ejemplo n.º 5
0
 public async Task Create(StubObject stubObject)
 {
     _logger.LogDebug("Create request, creating: {@stubObject}", stubObject);
     var collection = _mongoClient.GetDatabase($"{nameof(StubObject)}").GetCollection <StubObject>($"{nameof(StubObject)}");
     await collection.InsertOneAsync(stubObject);
 }