Exemplo n.º 1
0
            public void ExecuteActionOnExistingInstance(Func <ICommand, Guid> idCallback, Func <ICommand, Type> typeCallback, Action <AggregateRoot, ICommand> action)
            {
                var id      = idCallback(_command);
                var type    = typeCallback(_command);
                var aggRoot = _uow.GetById(type, id, _command.KnownVersion);

                action(aggRoot, _command);
                _uow.Accept();
            }
Exemplo n.º 2
0
        protected override void ExecuteInContext(IUnitOfWorkContext context, AddInvoiceDiscount command)
        {
            Invoice invoice = context.GetById <Invoice>(command.InvoiceId, command.KnownVersion);

            invoice.GiveDiscount(command.DiscountInPercent);
            context.Accept();
        }
        protected override void ExecuteInContext(IUnitOfWorkContext context, InvalidateUserCommand command)
        {
            var aggregate = context.GetById <User>(command.UserID) as User;

            aggregate.Invalidate(command.UserID);
            context.Accept();
        }
        protected override void ExecuteInContext(IUnitOfWorkContext context, DeleteTweetCommand command)
        {
            var aggregate = context.GetById <Tweet>(command.TweetID) as Tweet;

            aggregate.Delete(command.TweetID);

            context.Accept();
        }
        protected override void ExecuteInContext(IUnitOfWorkContext context, SetUserPasswordCommand command)
        {
            var aggregate = context.GetById <User>(command.UserID) as User;

            aggregate.SetPassword(command.UserID, command.Password);

            context.Accept();
        }
Exemplo n.º 6
0
        protected override void ExecuteInContext(IUnitOfWorkContext context, SetUserPropertyCommand command)
        {
            var aggregate = context.GetById <User>(command.UserID) as User;

            aggregate.SetProperty(command.UserID, command.Name, command.Value);

            context.Accept();
        }
        protected override void ExecuteInContext(IUnitOfWorkContext context, AddUserToRoleCommand command)
        {
            var aggregate = context.GetById <User>(command.UserID) as User;

            aggregate.AddToRole(command.UserID, command.Role);

            context.Accept();
        }
Exemplo n.º 8
0
        protected override void ExecuteInContext(IUnitOfWorkContext context, AddInvoiceItem command)
        {
            ITaxRepository taxRepo = NcqrsEnvironment.Get <ITaxRepository>();
            Tax            tax     = taxRepo.FindByCode(command.TaxCode, command.OwnerId);

            Invoice invoice = context.GetById <Invoice>(command.InvoiceId, command.KnownVersion);

            invoice.AddInvoiceItem(command.ItemId, command.Description, command.Quantity, command.Price, command.DiscountInPercent, tax, command.OwnerId, command.UserName);
            context.Accept();
        }
Exemplo n.º 9
0
        protected override void ExecuteInContext(IUnitOfWorkContext context, ValidateUserCommand command)
        {
            var aggregate = context.GetById <User>(command.UserID) as User;

            bool validated = aggregate.Validate(command.UserID, command.Username, command.Password);

            if (validated)
            {
                aggregate.Validated(command.UserID);
                context.Accept();
            }
        }
Exemplo n.º 10
0
        protected override void ExecuteInContext(IUnitOfWorkContext context, CreateUserCommand command)
        {
            var newUser = new User(command.Username);

            context.Accept();
        }
Exemplo n.º 11
0
        protected override void ExecuteInContext(IUnitOfWorkContext context, CreateNewChannelCommand command)
        {
            var newChannel = new Channel(Guid.NewGuid(), command.Name);

            context.Accept();
        }
Exemplo n.º 12
0
        protected override void ExecuteInContext(IUnitOfWorkContext context, PostNewTweetCommand command)
        {
            var newTweet = new Tweet(command.Message, Guid.Parse(command.Channel), command.Who);

            context.Accept();
        }
Exemplo n.º 13
0
        protected override void ExecuteInContext(IUnitOfWorkContext context, PostNewTweetCommand command)
        {
            var newTweet = new Tweet(command.Mensagem, command.Quem);

            context.Accept();
        }