Пример #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;
 }
Пример #2
0
        public void Delete(EmployeeDataTransfer employee)
        {
            var entity = Context.Employees.Find(employee.Id);

            if (entity != null)
            {
                Context.Employees.Remove(entity);
                Context.SaveChanges();
            }
        }
Пример #3
0
        public void Update(EmployeeDataTransfer employee)
        {
            var entity = Context.Employees.Find(employee.Id);

            if (entity != null)
            {
                entity.DeepCopy(employee);
                Context.SaveChanges();
            }
        }
Пример #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
     });
 }
Пример #5
0
 public void Add(EmployeeDataTransfer employee)
 {
     Context.Employees.Add(employee.ToEntity());
     Context.SaveChanges();
 }