private void ApplyEvent(IEvent ev)
        {
            // TODO: Handle incoming events by updating the Mongo database
            switch (ev)
            {
            case CreatedEvent e:
                var resourceType = e.GetEntityType();
                switch (resourceType)
                {
                case ResourceType _ when resourceType == ResourceTypes.Foo:
                    var foo = new Foo
                    {
                        Id        = e.Id,
                        Timestamp = e.Timestamp,
                        UserId    = e.UserId
                    };
                    _db.Add(ResourceTypes.Foo, foo);
                    break;
                }

                break;

            case PropertyChangedEvent e:
                resourceType = e.GetEntityType();
                switch (resourceType)
                {
                case ResourceType _ when resourceType == ResourceTypes.Foo:
                    var originalFoo = _db.GetCollection <Foo>(resourceType).AsQueryable().First(x => x.Id == e.Id);
                    var args        = originalFoo.CreateFooArgs();
                    e.ApplyTo(args);
                    var updatedFoo = new Foo(args)
                    {
                        Id        = e.Id,
                        Timestamp = e.Timestamp,
                        UserId    = originalFoo.UserId
                    };
                    _db.Replace((ResourceTypes.Foo, e.Id), updatedFoo);
                    break;
                }

                break;


            case DeletedEvent e:
                resourceType = e.GetEntityType();
                switch (resourceType)
                {
                case ResourceType _ when resourceType == ResourceTypes.Foo:
                    _db.Delete((ResourceTypes.Foo, e.Id));
                    break;
                }

                break;
            }
        }