예제 #1
0
        public int Register(DomainCustomer customer, string email)
        {
            var secretCode = GenerateSecretCode();

            var customerDb = Mapper.Map <Customer>(customer);

            customerDb.SecretCode = secretCode;
            _iUnitOfWork.CustomerRepository.Add(customerDb);
            _iUnitOfWork.SaveChanges();

            _iEmailSender.SendSuperSecretCode(email, secretCode);

            return(customerDb.Id);
        }
 public Task <IEnumerable <DomainCharge> > ListAsync(DomainCustomer customer, int count)
 {
     return(Task.Run(() =>
     {
         try
         {
             IEnumerable <StripeCharge> charges = _service.List(count, customer.Id);
             return Task.FromResult(_mapper.Map <IEnumerable <StripeCharge>, IEnumerable <DomainCharge> >(charges));
         }
         catch (StripeException e)
         {
             throw new BillingException(string.Format("Failed to list charges for customer {0}: {1}", customer.Id, e));
         }
     }));
 }
 public Task <DomainCustomer> GetAsync(DomainCustomer customer)
 {
     return(Task.Run(() =>
     {
         try
         {
             StripeCustomer c = _service.Get(customer.Id);
             return Task.FromResult(_mapper.Map <StripeCustomer, DomainCustomer>(c));
         }
         catch (StripeException e)
         {
             throw new BillingException(string.Format("Failed to get customer {0}: {1}", customer.Id, e));
         }
     }));
 }