public bool ProcessOrder(Order order) { if (_inventoryRepository.CheckInventory(order.Item.ProductID, order.Quantity)) { if (_paymentService.ChargePayment(order.CardInfo.creditCardNumber, order.CardInfo.amount)) { _orderRepository.AddOrder(order); StringBuilder body = new StringBuilder(); body.AppendLine("A new order has been submitted"); EmailSettings emailSettings = new EmailSettings(); MailMessage mailMessage = new MailMessage( emailSettings.MailFromAddress, emailSettings.MailToAddress, "New order submitted!", body.ToString()); _emailService.SendEmail(mailMessage); return(true); } else { throw new Exception("Payment Declined"); } } else { throw new Exception("The ordered Qunatity is not available"); } }
public bool CheckInventory(int productId, int quantity) { return(_inventoryRepository.CheckInventory(productId, quantity)); }
public async Task <bool> CheckInventory(string productId, int qty) { return(await _inventoryRepository.CheckInventory(productId, qty).ConfigureAwait(false)); }