public ActionResult Edit(ChequingAccount chequingaccount)
 {
     if (ModelState.IsValid)
     {
         db.Entry(chequingaccount).State = EntityState.Modified;
         chequingaccount.ChangeState();
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", chequingaccount.AccountStateId);
     ViewBag.ClientId       = new SelectList(db.Clients, "ClientId", "FullName", chequingaccount.ClientId);
     return(View(chequingaccount));
 }
        public ActionResult Create(ChequingAccount chequingaccount)
        {
            chequingaccount.SetNextAccountNumber();
            if (ModelState.IsValid)
            {
                db.BankAccounts.Add(chequingaccount);
                db.SaveChanges();
                chequingaccount.ChangeState();
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", chequingaccount.AccountStateId);
            ViewBag.ClientId       = new SelectList(db.Clients, "ClientId", "FullName", chequingaccount.ClientId);
            return(View(chequingaccount));
        }
        public ActionResult Create(ChequingAccount chequingaccount)
        {
            //this code has been modified
            if (ModelState.IsValid)
            {
                //Setting the chequing account number to the next available one when creating a new chequing account
                chequingaccount.SetNextAccountNumber();
                db.BankAccounts.Add(chequingaccount);
                chequingaccount.ChangeState();
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", chequingaccount.AccountStateId);
            ViewBag.ClientId       = new SelectList(db.Clients, "ClientId", "FullName", chequingaccount.ClientId);
            return(View(chequingaccount));
        }
Ejemplo n.º 4
0
        public ActionResult Edit(ChequingAccount chequingaccount)
        {
            if (ModelState.IsValid)
            {
                db.Entry(chequingaccount).State = EntityState.Modified;

                db.SaveChanges();

                //If the conditions for this account's state is not fullfilled,change the state for the account.
                chequingaccount.ChangeState();
                //Save the changes right after the change.
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.ClientId       = new SelectList(db.Clients, "ClientId", "FullName", chequingaccount.ClientId);
            ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", chequingaccount.AccountStateId);
            return(View(chequingaccount));
        }
Ejemplo n.º 5
0
        public ActionResult Create(ChequingAccount chequingaccount)
        {
            //Added this line of code to set the next account number
            chequingaccount.SetNextAccountNumber();

            if (ModelState.IsValid)
            {
                db.BankAccounts.Add(chequingaccount);
                db.SaveChanges();
                chequingaccount.ChangeState();
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            //Modified the following parameters to include FullName and NOT FirstName
            ViewBag.ClientId       = new SelectList(db.Clients, "ClientId", "FullName", chequingaccount.ClientId);
            ViewBag.AccountStateId = new SelectList(db.AccountStates, "AccountStateId", "Description", chequingaccount.AccountStateId);
            return(View(chequingaccount));
        }