Esempio n. 1
0
    public void SetUp()
    {
        IWindsorContainer container = new WindsorContainer().Install(
            new RavenInstaller(Array.Empty <Tenant>(), DocumentStoreMode.InMemory));

        Store = container.Resolve <IDocumentStore>();
        IndexCreator.CreateIndexes(Store);
        Session = Store.OpenSession();
        OnSetUp();
    }
    public override Task Handle(HandlerContext <Command> context)
    {
        IndexCreator.CreateIndexes(CompositionRoot.DocumentStore);
        User admin = CompositionRoot.DocumentSession.Load <User>(User.AdminId);

        if (admin == null)
        {
            admin = new("", "", context.Payload.Email, context.Payload.Password)
            {
                Id = User.AdminId
            };
            admin.Initialize(t => context.PublishMessage(t));
            admin.Activate();
            CompositionRoot.DocumentSession.Store(admin);
        }
        else
        {
            admin.SetEmail(context.Payload.Email);
            admin.SetPassword(context.Payload.Password);
            admin.Activate();
        }

        return(Task.CompletedTask);
    }
Esempio n. 3
0
        private IHttpActionResult Handle(InitializeIndexesMessage message)
        {
            IndexCreator.CreateIndexes(DocumentStore);
            User admin = DocumentSession.Load <User>(Models.User.AdminId);

            if (admin == null)
            {
                admin = new User("", "", message.Email, message.Password)
                {
                    Id = Models.User.AdminId
                };
                admin.Initialize(PublishMessage);
                admin.Activate();
                DocumentSession.Store(admin);
            }
            else
            {
                admin.SetEmail(message.Email);
                admin.SetPassword(message.Password);
                admin.Activate();
            }

            return(Ok());
        }