public ActionResult PayBill(PaymentControlModel paymentDetails) { using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { try { DTHManager.SaveTransactionDetails(new OnePointTelecom.Models.Objects.Transaction(paymentDetails)); if (paymentDetails.Type == TransactionType.PostpaidBill) MobileManager.UpdateBillStatusToPaid(paymentDetails.PostpaidBillId); else if (paymentDetails.Type == TransactionType.NewConnection) MobileManager.AddMobileConnection(paymentDetails.CustomerId, paymentDetails.MobileSchemeId, paymentDetails.PhoneNumber); else if (paymentDetails.Type == TransactionType.DTHPackageSubscription) { if (paymentDetails.AvailDiscount == 1) { bool updateSuccess = UserManager.UpdateUserPoints(paymentDetails.CustomerId, 0); DTHPackage package = DTHManager.GetDTHPackage(paymentDetails.PackageId); updateSuccess = UserManager.UpdateUserPoints(paymentDetails.CustomerId, package.Points); } HttpWebRequest req = WebRequest.Create("http://localhost:51254/Transaction.svc/GetVoucherId") as HttpWebRequest; req.KeepAlive = false; req.Method = "GET"; HttpWebResponse resp = req.GetResponse() as HttpWebResponse; Encoding enc = System.Text.Encoding.GetEncoding(1252); StreamReader loResponseStream = new StreamReader(resp.GetResponseStream(), enc); string Response = loResponseStream.ReadToEnd(); loResponseStream.Close(); resp.Close(); ViewBag.VoucherId = Response; } ts.Complete(); } catch(Exception ex) { ts.Dispose(); MvcApplication.SetMessage("Transaction Error Occured."); ViewBag.Message = MvcApplication.GetMessage(); View(paymentDetails); } } return View("TransactionInfo",paymentDetails); }
public AvailPackageViewModel() { dthPackage = new DTHPackage(); paymentModel = new PaymentControlModel(); }