Beispiel #1
0
        public ActionResult SaveWheelChanges(Wheel UpdatedWheel)
        {
            //0. validation
            if (!ModelState.IsValid)
            {
                //over errors for each field in mobdel
                foreach (ModelState S in ModelState.Values)
                {
                    //individual errors for each fields
                }

                //Request.UserHostAddress
                return(View("../Shared/Error")); //error page
            }

            //1. orm
            Formula1Entities FOrm = new Formula1Entities();

            //find
            FOrm.Entry(FOrm.Wheels.Find(UpdatedWheel.WheelID)).CurrentValues.SetValues(UpdatedWheel);

            //save
            FOrm.SaveChanges();

            //go to customer view (refresh customer data)
            return(RedirectToAction("WheelInventory"));
        }
Beispiel #2
0
        public ActionResult AddNewWheel(Wheel newWheel, int WheelID, float Price)
        {
            Formula1Entities FOrm = new Formula1Entities();

            FOrm.Wheels.Add(newWheel);
            FOrm.SaveChanges();

            ViewBag.WheelID = WheelID;
            ViewBag.WCost   = Price;

            return(View("WheelReview"));
        }
Beispiel #3
0
        //[HttpPost]
        public ActionResult AddNewEngine(Engine newEngine, int EngineID, float Price)
        {
            Formula1Entities FOrm = new Formula1Entities();

            FOrm.Engines.Add(newEngine);
            FOrm.SaveChanges();

            ViewBag.EngineID = EngineID;
            ViewBag.ECost    = Price;

            return(View("EngineReview"));
        }
Beispiel #4
0
        public ActionResult DeleteWheelById(int WheelID)
        {
            //1. orm
            Formula1Entities FOrm = new Formula1Entities();

            //2. find what you're looking for THEN remove from list
            //if record has dependencis then delete that first!
            FOrm.Wheels.Remove((FOrm.Wheels.Find(WheelID)));

            //save changes
            FOrm.SaveChanges();

            //show new refreshed database
            return(RedirectToAction("WheelInventory"));
        }