Exemple #1
0
 public ActionResult Transfer(tranferamount ta)
 {
     if (ModelState.IsValid)
     {
         var i = ib.Transfer(ta);
         ib.save();
         ModelState.Remove("Amount");
         ModelState.Remove("To");
         if (i == "completed")
         {
             ViewBag.cla      = "panel-success";
             ViewBag.headi    = "Transaction";
             ViewBag.transfer = " Transaction completed Sucessfully";
             return(View("Partialviews"));
         }
         if (i == "Failed")
         {
             ModelState.Remove("Amount");
             ModelState.Remove("To");
             ViewBag.cla      = "panel-warning";
             ViewBag.headi    = "Transaction";
             ViewBag.transfer = " Transaction Failed";
             return(View("Partialviews"));
         }
         ViewBag.cla      = "panel-warning";
         ViewBag.headi    = "Transaction";
         ViewBag.transfer = " Transaction Failed due to receiver account is not available (or) you not having the balance";
         ModelState.Remove("Amount");
         ModelState.Remove("To");
         return(View("Partialviews"));
     }
     return(View());
 }
Exemple #2
0
        //Transfer one account to another account
        public string Transfer(tranferamount ta)
        {
            bool debitmoney  = false;
            bool creditmoney = false;

            try
            {
                using (TransactionScope ts = new TransactionScope())      //Transaction scope
                {
                    var from = profile();
                    var to   = db.Generaltable.Where(a => a.Username.Equals(ta.To)).FirstOrDefault();
                    if (from.AccountBalance >= ta.Amount && to != null)
                    {
                        BankAccount bafrom = from;               //in Bankaccount table Debited our amount
                        bafrom.AccountBalance = bafrom.AccountBalance - ta.Amount;

                        BankAccount bato = to;                   //in Bankaccount Credited to amount
                        bato.AccountBalance = bato.AccountBalance + ta.Amount;

                        Transactionsdetail tddebit = new Transactionsdetail();     //Transaction history for debited
                        tddebit.Username     = username;
                        tddebit.Tousername   = ta.To;
                        tddebit.Datetimes    = DateTime.Now;
                        tddebit.Debited      = ta.Amount;
                        tddebit.Credited     = null;
                        tddebit.Balance      = bafrom.AccountBalance;
                        tddebit.Typeofaction = "Transaction";
                        db.transdetails.Add(tddebit);

                        Transactionsdetail tdcredit = new Transactionsdetail();     //Transaction history for credited
                        tdcredit.Username     = ta.To;
                        tdcredit.Tousername   = username;
                        tdcredit.Datetimes    = DateTime.Now;
                        tdcredit.Debited      = null;
                        tdcredit.Credited     = ta.Amount;
                        tdcredit.Typeofaction = "Transaction";
                        tdcredit.Balance      = bato.AccountBalance;
                        db.transdetails.Add(tdcredit);
                        debitmoney  = true;
                        creditmoney = true;
                        if (debitmoney && creditmoney)        //all done correctly it will go on this loop
                        {
                            ts.Complete();
                            return("completed");
                        }
                    }
                }
            }
            catch
            {
                return("Failed");         //any error came in try it will fail the transaction
            }
            return("no");
        }
Exemple #3
0
 public ActionResult Deposite(tranferamount ta)
 {
     if (ModelState.IsValid)
     {
         ib.Deposite(ta);
         ib.save();
         ViewBag.cla      = "panel-success";
         ViewBag.headi    = "Deposite";
         ViewBag.transfer = "Deposited sucessfully";
         return(View("Partialviews"));
     }
     return(View());
 }
Exemple #4
0
        public void Deposite(tranferamount ta)
        {
            var         userdeposite = profile();
            BankAccount ba           = userdeposite;

            ba.AccountBalance = ba.AccountBalance + ta.Amount;   //Credited user amount

            Transactionsdetail td = new Transactionsdetail();    //Transaction history

            td.Username     = ta.Username;
            td.Typeofaction = "Deposit";
            td.Tousername   = ta.To;
            td.Credited     = ta.Amount;
            td.Datetimes    = DateTime.Now;
            td.Balance      = ba.AccountBalance;
            db.transdetails.Add(td);
        }
Exemple #5
0
 public ActionResult Withdraw(tranferamount ta)
 {
     if (ModelState.IsValid)
     {
         var i = ib.Withdraw(ta);
         ib.save();
         if (i == "Completed")
         {
             ViewBag.cla      = "panel-success";
             ViewBag.headi    = "Withdraw";
             ViewBag.transfer = "Withdraw sucessfully";
             return(View("Partialviews"));
         }
         ViewBag.cla      = "panel-warning";
         ViewBag.headi    = "Withdraw";
         ViewBag.transfer = "Withdraw Failed Check your account name and your balance";
         return(View("Partialviews"));
     }
     return(View());
 }
Exemple #6
0
        public string Withdraw(tranferamount ta)
        {
            var userwithdraw = profile();

            if (userwithdraw.AccountBalance >= ta.Amount)            //check User having that much amount
            {
                BankAccount ba = userwithdraw;                       //Debited user amount
                ba.AccountBalance = ba.AccountBalance - ta.Amount;

                Transactionsdetail td = new Transactionsdetail();    //Transaction history
                td.Username     = ta.Username;
                td.Tousername   = ta.To;
                td.Typeofaction = "Withdraw";
                td.Balance      = ba.AccountBalance;
                td.Debited      = ta.Amount;
                td.Datetimes    = DateTime.Now;
                db.transdetails.Add(td);
                return("Completed");
            }
            return("Failed");
        }