public IHttpActionResult PutDeparatments(long id, Deparatments deparatments) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != deparatments.DepartmentID) { return(BadRequest()); } db.Entry(deparatments).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DeparatmentsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutEmployees(long id, Employees employees) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employees.EmployeeID) { return(BadRequest()); } db.Entry(employees).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmployeesExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "Id,Name")] Country country) { if (ModelState.IsValid) { db.Entry(country).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(country)); }
public ActionResult Edit([Bind(Include = "Id,Name,CountryId")] State state) { if (ModelState.IsValid) { db.Entry(state).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CountryId = new SelectList(db.Countries, "Id", "Name", state.CountryId); return(View(state)); }
public ActionResult Edit([Bind(Include = "Id,Name,StateId")] City city) { if (ModelState.IsValid) { db.Entry(city).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StateId = new SelectList(db.States, "Id", "Name", city.StateId); return(View(city)); }
public ActionResult EditEmp(Employee employee) { if (Session["EmpName"] != null) { try { using (EmpDbContext empDb = new EmpDbContext()) { var data = (from a in empDb.Employees where a.EmployeeId == employee.EmployeeId select a).FirstOrDefault(); data.Company = employee.Company; data.CountryId = employee.CountryId; data.StateId = employee.StateId; data.Description = employee.Description; data.IsEmployeeRetired = employee.IsEmployeeRetired; data.Name = employee.Name; data.EmpDate = employee.EmpDate; data.IsActive = employee.IsActive; empDb.Entry(data).State = EntityState.Modified; empDb.SaveChanges(); } return(RedirectToAction("Contact")); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "EmployeeInfo", "Create"))); } // return RedirectToAction("EditEmp"); } else { return(RedirectToAction("Index")); } }