コード例 #1
0
        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());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public BookListPageModel(IBookGateway bookGateway)
 {
     _bookGateway = bookGateway;
 }
コード例 #4
0
 public BookServiceClient(IBookGateway bookGateway, IRestApiService restApiGateway)
 {
     _bookGateway    = bookGateway;
     _restApiService = restApiGateway; _apiController = "Book";
 }