public Dictionary <bool, List <string> > Process(OrderViewModel order) { if (_productRepository.CheckInventory(order.Product.ProductID, order.Quantity)) { var prodInDb = _productRepository.GetProductfromDb(order.Product.ProductID); var totalPrice = order.Quantity * prodInDb.UnitPrice * (1 - prodInDb.Discount); if (_paymentSeriveRepository.ChargePayment(order.CardDetails.CardNum, totalPrice)) { //ToDO //Update Procucts table with the updated quantity in stock //Insert into OrderTable, OrderDetails Table _emailRepository.SendEmail("*****@*****.**", "Order status", "Order placed Successfully"); } else { errors.Add("Payment Declined"); } } else { errors.Add("Out of stock"); } bool isSucess = !errors.Any(); return(new Dictionary <bool, List <string> > { { isSucess, errors } }); }
public bool ChargePaymentTestCase(string creditCardNumber, decimal amount) { return(_paymentServiceRepository.ChargePayment(creditCardNumber, amount)); }