Beispiel #1
0
        ////******************currency withdrawl


        public ActionResult GetCurrWithDraw(int id)
        {
            AtmAccount b = db.AtmAccounts.Find(id); ////finds the account according to the the value 'id' which is the 'atmaccId' (primary key) in the database


            return(View(b));
        }
Beispiel #2
0
        public string GetDeposit(string cbal, string amount, string ano, int aid, int atypeid) //These variables are populated from the ajax in the view
        {
            decimal currentbalance = Decimal.Parse(cbal);                                      //assigning a variable to the current balance prior to deposit
            decimal am             = Decimal.Parse(amount);                                    ///amount to be deposited
            decimal total          = am + currentbalance;                                      ////creating the new balance

            AtmAccount a = new AtmAccount();                                                   ////creates another instance of AtmAccount

            a.AccountNumber  = ano;                                                            //assigning the values to the properties
            a.AccountBalance = total;
            a.atmaccId       = aid;
            a.AccTypeId      = atypeid;
            a.AccUserId      = User.Identity.GetUserId();

            db.Entry(a).State = System.Data.Entity.EntityState.Modified; //THIS MODIFIES THE DATABASE WITH THE NEW DATA
            db.SaveChanges();

            ////THIS CREATES A RECORD IN THE TRANSACTIONS TABLE
            Transaction t = new Transaction();

            t.atmaccId    = aid;
            t.TransAmount = am;
            t.TransDate   = DateTime.Now; //DATE AND TIME OF TRANSACTION
            t.TranstypeId = 1;            ////REPRESENTS A DEPOSIT IN THE TRANSACTIONTYPE TABLE

            db.Transactions.Add(t);
            db.SaveChanges();
            return("£" + am + " Deposited successfully ");
        }
Beispiel #3
0
        public ActionResult Create(AtmAccount atm)
        {
            db.AtmAccounts.Add(atm);//This creates the new record/account in the database
            db.SaveChanges();

            return(RedirectToAction("index"));
        }
Beispiel #4
0
        public ActionResult Manageaccount(int id)   //This method is called when a user clicks on 'manage account'
        {
            AtmAccount a = db.AtmAccounts.Find(id); ////finds the account according to the the value 'id' which is the 'atmaccId' (primary key) in the database


            return(View(a));
        }
 public ActionResult Deposit([Bind(Include = "Id,TransAmount,TransDate,TransTypeId,AtmAccountId")] Transaction transaction)
 {
     if (ModelState.IsValid)
     {
         AtmAccount accounts = db.AtmAccounts.Find(transaction.Id);
         ViewBag.AtmAccountId = accounts.AccountNumber;
         ViewBag.TransTypeId  = new SelectList(db.TransTypes, "Id", "TransactionType");
         if (accounts == null)
         {
             return(new HttpNotFoundResult());
         }
         var balance = accounts.AccountBalance;     //Sets account balance
         balance = balance + transaction.TransAmount;
         accounts.AccountBalance  = balance;
         transaction.TransTypeId  = 2;    //2 is deposit in the transaction type table
         transaction.TransDate    = DateTime.Now;
         transaction.AtmAccountId = transaction.Id;
         ViewBag.AtmAccountId     = new SelectList(db.AtmAccounts, "Id", "AccountNumber", transaction.AtmAccountId);
         ViewBag.TransTypeId      = new SelectList(db.TransTypes, "Id", "TransactionType", transaction.TransTypeId);
         db.Transactions.Add(transaction);
         db.SaveChanges();
         return(RedirectToAction("Index", "Transactions"));
     }
     return(Content("Insufficient funds available"));
 }
        // GET: Transactions/Deposit
        public ActionResult Deposit(int?id)
        {
            AtmAccount accounts = db.AtmAccounts.Find(id);

            ViewBag.AtmAccountId = accounts.AccountNumber;
            return(View());
        }
        // GET: Transactions/QuickWithdrawal
        public ActionResult QuickWithdrawal(int?id)
        {
            AtmAccount accounts = db.AtmAccounts.Find(id);

            ViewBag.AtmAccountId = accounts.AccountNumber;
            ViewBag.TransTypeId  = new SelectList(db.TransTypes, "Id", "TransactionType");
            if (accounts == null)
            {
                return(new HttpNotFoundResult());
            }
            var balance = accounts.AccountBalance;

            if (balance < 100)
            {
                return(Content("Insufficient funds available"));
            }
            else
            {
                balance = balance - 100;
                accounts.AccountBalance = balance;
                Transaction transaction = new Transaction();
                transaction.TransAmount  = 100;
                transaction.TransDate    = DateTime.Now;
                transaction.TransTypeId  = 1;
                transaction.AtmAccountId = accounts.Id;
                db.Transactions.Add(transaction);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
        }
Beispiel #8
0
        public ActionResult DeleteConfirmed(int id)
        {
            AtmAccount atmAccount = db.AtmAccounts.Find(id);

            db.AtmAccounts.Remove(atmAccount);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #9
0
 public ActionResult Edit([Bind(Include = "atmaccId,AccountNumber,AccountBalance,AccTypeId,AccUserId")] AtmAccount atmAccount)
 {
     if (ModelState.IsValid)
     {
         db.Entry(atmAccount).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AccTypeId = new SelectList(db.AccTypes, "acctypeId", "AccountType", atmAccount.AccTypeId);
     return(View(atmAccount));
 }
Beispiel #10
0
        public ActionResult Create()
        {
            string     accno = RandomDigits(10);            ////assigns a random number to the 'accno' variable
            AtmAccount atm   = new AtmAccount();            ////creates a new instance of AtmAccount from the model called atm

            atm.AccountNumber  = accno;                     //// assigning values to the properties
            atm.AccountBalance = 0;                         //// assigning values to the properties
            atm.AccUserId      = User.Identity.GetUserId(); //// assinging the id of the currently logged in user to a property of atm

            ViewBag.acctypeId = new SelectList(db.AccTypes, "acctypeId", "AccountType");
            return(View(atm));
        }
        public ActionResult Create([Bind(Include = "Id,AccountNumber,AccountBalance,AppUserId,AccTypeId")] AtmAccount atmAccount)
        {
            if (ModelState.IsValid)
            {
                atmAccount.AppUserId = User.Identity.GetUserId();
                db.AtmAccounts.Add(atmAccount);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccTypeId = new SelectList(db.AccTypes, "Id", "AccountType", atmAccount.AccTypeId);
            return(View(atmAccount));
        }
Beispiel #12
0
        // GET: newatmCont/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AtmAccount atmAccount = db.AtmAccounts.Find(id);

            if (atmAccount == null)
            {
                return(HttpNotFound());
            }
            return(View(atmAccount));
        }
Beispiel #13
0
        // GET: newatmCont/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AtmAccount atmAccount = db.AtmAccounts.Find(id);

            if (atmAccount == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AccTypeId = new SelectList(db.AccTypes, "acctypeId", "AccountType", atmAccount.AccTypeId);
            return(View(atmAccount));
        }
Beispiel #14
0
        public string GetWithDraw(string cbal, string amount, string ano, int aid, int atypeid, string currency)
        {
            string  msg            = "";
            decimal currentbalance = Decimal.Parse(cbal);

            if (currentbalance > 0)
            {
                decimal am    = Decimal.Parse(amount);
                decimal total = currentbalance - am;
                if (total > 0)
                {
                    AtmAccount a = new AtmAccount();
                    a.AccountBalance  = total;
                    a.AccountNumber   = ano;
                    a.AccTypeId       = atypeid;
                    a.atmaccId        = aid;
                    a.AccUserId       = User.Identity.GetUserId();
                    db.Entry(a).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();


                    Transaction t = new Transaction();
                    t.atmaccId    = aid;
                    t.TransAmount = am;
                    t.TransDate   = DateTime.Now;
                    t.TranstypeId = 2; ////represents a withdrawl in the transactiontype table

                    db.Transactions.Add(t);
                    db.SaveChanges();
                    msg = "£" + am + " Amount Withdrawn successfully";
                }
                else
                {
                    msg = "Insufficent Balance, Sorry !!!!!!!!!!!!!!!";
                }
            }
            else
            {
                msg = "You don't Have any Money, Sorry !!!!!!!!!!!!!!!";
            }

            return(msg);
        }
Beispiel #15
0
        public string GetCurrWithDraw(string cbal, decimal amount, string ano, int aid, int atypeid, decimal currency, string currencyName)
        {
            decimal newAmount = amount;
            string  msg       = "";

            /////Conversion Start
            if (currencyName == "Euro")
            {
                newAmount = 1 / currency * newAmount;


                msg = amount + " Euros Sucessfully withdrawn at the exchange rate of £1 to every " + currency;
            }
            else if (currencyName == "Dollar")
            {
                newAmount = 1 / currency * newAmount;
                msg       = amount + " US Dollars Sucessfully withdrawn at the exchange rate " + currency;
            }
            else if (currencyName == "Yen")
            {
                //newAmount = 1 / currency * newAmount;
                newAmount = Math.Truncate(1 / currency * newAmount);
                msg       = amount + " Japanese Yen Sucessfully withdrawn at the exchange rate " + currency;
            }
            else if (currencyName == "Yuan")
            {
                newAmount = 1 / currency * newAmount;
                msg       = amount + " Chinese Yaun Sucessfully withdrawn at the exchange rate " + currency;
            }
            else if (currencyName == "Rubel")
            {
                newAmount = 1 / currency * newAmount;
                msg       = amount + " Russian Rubels Sucessfully withdrawn at the exchange rate " + currency;
            }
            else if (currencyName == "KongDollar")
            {
                newAmount = 1 / currency * newAmount;
                msg       = amount + " Hong Kong Dollars Sucessfully withdrawn at the exchange rate " + currency;
            }
            ////Conversion End



            decimal currentbalance = Decimal.Parse(cbal);

            if (currentbalance > 0)
            {
                decimal am    = newAmount;
                decimal total = currentbalance - am;
                if (total > 0)
                {
                    AtmAccount a = new AtmAccount();
                    a.AccountBalance  = total;
                    a.AccountNumber   = ano;
                    a.AccTypeId       = atypeid;
                    a.atmaccId        = aid;
                    a.AccUserId       = User.Identity.GetUserId();
                    db.Entry(a).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();


                    Transaction t = new Transaction();
                    t.atmaccId    = aid;
                    t.TransAmount = am;
                    t.TransDate   = DateTime.Now;
                    t.TranstypeId = 2; ////represents a withdrawl in the transactiontype table

                    db.Transactions.Add(t);
                    db.SaveChanges();
                    //msg = am + " Amount Withdrawn successfully.....";
                }
                else
                {
                    msg = "Insufficent Balance, Sorry !!!!!!!!!!!!!!!";
                }
            }
            else
            {
                msg = "You don't Have any Money, Sorry !!!!!!!!!!!!!!!";
            }

            return(msg);
        }