public ActionResult Register(User_Registeration user) { /*if(ModelState.IsValid) * {*/ context = new DBContext(); if (user != null) { context.User_Registerations.Add(user); if (user.UserCategory == Category.Customer) { Customer_Wallet wallet = new Customer_Wallet() { CustomerId = user.UserId, Balance = 0 }; context.Customer_Wallets.Add(wallet); } context.SaveChanges(); ViewBag.Message = String.Format("New User Created Succesfully"); } return(View()); /*} * ViewBag.Message = "UserId Already Taken"; * return View();*/ }
public ActionResult Add_Money(PaymentCard card) { DBContext context = new DBContext(); if (card != null) { Customer_Wallet wallet = context.Customer_Wallets.FirstOrDefault(m => m.CustomerId == Session["Customer ID"].ToString()); } return(View()); }
public ActionResult AddMoneyViaCard(Billing bill) { User_Registeration cust = Session["Customer"] as User_Registeration; string custId = cust.UserId; Customer_Wallet wallet = context.Customer_Wallets.FirstOrDefault(w => w.CustomerId == custId); Session["WalletBalance"] = wallet.Balance; if (wallet.Balance >= bill.total_Amt) { int newBal = wallet.Balance - bill.total_Amt; context.Customer_Wallets.FirstOrDefault(w => w.CustomerId == custId).Balance = newBal; context.SaveChanges(); Session["Display"] = "Rs. " + bill.total_Amt + " has been Debited from your Wallet. Your remaining Balance is Rs." + newBal; return(RedirectToAction("ConfirmBooking")); } else { int reqMoney = bill.total_Amt - wallet.Balance; Session["Display"] = "Add Rs. " + reqMoney + " to your card."; } return(View()); }