public IHttpActionResult PutCustomer(int id, Customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customer.CustomerId) { return(BadRequest()); } db.Entry(customer).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "CarrierID,MCNumber,DOTNumber,Address1,Address2,City,StateID,Zip,Email,WebURL,Active,DateCreated,LastModified")] Carrier carrier) { if (ModelState.IsValid) { db.Entry(carrier).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StateID = new SelectList(db.States, "StateID", "StateName", carrier.StateID); return(View(carrier)); }
public ActionResult Edit(int id, TestEmployee model) { using (PracticeDBEntities db = new PracticeDBEntities()) { Employee employee = new Employee(); employee.Eno = model.Eno; employee.Ename = model.Ename; employee.Job = model.Job; employee.Salary = model.Salary; employee.Dname = model.Dname; db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Index")); }