예제 #1
0
        public bool UpdateEmployee(Employee employeeToUpdate)
        {
            List <Employee> employeeDataBase = EmployeeDataEntity.EmployeeBase;

            try
            {
                foreach (Employee item in employeeDataBase)
                {
                    if (item.EmployeeId == employeeToUpdate.EmployeeId)
                    {
                        Employee itemTemp = EmployeeOperation.Clone <Employee>(item);
                        if (employeeToUpdate.Birth != new DateTime())
                        {
                            itemTemp.Birth = employeeToUpdate.Birth;
                        }
                        if (employeeToUpdate.Address != null)
                        {
                            itemTemp.Address = employeeToUpdate.Address;
                        }
                        if (employeeToUpdate.Phone != null)
                        {
                            itemTemp.Phone = employeeToUpdate.Phone;
                        }
                        employeeDataBase.Remove(item);
                        employeeDataBase.Add(itemTemp);
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public List <Employee> GetEmployeeSearchResult(Employee conditon)
        {
            List <Employee> employeeDataBase   = EmployeeDataEntity.EmployeeBase;
            List <Employee> searchedResult     = new List <Employee>();
            Employee        searchedItem       = new Employee();
            string          EmployeeIDConditon = conditon.EmployeeId.ToString();

            try
            {
                foreach (Employee employeeItem in employeeDataBase)
                {
                    if (conditon.EmployeeId == 0)
                    {
                        EmployeeIDConditon = String.Empty;
                    }
                    if (conditon.FirstName == null)
                    {
                        conditon.FirstName = String.Empty;
                    }
                    if (conditon.LastName == null)
                    {
                        conditon.LastName = String.Empty;
                    }
                    if (employeeItem.EmployeeId.ToString().Contains(EmployeeIDConditon) &&
                        employeeItem.FirstName.ToUpper().Contains(conditon.FirstName.ToUpper()) &&
                        employeeItem.LastName.ToUpper().Contains(conditon.LastName.ToUpper()))
                    {
                        searchedItem = new Employee();
                        searchedItem = EmployeeOperation.Clone <Employee>(employeeItem);
                        searchedResult.Add(searchedItem);
                    }
                }
                return(searchedResult);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }