public bool DeleteEmployee(Employee emp) { using (companyEntities db = new companyEntities()) { Employee existingEmployee = db.Employees.Where(temp => temp.EmpID == emp.EmpID).FirstOrDefault(); if (existingEmployee == null) { return(false); } else { db.Employees.Remove(existingEmployee); db.SaveChanges(); return(true); } } }
public bool UpdateEmployee(Employee emp) { using (companyEntities db = new companyEntities()) { Employee existingEmployee = db.Employees.Where(temp => temp.EmpID == emp.EmpID).FirstOrDefault(); if (existingEmployee == null) { return(false); } else { existingEmployee.EmpName = emp.EmpName; existingEmployee.Salary = emp.Salary; db.SaveChanges(); return(true); } } }