Exemplo n.º 1
0
 public static void Add(Employee employee)
 {
     using (var context = new SoftUniEntities())
     {
         context.Employees.Add(employee);
         context.SaveChanges();
     }     
 }
Exemplo n.º 2
0
 public static void Delete(Employee employee)
 {
     using (var context = new SoftUniEntities())
     {
         Employee empl = context.Employees.Find(employee.EmployeeID);
         context.Employees.Remove(empl);
         context.SaveChanges();
     }
 }
Exemplo n.º 3
0
        public static void Modify(Employee employee)
        {
            using (var context = new SoftUniEntities())
            {
                Employee empl = context.Employees.SingleOrDefault(e => e.EmployeeID == employee.EmployeeID);

                if (empl != null)
                {
                    empl.FirstName = employee.FirstName;
                    empl.LastName = employee.LastName;
                    empl.MiddleName = employee.MiddleName;
                    empl.AddressID = employee.AddressID;
                    empl.ManagerID = employee.ManagerID;
                    empl.DepartmentID = employee.DepartmentID;
                    empl.JobTitle = employee.JobTitle;
                    empl.Salary = employee.Salary;
                    empl.HireDate = employee.HireDate;
                }

                context.SaveChanges();
            }
        }