/// <summary>
        /// Checks all the job posts with Employee.CompareToJob
        /// </summary>
        /// <param name="employee"></param>
        /// <return>Returns a list of recommended JobPosts</returns>
        public static List <JobPost> GetRecommendedJobs(CVPost cv)
        {
            Database       db   = Database.GetInstance();
            List <JobPost> list = new List <JobPost>();

            foreach (var user in db.Employers)
            {
                foreach (var job in user.JobPosts)
                {
                    if (cv.CompareToJob(job))
                    {
                        list.Add(job);
                    }
                }
            }

            return(list);
        }
示例#2
0
 public Employee(string username, string emailAddress, string password) : base(username, emailAddress, password, UserType.Employee)
 {
     CV = new CVPost();
 }
        private void AddCV()
        {
            string input;
            bool   @break;
            CVPost CV = new CVPost();

            #region Name
            while (true)
            {
                View.WriteLine("Name");
                View.WriteLine();
                View.Write("> ");

                input = Console.ReadLine();

                try
                {
                    CV.Name = input;
                    break;
                }
                catch (Exception ex)
                {
                    View.WriteErrorAndClear(ex.Message);
                }
            }
            #endregion
            View.Clear();
            #region Surname
            while (true)
            {
                View.WriteLine("Surname");
                View.WriteLine();
                View.Write("> ");

                input = Console.ReadLine();

                try
                {
                    CV.Surname = input;
                    break;
                }
                catch (Exception ex)
                {
                    View.WriteErrorAndClear(ex.Message);
                }
            }
            #endregion
            View.Clear();
            #region Gender
            while (true)
            {
                View.WriteLine("Are you a male(m) or a female(f)?");
                View.WriteLine();
                View.Write("> ");

                input = Console.ReadLine();

                if (input == "male" || input == "m")
                {
                    CV.Gender = Gender.Male;
                    break;
                }
                else if (input == "female" || input == "f")
                {
                    CV.Gender = Gender.Female;
                }
                else
                {
                    View.WriteErrorAndClear("Invalid Option");
                }
            }
            #endregion
            View.Clear();
            #region Age
            while (true)
            {
                View.WriteLine("Age");
                View.WriteLine();
                View.Write("> ");

                input = Console.ReadLine();

                try
                {
                    CV.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);
                }
            }
            #endregion
            View.Clear();
            #region Study Degree
            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":
                    CV.StudyDegree = StudyDegree.Undergraduate;
                    break;

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

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

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

                if (@break)
                {
                    break;
                }
            }
            #endregion
            View.Clear();
            #region Work Experience
            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":
                    CV.WorkExperience = WorkExperience.LessThanOneYear;
                    break;

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

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

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

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

                if (@break)
                {
                    break;
                }
            }
            #endregion
            View.Clear();
            #region Job 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();
                    }
                }
                catch (Exception)
                {
                    View.WriteErrorAndClear("Invalid option.");
                    continue;
                }

                // Declaring the job category
                CV.Category = (JobCategory)n;
                break;
            }
            #endregion
            View.Clear();
            #region City
            while (true)
            {
                View.WriteLine("City");
                View.WriteLine();
                View.Write("> ");

                input = Console.ReadLine();

                try
                {
                    CV.City = input;
                    break;
                }
                catch (Exception ex)
                {
                    View.WriteErrorAndClear(ex.Message);
                }
            }
            #endregion
            View.Clear();
            #region Minimum Salary
            while (true)
            {
                View.WriteLine("Minimum salary you want");
                View.WriteLine();
                View.Write("> ");

                input = Console.ReadLine();

                try
                {
                    CV.MinimumSalary = 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);
                }
            }
            #endregion
            View.Clear();
            #region Phone number
            while (true)
            {
                View.WriteLine("Your phone number (+994501234567)");
                View.WriteLine();
                View.Write("> ");

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

                try
                {
                    CV.PhoneNumber = input;
                    break;
                }
                catch (Exception ex)
                {
                    View.WriteErrorAndClear(ex.Message);
                }
            }
            #endregion
            View.Clear();
            #region Summary
            while (true)
            {
                View.WriteLine(CV.ToString());
                View.WriteLine();
                View.WriteLine("Are you sure to add this CV to your accaunt? (y/n)");
                View.WriteLine();
                View.Write("> ");

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

                if (input == "yes" || input == "y")
                {
                    break;
                }
                else if (input == "no" || input == "n")
                {
                    View.Clear();
                    return;
                }
                else
                {
                    View.WriteErrorAndClear("Invalid option.");
                }
            }
            #endregion
            View.Clear();

            user.CV = CV;
            Database.GetInstance().Save();
        }