// PUT odata/Racer(5)
        public async Task <IHttpActionResult> Put([FromODataUri] int key, Racer racer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (key != racer.Id)
            {
                return(BadRequest());
            }

            db.Entry(racer).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RacerExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(racer));
        }
Ejemplo n.º 2
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"));
        }