Ejemplo n.º 1
0
 public void DeleteEmployee(int id)
 {
     using (var db = new WebApiTestEntities())
     {
         Employee deleteEmployee = db.Employees.Where(x => x.EmployeeId == id).FirstOrDefault();
         db.Employees.Remove(deleteEmployee);
         db.SaveChanges();
     }
 }
Ejemplo n.º 2
0
        public void UpdateEmployee(Employee employee)
        {
            using (var db = new WebApiTestEntities())
            {
                Employee updateEmploye = db.Employees.Where(x => x.EmployeeId == employee.EmployeeId).FirstOrDefault();
                updateEmploye.Name   = employee.Name;
                updateEmploye.Code   = employee.Code;
                updateEmploye.Salary = employee.Salary;

                db.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public void AddEmployee(Employee employee)
        {
            using (var db = new WebApiTestEntities())
            {
                Employee NewEmployee = new Employee();
                NewEmployee.Name   = employee.Name;
                NewEmployee.Code   = employee.Code;
                NewEmployee.Salary = employee.Salary;

                db.SaveChanges();
            }
        }
Ejemplo n.º 4
0
        public IEnumerable <Employee> GetEmployeeList()
        {
            using (var db = new WebApiTestEntities())
            {
                var query = (from emp in db.Employees
                             select new Employee
                {
                    Name = emp.Name,
                    Code = emp.Code,
                    Salary = emp.Salary
                });

                return(query.ToList());
            }
        }
Ejemplo n.º 5
0
        public IEnumerable <Employee> GetEmployeeById(int id)
        {
            using (var db = new WebApiTestEntities())
            {
                var query = (from emp in db.Employees.Where(x => x.EmployeeId == id)
                             select new Employee
                {
                    Name = emp.Name,
                    Code = emp.Code,
                    Salary = emp.Salary
                }).ToList();

                return(query);
            }
        }