コード例 #1
0
        public string Execute(string[] args)
        {
            int age = int.Parse(args[0]);

            var employees = employeeController.OlderThanAge(age);

            if (employees == null)
            {
                throw new ArgumentException($"No employees older than {age} years.");
            }

            var result = new StringBuilder();

            foreach (var emp in employees.OrderByDescending(e => e.Salary))
            {
                result.Append($"{emp.FirstName} {emp.LastName} - ${emp.Salary:F2} - Manager: ");

                if (emp.Manager == null)
                {
                    result.Append("[no manager]");
                }
                else
                {
                    result.Append(emp.Manager.LastName);
                }
                result.AppendLine();
            }

            return(result.ToString().TrimEnd());
        }