public ActionResult Edit([Bind(Include = "empid,empname,email,phoneno")] employee employee) { if (ModelState.IsValid) { db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employee)); }
public bool DeleteEmployee(int id) { using (var context = new empdbEntities()) { var emp = new Employee() { Id = id }; context.Entry(emp).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); return(false); } }
public bool UpdateEmployee(int id, EmployeeModels models) { using (var context = new empdbEntities()) { var employee = new Employee(); if (employee != null) { employee.FirstName = models.FirstName; employee.LastName = models.LastName; employee.Email = models.Email; employee.Code = models.Code; employee.Addressid = models.Addressid; } context.Entry(employee).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(true); } }