예제 #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);
        }
예제 #2
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);
        }