public CreditCardDto Add(Guid customerId, CreditCardDto creditCardDto)
        {
            ISpecification<Customer> registeredSpec =
                new CustomerRegisteredSpec(customerId);

            Customer customer = this.customerRepository.FindOne(registeredSpec);

            if (customer == null)
                throw new Exception("No such customer exists");

            CreditCard creditCard =
                CreditCard.Create(customer, creditCardDto.NameOnCard,
                creditCardDto.CardNumber, creditCardDto.Expiry);

            customer.Add(creditCard);

            this.unitOfWork.Commit();

            return AutoMapper.Mapper.Map<CreditCard, CreditCardDto>(creditCard);
        }
Exemple #2
0
        public CreditCardDto Add(Guid customerId, CreditCardDto creditCardDto)
        {
            ISpecification <Customer> registeredSpec =
                new CustomerRegisteredSpec(customerId);

            Customer customer = this.customerRepository.FindOne(registeredSpec);

            if (customer == null)
            {
                throw new Exception("No such customer exists");
            }

            CreditCard creditCard =
                CreditCard.Create(customer, creditCardDto.NameOnCard,
                                  creditCardDto.CardNumber, creditCardDto.Expiry);

            customer.Add(creditCard);

            this.unitOfWork.Commit();

            return(AutoMapper.Mapper.Map <CreditCard, CreditCardDto>(creditCard));
        }