private static void AddEmployee()
        {
            String name  = Console.ReadLine(" Name: ", ConsoleColor.Yellow, ConsoleColor.White).Clean();
            String title = Console.ReadLine(" Title: ", ConsoleColor.Yellow, ConsoleColor.White).Clean();

SexPrompt:
            String sex = Console.ReadLine(" Sex: ", ConsoleColor.Yellow, ConsoleColor.White).Clean();

            if (!sexPattern.Consume(sex))
            {
                Console.WriteLine($"ERROR: {sex} is not a valid sex, expected Male or Female", ConsoleColor.Red);
                goto SexPrompt;
            }
BirthdatePrompt:
            String birthdate = Console.ReadLine(" Birthdate: ", ConsoleColor.Yellow, ConsoleColor.White).Clean();

            if (!birthdatePattern.Consume(birthdate))
            {
                Console.WriteLine($"ERROR: {birthdate} is not a valid birthdate, expected an ISO date format", ConsoleColor.Red);
                goto BirthdatePrompt;
            }
            Console.WriteLine(" Creating record...", ConsoleColor.DarkCyan);
            new Employee(name, Enum.Parse <Sex>(sex), DateTime.Parse(birthdate), title).Store();
            Console.WriteLine(" Record created successfully", ConsoleColor.DarkCyan);
        }
Example #2
0
 public static void Main()
 {
     Theme.DefaultDark.Apply();
     while (true)
     {
         Console.WriteChoices(MenuChoices);
         Console.ReadChoice(MenuChoices);
     }
 }
        private static void ListEmployees()
        {
            Employee employee;

            Console.WriteLine(String.Format("|{0,20}|{1,20}|{2,10}|{3,20}|", "Name".Pad(20), "Title".Pad(20), "Sex".Pad(10), "Birthdate".Pad(20)), ConsoleColor.Blue);
            foreach (String fileName in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.record"))
            {
                employee = Employee.Load(Path.GetFileNameWithoutExtension(fileName));
                Console.WriteLine(String.Format("|{0,20}|{1,20}|{2,10}|{3,20}|", employee.Name, employee.Title, employee.Sex, employee.Birthdate.ToShortDateString()));
            }
        }
        private static void RemoveEmployee()
        {
NamePrompt:
            String name = Console.ReadLine(" Name: ", ConsoleColor.Yellow, ConsoleColor.White);

            if (File.Exists($"{name}.record"))
            {
                File.Delete($"{name}.record");
            }
            else
            {
                Console.WriteLine($"ERROR: \"{name}\" wasn't found in the registry", ConsoleColor.Red);
                goto NamePrompt;
            }
        }
        private static void UpdateSex()
        {
SexPrompt:
            String sex = Console.ReadLine(" Sex: ", ConsoleColor.Yellow, ConsoleColor.White);

            if (sexPattern.Consume(sex))
            {
                employee.Sex = Enum.Parse <Sex>(sex);
            }
            else
            {
                Console.WriteLine($"ERROR: {sex} is not a valid sex, expected Male or Female", ConsoleColor.Red);
                goto SexPrompt;
            }
        }
        private static void UpdateBirthdate()
        {
BirthdatePrompt:
            String birthdate = Console.ReadLine(" Birthdate: ", ConsoleColor.Yellow, ConsoleColor.White);

            if (birthdatePattern.Consume(birthdate))
            {
                employee.Birthdate = DateTime.Parse(birthdate);
            }
            else
            {
                Console.WriteLine($"ERROR: {birthdate} is not a valid birthdate, expected an ISO date format", ConsoleColor.Red);
                goto BirthdatePrompt;
            }
        }
        private static void UpdateEmployee()
        {
NamePrompt:
            String name = Console.ReadLine(" Name: ", ConsoleColor.Yellow, ConsoleColor.White);

            if (File.Exists($"{name}.record"))
            {
                employee = Employee.Load(name);
            }
            else
            {
                Console.WriteLine($"ERROR: \"{name}\" wasn't found in the registry", ConsoleColor.Red);
                goto NamePrompt;
            }
            updateLoop = true;
            while (updateLoop)
            {
                Console.WriteChoices(UpdateMenu);
                Console.ReadChoice(UpdateMenu);
            }
        }
Example #8
0
        public static void Main()
        {
            Theme.DefaultDark.Apply();
            MenuChoices = new KeyChoiceSet(" Enter Choice: ",
                                           new KeyChoice(ConsoleKey.D1, "Extensions", () => {
                Console.WriteChoices(ExtensionsChoices);
                Console.ReadChoice(ExtensionsChoices);
            }),
                                           new KeyChoice(ConsoleKey.D2, "Patterns", () => {
                Console.WriteChoices(PatternsChoices);
                Console.ReadChoice(PatternsChoices);
            }),
                                           new BackKeyChoice(ConsoleKey.Q, "Quit", () => Environment.Exit(0)));
            ExtensionsChoices = new KeyChoiceSet(" Enter Choice: ",
                                                 new KeyChoice(ConsoleKey.D1, "Chop", () => BenchmarkRunner.Run <ChopBenchmarks>()),
                                                 new KeyChoice(ConsoleKey.D2, "Clean", () => BenchmarkRunner.Run <CleanBenchmarks>()),
                                                 new KeyChoice(ConsoleKey.D3, "Contains", () => {
                _ = BenchmarkRunner.Run <ContainsCharStringBenchmarks>();
                _ = BenchmarkRunner.Run <ContainsCharIEnumerableBenchmarks>();
                _ = BenchmarkRunner.Run <ContainsStringIEnumerableBenchmarks>();
            }),
                                                 new KeyChoice(ConsoleKey.D4, "Ensure", () => BenchmarkRunner.Run <EnsureBenchmarks>()),
                                                 new KeyChoice(ConsoleKey.D5, "Join", () => BenchmarkRunner.Run <JoinBenchmarks>()),
                                                 new KeyChoice(ConsoleKey.D6, "Lines", () => BenchmarkRunner.Run <LinesBenchmarks>()),
                                                 new KeyChoice(ConsoleKey.D7, "Occurrences", () => BenchmarkRunner.Run <OccurrencesBenchmarks>()),
                                                 new KeyChoice(ConsoleKey.D8, "Pad", () => BenchmarkRunner.Run <PadBenchmarks>()),
                                                 new KeyChoice(ConsoleKey.D9, "Repeat", () => BenchmarkRunner.Run <RepeatBenchmarks>()),
                                                 new KeyChoice(ConsoleKey.A, "Split", () => BenchmarkRunner.Run <SplitBenchmarks>()),
                                                 new BackKeyChoice(ConsoleKey.B, "Back", () => { }));
            PatternsChoices = new KeyChoiceSet(" Enter Choice: ",
                                               new KeyChoice(ConsoleKey.D1, "Literal", () => BenchmarkRunner.Run <LiteralBenchmarks>()));

            while (true)
            {
                Console.WriteChoices(MenuChoices);
                Console.ReadChoice(MenuChoices);
            }
        }
        private static void UpdateTitle()
        {
            String title = Console.ReadLine(" Title: ", ConsoleColor.Yellow, ConsoleColor.White);

            employee.Title = title;
        }