コード例 #1
0
        public void Process(MyEvent @event)
        {
            _logger.Information("Event processed");

            try
            {  
              var document = new Animal
              {
                  Species = "Dog",
                  Name    = Guid.NewGuid().ToString()
              };

              _repository.Insert(document);
              _logger.Information("Inserted document"); }
            catch (Exception ex)
            {
                _logger.Error(ex, "Couldn't insert document ");
            }
        }
コード例 #2
0
        public void Process(MyEvent @event)
        {
            _logger.Information("Event processed");

            try
            {  

              /*
               * var existing = _repository.GetById(Guid.Parse("358b9a07-51fa-4da1-af6d-ffff04a08a00"));
               * var existingAsJson = _serializer.ToJson(existing);
               * _logger.Information($"Existing document : {existingAsJson}");
               */

              var document = new Animal
              {
                  Id      = Guid.NewGuid(),
                  Species = "Dog",
                  Name    = Guid.NewGuid().ToString()
              };

              _repository.Insert(document).ContinueWith(t =>
                {
                    _logger.Information("Inserted document");

                    _repository.GetById(document.Id).ContinueWith(task =>
                    {
                        var existing       = task.Result;
                        var existingAsJson = _serializer.ToJson(existing);
                        _logger.Information($"Existing document : {existingAsJson}");
                    });
                }); }
            catch (Exception ex)
            {
                _logger.Error(ex, "Couldn't insert document ");
            }
        }