public ActionResult ViewDetail(FormCollection formCollection) { try { PurchaseDetail purchaseDetail = new PurchaseDetail(); // Retrieve form data using form collection purchaseDetail.BookID = Convert.ToInt32(formCollection["BookID"]); purchaseDetail.Amount = Convert.ToDouble(formCollection["Price"]); purchaseDetail.transactionstatus = "Success"; purchaseDetail.transactionType = formCollection["PayType"]; purchaseDetail.PurchaseID = 0; purchaseDetail.PurchasedOn = DateTime.Now; purchaseDetail.Userid = 1; BookGateway.BookGatewayFactory bookFactory = new BookGateway.BookGatewayFactory(); IBookGateway bookGateway = bookFactory.GetBookGateway(purchaseDetail.transactionType); PurchaseDetail opurchaseDetail = bookGateway.SavePaymentDetails(purchaseDetail); TempData["Message"] = "<span style='color:blue;'>Book purchased successfully</span>"; return(RedirectToAction("Index")); } catch (Exception ex) { TempData["Message"] = "<span style='color:red;'>" + ex.Message + "</span>"; } return(View()); }
public IBookGateway GetBookGateway(string type) { IBookGateway returnvalue = null; if (type.ToLower() == "paypal") { returnvalue = new Paypal(); } else if (type.ToLower() == "stripnet") { returnvalue = new StripNet(); } return(returnvalue); }
public BookListPageModel(IBookGateway bookGateway) { _bookGateway = bookGateway; }
public BookServiceClient(IBookGateway bookGateway, IRestApiService restApiGateway) { _bookGateway = bookGateway; _restApiService = restApiGateway; _apiController = "Book"; }