public string AddEmployee(EmployeeDetail employee) { using (var repo = new EmployeeInterviewEntities()) { repo.EmployeeDetails.Add(employee); repo.SaveChanges(); } return("Employee Added successfully."); }
public string DeleteEmployee(int id) { using (var repo = new EmployeeInterviewEntities()) { var data = repo.EmployeeDetails.FirstOrDefault(a => a.Id == id); if (data != null) { repo.EmployeeDetails.Remove(data) ; repo.SaveChanges(); } } return("Employee removed successfully."); }
public string UpdateEmployee(EmployeeDetail employee) { using (var repo = new EmployeeInterviewEntities()) { var data = repo.EmployeeDetails.SingleOrDefault(a => a.Id == employee.Id); if (data != null) { data.FirstName = employee.FirstName; data.LastName = employee.LastName; data.PhoneNumber = employee.PhoneNumber; data.EmailAddress = employee.EmailAddress; data.Address = employee.Address; repo.SaveChanges(); } } return("Employee Updated successfully."); }