コード例 #1
0
        /// <summary>
        /// Details Action Method Shows Personal Details of Customwers
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BanksCustomer banksCustomer = db.BanksCustomers.SingleOrDefault(m => m.AccountNumber == id);

            if (banksCustomer == null)
            {
                return(HttpNotFound());
            }
            return(View(banksCustomer));
        }
コード例 #2
0
        public ActionResult SignUp(BanksCustomer banks_Customer)
        {
            if (ModelState.IsValid)
            {
                using (var db = new BankEntities1())
                {
                    banks_Customer.UserRole       = "Customer";
                    banks_Customer.CurrentBalance = 0;
                    banks_Customer.Fund           = 0;
                    db.BanksCustomers.Add(banks_Customer);

                    db.SaveChanges();
                    return(RedirectToAction("Login", "Login"));
                }
            }
            return(View());
        }
コード例 #3
0
        public ActionResult AddFund(Fund fund)
        {
            if (ModelState.IsValid)
            {
                //Customers Fund Increases into BanksCustomer Table
                BanksCustomer banksCustomer = db.BanksCustomers.Where(u => u.AccountNumber == fund.AccountNumber).FirstOrDefault();
                LoginDetails  updateFund    = db2.LoginDetails.Where(u => u.AccountNumber1 == fund.AccountNumber).FirstOrDefault();
                updateFund.Fund = banksCustomer.Fund + fund.Fund1;
                db2.Entry(updateFund).Property("Fund").IsModified = true;
                db2.SaveChanges();

                //Save Funds History into Fund Table
                db.Funds.Add(fund);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View());
        }
コード例 #4
0
        public ActionResult Transfer([Bind(Include = "AccountNumber,TransferFrom,TransferTo,TransferAmount,TransferDate,CurrentBalance,Funds,CustomerName")] TransactionDetail transactionDetail)
        {
            if (Session["UserName"] != null && Session["UserRole"].ToString().Contains("Customer"))
            {
                if (ModelState.IsValid)
                {
                    transactionDetail.TransferDate  = DateTime.Now;
                    transactionDetail.AccountNumber = Convert.ToInt32(Session["AccountNumber"]);
                    transactionDetail.TransferFrom  = Convert.ToInt32(Session["AccountNumber"]);
                    transactionDetail.CustomerName  = Convert.ToString(Session["CustomerName"]);
                    db2.TransactionDetails.Add(transactionDetail);
                    db2.SaveChanges();

                    //Receivers Balance Increases
                    BanksCustomer banksCustomer = new BanksCustomer();
                    banksCustomer = db2.BanksCustomers.Where(u => u.AccountNumber == transactionDetail.TransferTo).FirstOrDefault();
                    LoginDetails updateBalanceReveiver = db.LoginDetails.Where(u => u.AccountNumber1 == transactionDetail.TransferTo).FirstOrDefault();
                    updateBalanceReveiver.CurrentBalance += transactionDetail.TransferAmount;
                    db.Entry(updateBalanceReveiver).Property("CurrentBalance").IsModified = true;
                    db.SaveChanges();

                    //Senders Balance Decreases
                    banksCustomer = db2.BanksCustomers.Where(u => u.AccountNumber == transactionDetail.TransferFrom).FirstOrDefault();
                    LoginDetails updateBalanceSender = db.LoginDetails.Where(u => u.AccountNumber1 == transactionDetail.TransferFrom).FirstOrDefault();
                    updateBalanceSender.CurrentBalance -= transactionDetail.TransferAmount;
                    db.Entry(updateBalanceSender).Property("CurrentBalance").IsModified = true;
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }

                ViewBag.ReceiversAccountNumber = new SelectList(db2.BanksCustomers.Where(u => u.UserRole.ToString().Contains("Customer")), "AccountNumber", "AccountNumber", transactionDetail.AccountNumber);
                return(View(transactionDetail));
            }

            Response.Write("<script>alert('Session logged out. Sign in again');</script>");
            FormsAuthentication.SignOut();
            Session.Clear();
            return(RedirectToAction("SignIn", "Auth"));
        }