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 Create([Bind(Include = "CarrierID,MCNumber,DOTNumber,Address1,Address2,City,StateID,Zip,Email,WebURL,Active,DateCreated,LastModified")] Carrier carrier) { if (ModelState.IsValid) { db.Carriers.Add(carrier); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StateID = new SelectList(db.States, "StateID", "StateName", carrier.StateID); return(View(carrier)); }
public ActionResult Delete(int id, FormCollection formCollection) { using (PracticeDBEntities db = new PracticeDBEntities()) { Employee employee = db.Employees.Where(x => x.Eno == id).FirstOrDefault(); db.Employees.Remove(employee); db.SaveChanges(); } return(RedirectToAction("Index")); }
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")); }
public ActionResult Create(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.Employees.Add(employee); db.SaveChanges(); } return(RedirectToAction("Index")); }
public int Save() { return(_db.SaveChanges()); }