public async Task <IActionResult> Netbankingpayment(string bank, string uname, string passwd) { var bankuser = await _classRepository.FindNetbankingAsync(uname); if (bankuser == null) { ViewBag.message1 = "Payment failed because Invalid Username!"; } else { if (bankuser.Password != passwd || bankuser.Bank != bank) { ViewBag.message1 = "Payment failed due to Invalid password or Bank!"; } else if (bankuser.balance < HttpContext.Session.GetInt32(SessionAmt1)) { ViewBag.message1 = "Payment failed due to insufficient balance!"; } else { var user1 = _userManager.FindByNameAsync(User.Identity.Name.ToUpper()); var book = user1.Result.Bookings; string mailid = user1.Result.Email; var random = new Random(); int dac = random.Next(1001, 9999); Cylinder cylinder = await _classRepository.SetQuantityofCylinderAsync(HttpContext.Session.GetString(SessionCyltype).ToString()); var book1 = new Booking { Booking_Id = ObjectId.GenerateNewId().ToString(), Cylinder_Id = cylinder.Cylinder_Id, Amount = Int32.Parse(HttpContext.Session.GetInt32(SessionAmt1).ToString()), BookingDate = DateTime.Now, PaymentMethod = "Netbanking", SubsidyAmount = cylinder.SubsidyAmount, OrderStatus = "Confirmed-Payment Received", DAC = dac.ToString() }; ViewBag.id1 = book1.Booking_Id; book.Add(book1); user1.Result.Bookings = book; bankuser.balance = (int)(bankuser.balance - HttpContext.Session.GetInt32(SessionAmt1)); await _userManager.UpdateAsync(user1.Result); ViewBag.paymentStatus = "success"; _classRepository.updateNetbankingBalance(bankuser); ViewBag.message1 = "woohoo! Your payment is successfull. Enjoy your Trip :)"; string Subject = "Voila! Your Cylinder is booked! "; string body = " Your Cylinder is booked via Reference No." + book1.Booking_Id + ". Your Payment ₹" + HttpContext.Session.GetInt32(SessionAmt1).ToString() + " is received.Your DAC is " + dac.ToString() + " .Which you have to give our Delivery partener at Delivery time. Thanks for " + "using our service."; _classRepository.SendMailForPaper(mailid, Subject, body); } } return(View("Cardpayment")); }