Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            GoldState goldstate = (GoldState)db.AccountStates.Find(id);

            db.AccountStates.Remove(goldstate);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        //
        // GET: /GoldState/Delete/5

        public ActionResult Delete(int id = 0)
        {
            GoldState goldstate = (GoldState)db.AccountStates.Find(id);

            if (goldstate == null)
            {
                return(HttpNotFound());
            }
            return(View(goldstate));
        }
Esempio n. 3
0
 public ActionResult Edit(GoldState goldstate)
 {
     if (ModelState.IsValid)
     {
         db.Entry(goldstate).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(goldstate));
 }
        //
        // GET: /GoldState/Edit/5

        public ActionResult Edit(int id = 0)
        {
            GoldState goldstate = db.GoldStates.Find(id);

            if (goldstate == null)
            {
                return(HttpNotFound());
            }
            return(View(goldstate));
        }
Esempio n. 5
0
        public ActionResult Create(GoldState goldstate)
        {
            if (ModelState.IsValid)
            {
                db.AccountStates.Add(goldstate);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(goldstate));
        }
Esempio n. 6
0
        //
        // GET: /GoldState/Edit/5

        public ActionResult Edit(int id = 0)
        {
            //Casted AccountState to a GoldState
            GoldState goldstate = (GoldState)db.AccountStates.Find(id);

            if (goldstate == null)
            {
                return(HttpNotFound());
            }
            return(View(goldstate));
        }
Esempio n. 7
0
 private void EvaluateState()
 {
     if (Balance <= 5000)
     {
         State = new SilverState();
     }
     if (Balance > 5000 && Balance < 10000)
     {
         State = new GoldState();
     }
     if (Balance >= 10000)
     {
         State = new PlatinumState();
     }
 }
Esempio n. 8
0
        //Organizing Data - Replace Type Code with State/Strategy
        public static State CreateAccount(int firstDeposit, Account account)
        {
            State created;

            if (firstDeposit > 10000)
            {
                created = new GoldState(firstDeposit, account);
            }
            else if (firstDeposit > 5000)
            {
                created = new SilverState(firstDeposit, account);
            }
            else
            {
                created = new BronzeState(firstDeposit, account);
            }

            return(created);
        }
Esempio n. 9
0
        //
        // GET: /GoldState/

        public ActionResult Index()
        {
            return(View(GoldState.GetInstance()));
        }
        //
        // GET: /GoldState/

        public ActionResult Index()
        {
            //Returns the goldstate account state instance
            return(View(GoldState.GetInstance()));
        }