Example #1
0
        public static Result CreateCustomer(string name, string billingInfo)
        {
            Result <BillingInfo>  billingInfoResult  = BillingInfo.Create(billingInfo);
            Result <CustomerName> customerNameResult = CustomerName.Create(name);

            return(Result.Combine(billingInfoResult, customerNameResult)
                   .OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value))
                   .OnSuccess(() => new Customer(customerNameResult.Value))
                   .OnSuccess(customer => _repository.Save(customer)
                              .OnFailure(() => _paymentGateway.RollbackLastTransaction()))
                   .OnSuccess(() => _emailSender.SendGreetings(customerNameResult.Value))
                   .OnBoth(result => Log(result)));
        }
Example #2
0
 public Customer(CustomerName value)
 {
     this.value = value;
 }
Example #3
0
 internal Result SendGreetings(CustomerName value)
 {
     throw new NotImplementedException();
 }