public Entities.Employee DeleteEmployee(Int32 employeeID) { try { using (CPDSEntities context = new CPDSEntities()) { if (context.Employee.Any(e => e.EmployeeID == employeeID) == true) { Employee modEmp = context.Employee.Where(e => e.EmployeeID == employeeID).First(); context.Employee.Remove(modEmp); context.SaveChanges(); } return(new Entities.Employee()); } } catch (Exception ex) { throw; } }
public Entities.Employee InsertEmployee(Entities.Employee emp) { try { using (CPDSEntities context = new CPDSEntities()) { Employee newEmp = ConvertFromEntitiesEmployee(emp); context.Employee.Add(newEmp); context.SaveChanges(); emp.EmployeeNumber = newEmp.EmployeeID; } return(emp); } catch (Exception ex) { throw; } }
public Entities.Employee UpdateEmployee(Entities.Employee emp) { try { using (CPDSEntities context = new CPDSEntities()) { if (context.Employee.Any(e => e.EmployeeID == emp.EmployeeNumber) == true) { Employee modEmp = context.Employee.Where(e => e.EmployeeID == emp.EmployeeNumber).First(); this.ConvertFromEntitiesEmployee(emp, ref modEmp); context.SaveChanges(); return(emp); } return(new Entities.Employee()); } } catch (Exception ex) { throw; } }