Ejemplo n.º 1
0
        public List <EmployeeDemographic> SearchEmployeeDemographics(
            String title,
            int?experienceMin,
            int?experienceMax,
            int?ageMin,
            int?ageMax,
            String gender,
            String race)
        {
            List <EmployeeDemographic> officers = EmployeeDemographics.ToList();

            if (title != null)
            {
                officers = officers.Where(officer => title.ToLower() == officer.JOB_TITLE.ToLower()).ToList();
            }

            if (experienceMin != null && experienceMax != null)
            {
                officers = officers.Where(officer => experienceMin <= officer.Years_Of_Service && experienceMax >= officer.Years_Of_Service).ToList();
            }

            if (ageMin != null && ageMax != null)
            {
                officers = officers.Where(officer => ageMin <= officer.Age && ageMax >= officer.Age).ToList();
            }

            if (gender != null)
            {
                officers = officers.Where(officer => gender.ToLower() == officer.Gender.ToLower()).ToList();
            }

            if (race != null)
            {
                officers = officers.Where(officer => race.ToLower() == officer.Race.ToLower()).ToList();
            }


            return(officers);
        }
Ejemplo n.º 2
0
        public List <EmployeeDemographic> OrderByDemographics(String action, String order)
        {
            List <EmployeeDemographic> officers = EmployeeDemographics.ToList();

            switch (action)
            {
            case ("title"):

                if (order == "descending")
                {
                    officers = officers.OrderByDescending(officer => officer.JOB_TITLE).ToList();
                }
                else
                {
                    officers = officers.OrderByDescending(officer => officer.JOB_TITLE).ToList();
                }
                break;

            case ("experience"):

                if (order == "descending")
                {
                    officers = officers.OrderByDescending(officer => officer.Years_Of_Service).ToList();
                }
                else
                {
                    officers = officers.OrderByDescending(officer => officer.Years_Of_Service).ToList();
                }
                break;

            case ("age"):

                if (order == "descending")
                {
                    officers = officers.OrderByDescending(officer => officer.Age).ToList();
                }
                else
                {
                    officers = officers.OrderByDescending(officer => officer.Age).ToList();
                }
                break;

            case ("gender"):

                if (order == "descending")
                {
                    officers = officers.OrderByDescending(officer => officer.Gender).ToList();
                }
                else
                {
                    officers = officers.OrderByDescending(officer => officer.Gender).ToList();
                }
                break;


            case ("race"):

                if (order == "descending")
                {
                    officers = officers.OrderByDescending(officer => officer.Race).ToList();
                }
                else
                {
                    officers = officers.OrderByDescending(officer => officer.Race).ToList();
                }
                break;
            }

            return(officers);
        }