Ejemplo n.º 1
0
        public static void Start(Worker worker, Database.Database db)
        {
            var logger = new Logger.ConsoleLogger();

            var seeAdsLoop = true;

            var             mainVacancies = db.GetVacancies();
            IList <Vacancy> vacancies     = mainVacancies;

            while (seeAdsLoop)
            {
                Console.Clear();

                ExceptionHandle.Handle(VacancyHelper.SeeAds, vacancies);

                ConsoleScreen.PrintMenu(ConsoleScreen.FilterMenu, ConsoleColor.Blue);

                var filterMenuChoice = (FilterMenuEnum)ConsoleScreen.Input(ConsoleScreen.FilterMenu.Count);

                switch (filterMenuChoice)
                {
                case FilterMenuEnum.Select:
                {
                    var loop2 = true;
                    while (loop2)
                    {
                        Console.Clear();
                        if (!ExceptionHandle.Handle(VacancyHelper.SeeAds, vacancies))
                        {
                            break;
                        }
                        Console.WriteLine("Vacancy id: ");
                        var vacId = UserHelper.InputGuid();

                        try
                        {
                            var vacancy = VacancyHelper.GetVacancy(vacId, vacancies);

                            while (true)
                            {
                                var requestFromWorker = vacancy.CheckWorkerRequest(worker.Guid);
                                Console.Clear();
                                Console.WriteLine(vacancy++);     // increase vacancy view count and print
                                Database.Database.Changes = true;

                                Console.WriteLine();
                                Console.WriteLine($"1. {(requestFromWorker ? "Cancel" : "Request")}");;
                                Console.WriteLine("2. Back");
                                var choice = ConsoleScreen.Input(2);

                                if (choice == 1)
                                {
                                    if (requestFromWorker)
                                    {
                                        vacancy.RemoveRequest(worker.Guid);
                                    }
                                    else
                                    {
                                        Cv cv = null;
                                        while (true)
                                        {
                                            Console.Clear();
                                            if (!ExceptionHandle.Handle(worker.ShowAllCv, true))
                                            {
                                                LoggerPublisher.OnLogInfo("Please add public Cv!");
                                                ConsoleScreen.Clear();
                                                break;
                                            }

                                            var cvId = UserHelper.InputGuid();

                                            try
                                            {
                                                cv = CvHelper.GetCv(cvId, worker.Cvs);
                                                break;
                                            }
                                            catch (Exception e)
                                            {
                                                LoggerPublisher.OnLogError(e.Message);
                                                ConsoleScreen.Clear();
                                            }
                                        }

                                        if (cv != null)
                                        {
                                            vacancy.SendRequest(worker.Guid, cv.Guid);
                                        }
                                    }
                                }
                                else if (choice == 2)
                                {
                                    if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to see other Ads?",
                                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                                    {
                                        loop2 = false;
                                    }
                                    break;
                                }
                            }

                            if (loop2)
                            {
                                continue;
                            }
                        }
                        catch (Exception e)
                        {
                            LoggerPublisher.OnLogError(e.Message);
                            ConsoleScreen.Clear();
                        }

                        if (!loop2 || ConsoleScreen.DisplayMessageBox("Info", "Do you want to try again?",
                                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                        {
                            break;
                        }
                    }
                    break;
                }

                case FilterMenuEnum.ByCategory:
                {
                    Console.Clear();

                    vacancies = ExceptionHandle.Handle(VacancyFilter.FilterByCategory, UserHelper.InputCategory(),
                                                       vacancies);

                    break;
                }

                case FilterMenuEnum.ByEducation:
                {
                    Console.Clear();

                    vacancies = ExceptionHandle.Handle(VacancyFilter.FilterByEducation, UserHelper.InputEducation(), vacancies);
                    break;
                }

                case FilterMenuEnum.ByExperience:
                {
                    Console.Clear();

                    vacancies = ExceptionHandle.Handle(VacancyFilter.FilterByExperience, UserHelper.InputExperience(), vacancies);
                    break;
                }

                case FilterMenuEnum.ByRegion:
                {
                    Console.Clear();

                    vacancies = ExceptionHandle.Handle(VacancyFilter.FilterByRegion, UserHelper.InputRegion(), vacancies);
                    break;
                }

                case FilterMenuEnum.BySalary:
                {
                    Console.Clear();
                    var input  = UserHelper.InputSalary();
                    var salary = UserHelper.ParseSalary(input);

                    vacancies = ExceptionHandle.Handle(VacancyFilter.FilterBySalary, salary, vacancies);
                    break;
                }

                case FilterMenuEnum.Reset:
                {
                    vacancies = mainVacancies;
                    break;
                }

                case FilterMenuEnum.Back:
                {
                    seeAdsLoop = false;
                    break;
                }
                }
            }
        }
Ejemplo n.º 2
0
        public static void Start(Entities.Employer employer, Database.Database db)
        {
            var logger = new Logger.ConsoleLogger();

            var seeCvsLoop = true;


            var mainCvs = db.GetCvs();

            IList <Cv> cvs = mainCvs;


            while (seeCvsLoop)
            {
                Console.Clear();

                ExceptionHandle.Handle(CvHelper.SeeCvs, cvs);

                ConsoleScreen.PrintMenu(ConsoleScreen.FilterMenu, ConsoleColor.Blue);

                var filterMenuChoice = (FilterMenuEnum)ConsoleScreen.Input(ConsoleScreen.FilterMenu.Count);

                switch (filterMenuChoice)
                {
                case FilterMenuEnum.Select:
                {
                    var loop3 = true;
                    while (loop3)
                    {
                        Console.Clear();
                        if (!ExceptionHandle.Handle(CvHelper.SeeCvs, cvs))
                        {
                            break;
                        }
                        Console.WriteLine("Cv id: ");

                        var cvId = UserHelper.InputGuid();

                        try
                        {
                            var cv = CvHelper.GetCv(cvId, cvs);

                            Console.Clear();

                            while (true)
                            {
                                var requestFromEmployer = cv.CheckEmployerRequest(employer.Guid);

                                Console.Clear();

                                Console.WriteLine(cv++);     // increase view count and print.

                                Database.Database.Changes = true;

                                Console.WriteLine();

                                Console.WriteLine($"1. {(requestFromEmployer ? "Cancel" : "Request")}");

                                Console.WriteLine("2. Back");

                                var choice = ConsoleScreen.Input(2);

                                if (choice == 1)
                                {
                                    if (requestFromEmployer)
                                    {
                                        cv.RemoveRequest(employer.Guid);
                                    }
                                    else
                                    {
                                        Vacancy vacancy = null;

                                        while (true)
                                        {
                                            Console.Clear();
                                            if (!ExceptionHandle.Handle(employer.ShowAllAds, true))
                                            {
                                                LoggerPublisher.OnLogInfo("Please add public Vacancy!");
                                                ConsoleScreen.Clear();
                                                break;
                                            }

                                            var vacancyId = UserHelper.InputGuid();


                                            try
                                            {
                                                vacancy = VacancyHelper.GetVacancy(vacancyId, employer.Vacancies);
                                                break;
                                            }
                                            catch (Exception e)
                                            {
                                                LoggerPublisher.OnLogError(e.Message);
                                                ConsoleScreen.Clear();
                                            }
                                        }

                                        if (vacancy != null)
                                        {
                                            cv.SendRequest(employer.Guid, vacancy.Guid);
                                        }
                                    }
                                }
                                else if (choice == 2)
                                {
                                    if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to see other Cvs?",
                                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                                    {
                                        loop3 = false;
                                    }
                                    break;
                                }
                            }

                            if (loop3)
                            {
                                continue;
                            }
                        }
                        catch (Exception e)
                        {
                            LoggerPublisher.OnLogError(e.Message);
                        }
                    }
                    break;
                }

                case FilterMenuEnum.ByCategory:
                {
                    Console.Clear();

                    cvs = ExceptionHandle.Handle(CvFilter.FilterByCategory, UserHelper.InputCategory(), cvs);
                    break;
                }

                case FilterMenuEnum.ByEducation:
                {
                    Console.Clear();

                    cvs = ExceptionHandle.Handle(CvFilter.FilterByEducation, UserHelper.InputEducation(), cvs);
                    break;
                }

                case FilterMenuEnum.ByExperience:
                {
                    Console.Clear();

                    cvs = ExceptionHandle.Handle(CvFilter.FilterByExperience, UserHelper.InputExperience(), cvs);
                    break;
                }

                case FilterMenuEnum.ByRegion:
                {
                    Console.Clear();

                    cvs = ExceptionHandle.Handle(CvFilter.FilterByRegion, UserHelper.InputRegion(), cvs);
                    break;
                }

                case FilterMenuEnum.BySalary:
                {
                    Console.Clear();

                    var input  = UserHelper.InputSalary();
                    var salary = UserHelper.ParseSalary(input);
                    cvs = ExceptionHandle.Handle(CvFilter.FilterBySalary, salary, cvs);
                    break;
                }

                case FilterMenuEnum.Reset:
                {
                    cvs = mainCvs;
                    break;
                }

                case FilterMenuEnum.Back:
                {
                    seeCvsLoop = false;
                    break;
                }
                }
            }
        }