public async Task <IActionResult> Cardpayment(string cardno, int mm, int yy, int cvv) { /* var card = await _context.Cards * .FirstOrDefaultAsync(m => m.CardNumber == cardno);*/ var card = await _classRepository.FindByCardAsync(cardno); HttpContext.Session.SetString(Sessioncard1, cardno); HttpContext.Session.SetString(Sessioncardobj.ToString(), card.ToString()); /*var booking = _context.Bookings * .OrderByDescending(a => a.BookingID) * .First();*/ //ViewBag.cd = card; //return View(); ViewBag.paymentStatus = "fail"; //ViewBag.pkgid = (int)TempData["packageid"]; //HttpContext.Session.SetInt32(Sessionpkgid1, (int)TempData["packageid"]); if (card == null) { ViewBag.message1 = "Payment failed due to wrong card number!"; } else { if (card.month != mm || (card.year != yy || card.CVV != cvv)) { ViewBag.message1 = "Payment failed due to wrong card Details!"; } else if (card.balance < HttpContext.Session.GetInt32(SessionAmt1)) { ViewBag.message1 = "Payment failed due to insufficient balance!"; } else { var mailid = card.mailid; ViewBag.mail = mailid; var random = new Random(); int OTP = random.Next(100001, 999999); HttpContext.Session.SetInt32(SessionOtp1, OTP); string Subject = "OTP for your Debit Card Payment"; string body = "Your OTP Via Debit card Payment on Cylinder booking site is " + OTP; _classRepository.SendMailForPaper(mailid, Subject, body); return(View("OTP")); } } return(View()); }