示例#1
0
        public static void AddEmployee()
        {
            Employee employeeNew = new Employee();

            Console.WriteLine("Enter employee Id");
            employeeNew.EmployeeId = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter employee name");
            employeeNew.EmployeeName = Console.ReadLine();
            Console.WriteLine("Enter designation Id");
            employeeNew.DesignationId = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter department Id");
            employeeNew.DepartmentId = Convert.ToInt32(Console.ReadLine());

            try
            {
                bool success = EmployeeBL.AddEmployeeBL(employeeNew);
                if (success)
                {
                    Console.WriteLine("Employee successfully added");
                }
                else
                {
                    Console.WriteLine("Employee addition unsuccessful");
                }
            }
            catch (EmployeeAppException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#2
0
 private static void AddEmployee()
 {
     try
     {
         Employee newEmployee = new Employee();
         Console.WriteLine("Enter EmployeeID :");
         newEmployee.EmployeeID = Convert.ToInt32(Console.ReadLine());
         Console.WriteLine("Enter Employee Name :");
         newEmployee.EmployeeName = Console.ReadLine();
         Console.WriteLine("Enter PhoneNumber :");
         newEmployee.EmployeeContactNumber = Console.ReadLine();
         bool employeeAdded = EmployeeBL.AddEmployeeBL(newEmployee);
         if (employeeAdded)
         {
             Console.WriteLine("Employee Added");
         }
         else
         {
             Console.WriteLine("Employee not Added");
         }
     }
     catch (EmployeePhoneBookException ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
        /// <summary>
        /// Adds Employee.
        /// </summary>
        /// <returns></returns>
        public static async Task AddEmployee()
        {
            try
            {
                //Read inputs
                Employee employee = new Employee();
                Write("Name: ");
                employee.EmployeeName = ReadLine();
                Write("Email: ");
                employee.Email = ReadLine();
                Write("Password: "******"Mobile: ");
                employee.Mobile = ReadLine();

                //Invoke AddEmployeeBL method to add
                using (IEmployeeBL employeeBL = new EmployeeBL())
                {
                    bool isAdded = await employeeBL.AddEmployeeBL(employee);

                    if (isAdded)
                    {
                        WriteLine("Employee Added");
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex);
                WriteLine(ex.Message);
            }
        }