Created
February 23, 2020 12:00
-
-
Save pereiren/39f3e3417aea9912846ebfe56a1a2e81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CartService : ICartService | |
{ | |
//... | |
CheckoutService checkoutDomainService; | |
public CartService(... CheckoutService checkoutDomainService ...) | |
{ | |
//... | |
this.checkoutDomainService = checkoutDomainService; | |
} | |
public CheckOutResultDto CheckOut(Guid customerId) | |
{ | |
CheckOutResultDto checkOutResultDto = new CheckOutResultDto(); | |
Cart cart = this.cartRepository.FindOne(new CustomerCartSpec(customerId)); | |
this.validateCart(customerId, cart); | |
Customer customer = this.customerRepository.FindById(cart.CustomerId); | |
Nullable<CheckOutIssue> checkOutIssue = | |
this.checkoutDomainService.CanCheckOut(customer, cart); | |
if (!checkOutIssue.HasValue) | |
{ | |
Purchase purchase = this.checkoutDomainService.Checkout(customer, cart); | |
checkOutResultDto = Mapper.Map<Purchase, CheckOutResultDto>(purchase); | |
this.unitOfWork.Commit(); | |
} | |
else | |
{ | |
checkOutResultDto.CheckOutIssue = checkOutIssue; | |
} | |
return checkOutResultDto; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment