예제 #1
0
        public List <CandidateInfo> ListUserFit(string KeyWord, int AreaID, int JobID, int experienceID, int salaryID, int languageID, int levelLanguageID)
        {
            var listUsers      = ListUser();
            var listUserMajors = new UserMajorDao().ListUserMajor();
            var listJobs       = new JobMajorDao().ListJobMain();
            var listLanguage   = new UserForeignLanguageDao().ReturnList();

            var result = (from User in listUsers
                          join UserMajor in listUserMajors on User.UserId equals UserMajor.UserID
                          join Language in listLanguage on User.UserId equals Language.UserID
                          where (AreaID == 0 || User.UserArea == AreaID) &&
                          (JobID == 0 || UserMajor.MajorID == JobID) &&
                          (languageID == 0 || Language.LanguageID == languageID) &&
                          (salaryID == 0 || User.Salary == salaryID) &&
                          (KeyWord == "0" || User.UserName.Contains(KeyWord))
                          select new
            {
                UserId = User.UserId,
                UserName = User.UserName,
                //UserImage = User.UserImage,
                //UserExperience = User.UserExperience,
                UserSalary = (User.Salary != null)?  User.Salary : 0,
                UserArea = db.Areas.Find(User.UserArea).NameArea,
                UserMajorName = (from UserMajor in listUserMajors
                                 join JobMajor in listJobs on UserMajor.MajorID equals JobMajor.JobID

                                 where (UserMajor.UserID == User.UserId)

                                 select JobMajor.JobName).ToList()
            }).AsEnumerable().Select(x => new CandidateInfo()
            {
                UserId   = x.UserId,
                UserName = x.UserName,
                //UserImage = x.UserImage,
                //UserExperience = x.UserExperience,
                UserSalary    = new SalaryDao().AmountSalary(x.UserSalary.Value),
                UserArea      = x.UserArea,
                UserSalary    = x.UserSalary,
                UserMajorName = x.UserMajorName
            });

            List <CandidateInfo> finalResult = result.ToList();
            int n = finalResult.Count;

            if (n == 0 || n == 1)
            {
                return(finalResult);
            }

            List <CandidateInfo> finalResult2 = new List <CandidateInfo>();

            for (int i = 0; i < n; i++)
            {
                bool check = true;
                for (int j = 0; j < finalResult2.Count; j++)
                {
                    if (finalResult[i].UserId == finalResult2[j].UserId)
                    {
                        check = false;
                        break;
                    }
                }
                if (check == true)
                {
                    finalResult2.Add(finalResult[i]);
                }
            }
            return(finalResult2);
        }
예제 #2
0
        public List <CandidateInfo> ListUserFit(String name, int areaID, int JobId)
        {
            var listUserMajors = new UserMajorDao().ListUserMajor();
            var listJobs       = new JobMajorDao().ListJobMain();

            var result = (from User in db.Users.ToList()
                          join UserMajor in listUserMajors on User.UserId equals UserMajor.UserID
                          where (areaID == 0 || User.UserArea == areaID)
                          where (JobId == 0 || UserMajor.MajorID == JobId)
                          where (name == "0" || User.UserName.Contains(name))
                          select new
            {
                UserId = User.UserId,
                UserName = User.UserName,
                //UserImage = User.UserImage,
                //UserExperience = User.UserExperience,
                //UserSalary = User.GPA,
                UserArea = db.Areas.Find(User.UserArea).NameArea,
                UserMajorName = (from UserMajor in listUserMajors
                                 join JobMajor in listJobs on UserMajor.MajorID equals JobMajor.JobID

                                 where (UserMajor.UserID == User.UserId)

                                 select JobMajor.JobName).ToList()
            }).AsEnumerable().Select(x => new CandidateInfo()
            {
                UserId   = x.UserId,
                UserName = x.UserName,
                //UserImage = x.UserImage,
                //UserExperience = x.UserExperience,
                //UserSalary = (float)x.UserSalary,
                UserArea      = x.UserArea,
                UserMajorName = x.UserMajorName
            });

            List <CandidateInfo> finalResult = result.ToList();
            int n = finalResult.Count;

            if (n == 0 || n == 1)
            {
                return(finalResult);
            }

            List <CandidateInfo> finalResult2 = new List <CandidateInfo>();

            for (int i = 0; i < n; i++)
            {
                bool check = true;
                for (int j = 0; j < finalResult2.Count; j++)
                {
                    if (finalResult[i].UserId == finalResult2[j].UserId)
                    {
                        check = false;
                        break;
                    }
                }
                if (check == true)
                {
                    finalResult2.Add(finalResult[i]);
                }
            }
            return(finalResult2);
        }