Пример #1
0
 public CreditCard(CreditCardCreateCommand command)
 {
     CreditCardHolderName = command.CreditCardHolderName;
     CardNumber           = command.CardNumber;
     CreditCardType       = command.CreditCardType.Name;
     ExpireMonth          = command.ExpireMonth;
     ExpireYear           = command.ExpireYear;
     PersonId             = command.PersonId;
 }
Пример #2
0
        public Person Take(CreditCardCreateCommand command)
        {
            var creditCard = new CreditCard(command);

            this.CreditCards.Add(creditCard);

            base.AddEvent(new PersonCreditCardCreateDomainEvent
            {
                AggregateRootId = Id,
                CommandJson     = JsonConvert.SerializeObject(command),
                UserId          = command.UserId
            });

            return(this);
        }
        public async Task <ICommandHandlerAggregateAnswer> HandleAsync(CreditCardCreateCommand command)
        {
            var answer = new CommandHandlerAggregateAnswer();
            var person = await personRepository.Query(command.PersonId);

            if (person.IsNotNull())
            {
                answer.ValidationResult = this.createCreditCardValidationHandler.Validate(command);

                if (command.IsValid)
                {
                    answer.AggregateRoot = await personRepository.Update(person.Take(command));
                }
            }
            return(answer);
        }