Ejemplo n.º 1
0
        public int AddEmployee(Employee employee)
        {
            DA.Employee emp = iMapper.Map <DA.Employee>(employee);
            using (DA.PractiseSessionEntities dbEntities = new DA.PractiseSessionEntities())
            {
                dbEntities.Employees.Add(emp);
                dbEntities.SaveChanges();
            }

            return(emp.EmployeeId);
        }
Ejemplo n.º 2
0
        public int DeleteEmployee(int id)
        {
            using (DA.PractiseSessionEntities dbEntities = new DA.PractiseSessionEntities())
            {
                var emp = dbEntities.Employees.FirstOrDefault(x => x.EmployeeId == id);
                if (emp != null)
                {
                    dbEntities.Employees.Remove(emp);
                    dbEntities.SaveChanges();
                }
                else
                {
                    return(1);
                }
            }

            return(0);
        }
Ejemplo n.º 3
0
        public int UpdateEmployee(int id, Employee employee)
        {
            using (DA.PractiseSessionEntities dbEntities = new DA.PractiseSessionEntities())
            {
                DA.Employee emp = dbEntities.Employees.FirstOrDefault(x => x.EmployeeId == id);

                if (emp != null)
                {
                    emp.FirstName = employee.FirstName;
                    emp.LastName  = employee.LastName;
                    emp.Salary    = employee.Salary;
                    emp.Gender    = emp.Gender;
                    dbEntities.SaveChanges();
                }
                else
                {
                    return(1);
                }
            }

            return(0);
        }