Ejemplo n.º 1
0
 public static void DeepCopy(this Employee me, EmployeeDataTransfer employee)
 {
     me.Name       = employee.Name;
     me.Department = employee.Department;
     me.HireDate   = employee.HireDate;
     me.Title      = employee.Title;
 }
Ejemplo n.º 2
0
        public void Delete(EmployeeDataTransfer employee)
        {
            var entity = Context.Employees.Find(employee.Id);

            if (entity != null)
            {
                Context.Employees.Remove(entity);
                Context.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public void Update(EmployeeDataTransfer employee)
        {
            var entity = Context.Employees.Find(employee.Id);

            if (entity != null)
            {
                entity.DeepCopy(employee);
                Context.SaveChanges();
            }
        }
Ejemplo n.º 4
0
 public static Employee ToEntity(this EmployeeDataTransfer employee)
 {
     return(new Employee {
         Id = employee.Id,
         Name = employee.Name,
         Department = employee.Department,
         HireDate = employee.HireDate,
         Title = employee.Title
     });
 }
Ejemplo n.º 5
0
 public void Add(EmployeeDataTransfer employee)
 {
     Context.Employees.Add(employee.ToEntity());
     Context.SaveChanges();
 }