private void AllJobs()
 {
     ShowJobs(DBUserUtils.GetJobPosts());
 }
        private void Search()
        {
            List <JobPost> jobs = new List <JobPost>();
            string         input;
            bool           @break;

            while (true)
            {
                jobs.Clear();
                View.WriteLine("1. Heading");
                View.WriteLine("2. Company name");
                View.WriteLine("3. Category");
                View.WriteLine("4. City");
                View.WriteLine("5. Salary");
                View.WriteLine("6. Age");
                View.WriteLine("7. Study degree");
                View.WriteLine("8. Work experience");
                View.WriteLine("Write e to exit");
                View.WriteLine();
                View.Write("> ");

                input = Console.ReadLine().Trim();

                switch (input)
                {
                case "1":
                    View.Clear();
                    View.WriteLine("Heading");
                    View.WriteLine();
                    View.Write("> ");

                    input = Console.ReadLine();

                    foreach (var job in DBUserUtils.GetJobPosts())
                    {
                        if (job.Heading == input)
                        {
                            jobs.Add(job);
                        }
                    }

                    View.Clear();
                    ShowJobs(jobs);
                    break;

                case "2":
                    View.Clear();
                    View.WriteLine("Company name");
                    View.WriteLine();
                    View.Write("> ");

                    input = Console.ReadLine();

                    foreach (var job in DBUserUtils.GetJobPosts())
                    {
                        if (job.CompanyName == input)
                        {
                            jobs.Add(job);
                        }
                    }

                    View.Clear();
                    ShowJobs(jobs);
                    break;

                case "3":
                    View.Clear();
                    JobCategory category;

                    while (true)
                    {
                        View.WriteLine("Choose one of the job categories");

                        // Getting names of Job Categories and displaying them
                        string[] names = Enum.GetNames(typeof(JobCategory));
                        for (int i = 1; i <= names.Length; i++)
                        {
                            View.WriteLine($"{i}. {names[i - 1]}");
                        }

                        View.WriteLine();
                        View.Write("> ");

                        input = Console.ReadLine();
                        int n = 0;

                        //checking if input is a number
                        try
                        {
                            int.TryParse(input, out n);
                            n--;
                            if (n < 0 || n >= names.Length)
                            {
                                throw new Exception();
                            }
                            category = (JobCategory)n;
                            break;
                        }
                        catch (Exception)
                        {
                            View.WriteErrorAndClear("Invalid option.");
                        }
                    }

                    foreach (var job in DBUserUtils.GetJobPosts())
                    {
                        if (job.Category == category)
                        {
                            jobs.Add(job);
                        }
                    }

                    View.Clear();
                    ShowJobs(jobs);
                    break;

                case "4":
                    View.Clear();
                    View.WriteLine("City");
                    View.WriteLine();
                    View.Write("> ");

                    input = Console.ReadLine();

                    foreach (var job in DBUserUtils.GetJobPosts())
                    {
                        if (job.City == input)
                        {
                            jobs.Add(job);
                        }
                    }

                    View.Clear();
                    ShowJobs(jobs);
                    break;

                case "5":
                    uint salary;

                    while (true)
                    {
                        View.WriteLine("Salary");
                        View.WriteLine();
                        View.Write("> ");

                        input = Console.ReadLine();

                        try
                        {
                            salary = uint.Parse(input);
                            break;
                        }
                        catch (FormatException)
                        {
                            View.WriteErrorAndClear("That is not a number.");
                        }
                        catch (OverflowException)
                        {
                            View.WriteErrorAndClear("That is either too big or less than zero.");
                        }
                        catch (Exception ex)
                        {
                            View.WriteErrorAndClear(ex.Message);
                        }
                    }

                    foreach (var job in DBUserUtils.GetJobPosts())
                    {
                        if (job.Salary == salary)
                        {
                            jobs.Add(job);
                        }
                    }

                    View.Clear();
                    ShowJobs(jobs);
                    break;

                case "6":
                    uint age;

                    while (true)
                    {
                        View.WriteLine("Age");
                        View.WriteLine();
                        View.Write("> ");

                        input = Console.ReadLine();

                        try
                        {
                            age = uint.Parse(input);
                            break;
                        }
                        catch (FormatException)
                        {
                            View.WriteErrorAndClear("That is not a number.");
                        }
                        catch (OverflowException)
                        {
                            View.WriteErrorAndClear("Your age is either too big or less than zero.");
                        }
                        catch (Exception ex)
                        {
                            View.WriteErrorAndClear(ex.Message);
                        }
                    }

                    foreach (var job in DBUserUtils.GetJobPosts())
                    {
                        if (job.Age == age)
                        {
                            jobs.Add(job);
                        }
                    }

                    View.Clear();
                    ShowJobs(jobs);
                    break;

                case "7":
                    StudyDegree?studyDegree = StudyDegree.Graduate;      //random declaration

                    while (true)
                    {
                        @break = true;
                        View.WriteLine("Choose your study degree.");
                        View.WriteLine("1. Undergraduate");
                        View.WriteLine("2. Graduate");
                        View.WriteLine("3. Postgraduate");
                        View.WriteLine();
                        View.Write("> ");

                        input = Console.ReadLine();

                        switch (input)
                        {
                        case "1":
                            studyDegree = StudyDegree.Undergraduate;
                            break;

                        case "2":
                            studyDegree = StudyDegree.Graduate;
                            break;

                        case "3":
                            studyDegree = StudyDegree.Postgraduate;
                            break;

                        default:
                            @break = false;
                            View.WriteErrorAndClear("Invalid option.");
                            break;
                        }

                        if (@break)
                        {
                            break;
                        }
                    }

                    foreach (var job in DBUserUtils.GetJobPosts())
                    {
                        if (job.StudyDegree == studyDegree)
                        {
                            jobs.Add(job);
                        }
                    }

                    View.Clear();
                    ShowJobs(jobs);
                    break;

                case "8":
                    WorkExperience workExperience = WorkExperience.FourToEightYears;     //random declaration

                    while (true)
                    {
                        @break = true;
                        View.WriteLine("Work experience");
                        View.WriteLine();
                        View.WriteLine("1. Less than 1 year");
                        View.WriteLine("2. 1 to 3 years");
                        View.WriteLine("3. 4 to 8 years");
                        View.WriteLine("4. More than 8 years");
                        View.WriteLine();
                        View.Write("> ");

                        input = Console.ReadLine().Trim();

                        switch (input)
                        {
                        case "1":
                            workExperience = WorkExperience.LessThanOneYear;
                            break;

                        case "2":
                            workExperience = WorkExperience.OneToFourYears;
                            break;

                        case "3":
                            workExperience = WorkExperience.FourToEightYears;
                            break;

                        case "4":
                            workExperience = WorkExperience.MoreThanEightYears;
                            break;

                        default:
                            @break = false;
                            View.WriteError("Invalid option.");
                            break;
                        }

                        if (@break)
                        {
                            break;
                        }
                    }

                    foreach (var job in DBUserUtils.GetJobPosts())
                    {
                        if (job.WorkExperience == workExperience)
                        {
                            jobs.Add(job);
                        }
                    }

                    View.Clear();
                    ShowJobs(jobs);
                    break;

                case "e":
                    View.Clear();
                    return;

                default:
                    View.WriteErrorAndClear("Invalid option");
                    break;
                }
            }
        }