Ejemplo n.º 1
0
 public void AddEmployee(Employee emp)
 {
     using (Model.ObligatorioEntities en = new Model.ObligatorioEntities())
     {
         Model.Employee nuevo = null;
         if (emp.GetType() == typeof(FullTimeEmployee))
         {
             FullTimeEmployee fullTime = (FullTimeEmployee)emp;
             nuevo = new Model.FullTimeEmployee()
             {
                 EMP_ID     = fullTime.Id,
                 NAME       = fullTime.Name,
                 SALARY     = fullTime.Salary,
                 START_DATE = fullTime.StartDate,
                 TYPE_EMP   = 1
             };
         }
         else
         {
             PartTimeEmployee fullTime = (PartTimeEmployee)emp;
             nuevo = new Model.PartTimeEmployee()
             {
                 EMP_ID     = fullTime.Id,
                 NAME       = fullTime.Name,
                 RATE       = fullTime.HourlyRate,
                 START_DATE = fullTime.StartDate,
                 TYPE_EMP   = 1
             };
         }
         en.Employee.Add(nuevo);
         en.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 public void UpdateEmployee(Employee emp)
 {
     using (Model.ObligatorioEntities en = new Model.ObligatorioEntities())
     {
         Model.Employee remove = en.Employee.Find(emp.Id);
         if (remove != null)
         {
             en.Employee.Remove(remove);
             en.SaveChanges();
             AddEmployee(emp);
         }
     }
 }