Example #1
0
        public static void Question1()
        {
            IEmployeeCommands employeeCommand = new EmployeeCommands(new EmployeeCommandsRepository());
            var firstEmployee = new Employee(1, "test", "test");

            employeeCommand.AddEmployee(firstEmployee);
            Console.WriteLine(
                $"Adding first employee :{firstEmployee.EmployeeId}, Name:{firstEmployee.FirstName}, Address:{firstEmployee.LastName}");
            var secondEmployee = new Employee(2, "test1", "test1");

            employeeCommand.AddEmployee(secondEmployee);

            Console.WriteLine(
                $"Adding second employee :{secondEmployee.EmployeeId}, Name:{secondEmployee.FirstName}, Address:{secondEmployee.LastName}");
            var thirdEmployee = new Employee(3, "test2", "test2");

            employeeCommand.AddEmployee(thirdEmployee);

            Console.WriteLine(
                $"Adding third employee :{thirdEmployee.EmployeeId}, Name:{thirdEmployee.FirstName}, Address:{thirdEmployee.LastName}");


            IEmployeeQueries employeeQuery = new EmployeeQueries(new EmployeeQueryRepository());
            var result = employeeQuery.GetEmployee(1);


            Console.WriteLine($"Get Employee ID =1 :{result.EmployeeId}, Name:{result.FirstName}, Address:{result.LastName}");


            var orderList = employeeQuery.GetOrderedEmployeeArray();

            for (int employeeCount = 1; employeeCount >= orderList.Count; employeeCount++)
            {
                Console.WriteLine(
                    $" Employee Ordered Array  :{orderList[employeeCount].EmployeeId}, Name:{orderList[employeeCount].FirstName}, Address:{orderList[employeeCount].LastName}");
            }
        }
Example #2
0
        static void Main()
        {
            using (var context = new EmployeesDbContext())
            {
                var input = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);

                while (true)
                {
                    var confMapper = new MapperConfiguration(conf => conf.AddProfile <EmployeeProfile>());
                    var mapper     = new Mapper(confMapper);

                    EmployeeCommands empCommands     = new EmployeeCommands(context, mapper);
                    ManagerCommands  managerCommands = new ManagerCommands(context, mapper);

                    var args = input.Skip(1).ToArray();
                    switch (input[0])
                    {
                    case "AddEmployee":
                        Console.WriteLine(empCommands.AddEmployee(args));
                        break;

                    case "SetBirthday":
                        empCommands.SetBirthday(args);
                        break;

                    case "SetAddress":
                        empCommands.SetAddress(args);
                        break;

                    case "EmployeeInfo":
                        var id = int.Parse(args[0]);
                        Console.WriteLine(empCommands.EmployeeInfo(id));
                        break;

                    case "EmployeePersonalInfo":
                        var Employeeid = int.Parse(args[0]);
                        Console.WriteLine(empCommands.EmployeePersonalInfo(Employeeid));
                        break;

                    case "SetManager":
                        Console.WriteLine(managerCommands.SetManager(args));
                        break;

                    case "ManagerInfo":
                        Console.WriteLine(managerCommands.ManagerInfo(args));
                        break;

                    case "ListEmployeesOlderThan":
                        Console.WriteLine(empCommands.ListEmployeesOlderThan(int.Parse(args[0])));
                        break;
                    }

                    if (input[0] == "Exit")
                    {
                        break;
                    }

                    input = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
                }
            }
        }