private int SaveOrderAndEmail(CheckoutDetailsModel checkoutDetailsModel, IShoppingCart shoppingCart) { var orderBuilder = new OrderBuilder(shoppingCart, authentication, mapper); var orderdto = orderBuilder.Build(checkoutDetailsModel); var orderNumber = orderRepository.Save(orderdto); if (orderNumber > 0) { var cartItemBuilder = new CartItemViewModelBuilder(jewelRepository, diamondRepository, mapper); var emailTemplateBuilder = new OrderConfirmationEmailTemplateViewModelBuilder(orderNumber.ToString(), checkoutDetailsModel, shoppingCart, cartItemBuilder); var emailTemplateViewModel = emailTemplateBuilder.Build(); mailer.OrderConfirmation(checkoutDetailsModel.Email, emailTemplateViewModel).Send(); } return(orderNumber); }