public Employee GetEmployee(int id)
 {
     using (Model.Obligatorio1Entities en = new Model.Obligatorio1Entities())
     {
         return(cast(en.EmployeesTPH.Find(id)));
     }
 }
 public void DeleteEmployee(int id)
 {
     using (Model.Obligatorio1Entities en = new Model.Obligatorio1Entities())
     {
         en.EmployeesTPH.Remove(
             en.EmployeesTPH.Find(id)
             );
         en.SaveChanges();
     }
 }
 public void AddEmployee(Employee emp)
 {
     if (emp == null)
     {
         return;
     }
     using (Model.Obligatorio1Entities en = new Model.Obligatorio1Entities())
     {
         en.EmployeesTPH.Add(cast(emp));
         en.SaveChanges();
     }
 }
 public List <Employee> GetAllEmployees()
 {
     using (Model.Obligatorio1Entities en = new Model.Obligatorio1Entities())
     {
         List <Employee> listaEmpleados = new List <Employee>();
         en.EmployeesTPH.ToList().ForEach(x =>
         {
             listaEmpleados.Add(cast(x));
         });
         return(listaEmpleados);
     }
 }
 public void UpdateEmployee(Employee emp)
 {
     if (emp == null)
     {
         return;
     }
     using (Model.Obligatorio1Entities en = new Model.Obligatorio1Entities())
     {
         Model.EmployeesTPH em = en.EmployeesTPH.Find(emp.Id);
         em.name      = emp.Name;
         em.StartDate = emp.StartDate;
         if (emp.GetType().Name == "FullTimeEmployee")
         {
             Model.FullTimeEmployees emCast = (Model.FullTimeEmployees)em;
             emCast.Salary = ((FullTimeEmployee)emp).Salary;
         }
         else
         {
             Model.PartTimeEmployees emCast = (Model.PartTimeEmployees)em;
             emCast.HourlyRate = ((PartTimeEmployee)emp).HourlyRate;
         }
         en.SaveChanges();
     }
 }