public PaymentProcessViewModel Post(PaymentViewModel model) { // validation if (ModelState.IsValid == false) { throw new HttpRequestException(); } // map the payment Payment payment = new Payment { CreatedDate = model.CreatedDate, Id = 1, Price = model.Price, Product = _ProductTagservice.FindInclude(x => x.Id == model.ProductTagId, x => x.Products).SingleOrDefault().Products.Find(x => x.Id == model.ProductId), Status = model.Status }; // process the payment _RuleEngine.ProcessPayment(payment, model.Description); // read the log and delete it string content = Logger.ReadLog(_PathMapper); return(new Models.PaymentProcessViewModel { Content = content, CreatedDate = DateTime.Now }); }
public void TestGenerateComission() { //Data Set Up PaymentInfo payment = new PaymentInfo() { PaymentType = "Book", CustomerId = 100, OrderId = 10, PaymentId = 101 }; PaymentRuleEngine pr = new PaymentRuleEngine(); //Execute var result = pr.ProcessPayment(payment); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Contains("CommisionGenerated")); }
public void TestMembershipActivation() { //Data Set Up PaymentInfo payment = new PaymentInfo() { PaymentType = "Membership", CustomerId = 100, OrderId = 10, PaymentId = 101 }; PaymentRuleEngine pr = new PaymentRuleEngine(); //Execute var result = pr.ProcessPayment(payment); //Assert Assert.IsNotNull(result); Assert.IsTrue(result.Contains("MembershipActivated")); }