Ejemplo n.º 1
0
        public virtual JsonResult GetGridData(GridContext ctx)
        {
            var curUser = this.usersRepo.FindOne(new UserByLoginSpecify(User.Identity.Name));

            IQueryable <Test> query = curUser.AssignedTests.AsQueryable();
            var totalCount          = query.Count();

            if (ctx.HasFilters)
            {
                query      = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                case SortOrder.Asc:
                    query = this.testsRepo.SortByAsc(ctx.SortColumn, query);
                    break;

                case SortOrder.Desc:
                    query = this.testsRepo.SortByDesc(ctx.SortColumn, query);
                    break;
                }
            }

            Mapper.CreateMap <AssignedTestModel, Test>().ReverseMap();
            var data = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map <AssignedTestModel>);

            return(Json(new { Data = data, TotalCount = totalCount }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public JsonResult GetGridData(GridContext ctx)
        {
            IQueryable <Department> query = this.departmentsRepo;
            var totalCount = query.Count();

            if (ctx.HasFilters)
            {
                query      = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                case SortOrder.Asc:
                    query = this.departmentsRepo.SortByAsc(ctx.SortColumn);
                    break;

                case SortOrder.Desc:
                    query = this.departmentsRepo.SortByDesc(ctx.SortColumn);
                    break;
                }
            }

            var departments = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).Select(Mapper.Map <DepartmentModel>);

            return(Json(new { Departments = departments, TotalCount = totalCount }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public virtual JsonResult GetGridData(GridContext ctx)
        {
            var curUser = this.usersRepo.FindOne(new UserByLoginSpecify(User.Identity.Name));

            IQueryable<Test> query = curUser.AssignedTests.AsQueryable();
            var totalCount = query.Count();

            if (ctx.HasFilters)
            {
                query = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                    case SortOrder.Asc:
                        query = this.testsRepo.SortByAsc(ctx.SortColumn, query);
                        break;

                    case SortOrder.Desc:
                        query = this.testsRepo.SortByDesc(ctx.SortColumn, query);
                        break;
                }
            }

            Mapper.CreateMap<AssignedTestModel, Test>().ReverseMap();
            var data = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map<AssignedTestModel>);

            return Json(new { Data = data, TotalCount = totalCount }, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 4
0
        public JsonResult GetGridData(GridContext ctx)
        {
            IQueryable <User> query = this.usersRepo.Where(x => this.CurrentSelectedCandidatesIds.Contains(x.Id));
            var totalCount          = query.Count();

            if (ctx.HasFilters)
            {
                query      = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                case SortOrder.Asc:
                    query = this.usersRepo.SortByAsc(ctx.SortColumn, query);
                    break;

                case SortOrder.Desc:
                    query = this.usersRepo.SortByDesc(ctx.SortColumn, query);
                    break;
                }
            }

            var data = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map <User, SelectedCandidateModel>);

            return(Json(new { Data = data, TotalCount = totalCount }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public virtual JsonResult GetGridData(GridContext ctx)
        {
            IQueryable <TEntity> query = this.repo;
            var totalCount             = query.Count();

            if (ctx.HasFilters)
            {
                query      = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                case SortOrder.Asc:
                    query = this.repo.SortByAsc(ctx.SortColumn, query);
                    break;

                case SortOrder.Desc:
                    query = this.repo.SortByDesc(ctx.SortColumn, query);
                    break;
                }
            }

            var data = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map <TEntity, TModel>);

            return(Json(new { Data = data, TotalCount = totalCount }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 6
0
        public JsonResult GetGridData(GridContext ctx)
        {
            IQueryable<Job> query = this.jobsRepo;
            var totalCount = query.Count();

            if (ctx.HasFilters)
            {
                query = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                    case SortOrder.Asc:
                        query = this.jobsRepo.SortByAsc(ctx.SortColumn, query);
                        break;

                    case SortOrder.Desc:
                        query = this.jobsRepo.SortByDesc(ctx.SortColumn, query);
                        break;
                }
            }

            var jobs = query.OrderBy(x=>x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map<JobModel>);

            return Json(new { Jobs = jobs, TotalCount = totalCount }, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 7
0
        public JsonResult GetDetailedRowGridData(GridContext ctx)
        {
            var curUser = this.jobsRepo.FindOne(new ByIdSpecify<Job>(this.CurrentJobId));
            var mySkills = curUser.JobSkills.AsQueryable();

            if (ctx.HasFilters)
            {
                mySkills = ctx.ApplyFilters(mySkills);
            }

            return Json(new { Skills = mySkills.Select(Mapper.Map<JobSkillModel>), TotalCount = mySkills.Count() }, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 8
0
        public JsonResult GetDetailedRowGridData(GridContext ctx)
        {
            var curUser = this.usersRepo.FindOne(new UserByLoginSpecify(User.Identity.Name));
            var mySkills = curUser.UsersSkills.AsQueryable();

            if (ctx.HasFilters)
            {
                mySkills = ctx.ApplyFilters(mySkills);
            }

            return Json(new {Skills = mySkills.Select(Mapper.Map<MySkillModel>), TotalCount = mySkills.Count()}, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 9
0
        public JsonResult GetDetailedRowGridData(GridContext ctx)
        {
            var curUser  = this.usersRepo.FindOne(new UserByLoginSpecify(User.Identity.Name));
            var mySkills = curUser.UsersSkills.AsQueryable();

            if (ctx.HasFilters)
            {
                mySkills = ctx.ApplyFilters(mySkills);
            }

            return(Json(new { Skills = mySkills.Select(Mapper.Map <MySkillModel>), TotalCount = mySkills.Count() }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 10
0
        public JsonResult GetDetailedRowGridData(GridContext ctx)
        {
            var curUser  = this.jobsRepo.FindOne(new ByIdSpecify <Job>(this.CurrentJobId));
            var mySkills = curUser.JobSkills.AsQueryable();

            if (ctx.HasFilters)
            {
                mySkills = ctx.ApplyFilters(mySkills);
            }

            return(Json(new { Skills = mySkills.Select(Mapper.Map <JobSkillModel>), TotalCount = mySkills.Count() }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 11
0
        public JsonResult GetGridData(GridContext ctx)
        {
            IQueryable <JobApplication> query = this.jobAppRepo.OrderBy(x => x.Id);

            //if (ctx.Filters.Any(f => f.Filter1.Field.Equals("ReqNotLow")))
            //{
            //    var jobId = ctx.Filters.Select(x => x.Filter1).Single(x => x.Field.Equals("JobId")).Value;
            //    query = this.SelectHasAllRequiredSkillsAndNotLower(long.Parse(jobId));
            //    var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("ReqNotLow"));
            //    ctx.Filters.Remove(filter);
            //}
            //else if (ctx.Filters.Any(f => f.Filter1.Field.Equals("Req")))
            //{
            //    var jobId = ctx.Filters.Select(x => x.Filter1).Single(x => x.Field.Equals("JobId")).Value;
            //    query = this.SelectHasAllRequiredSkills(long.Parse(jobId));
            //    var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("Req"));
            //    ctx.Filters.Remove(filter);
            //}
            //else
            //{
            //    query = this.jobAppRepo.OrderBy(x => x.Id);
            //}

            var totalCount = query.Count();

            if (ctx.HasFilters)
            {
                query      = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                case SortOrder.Asc:
                    query = this.jobAppRepo.SortByAsc(ctx.SortColumn, query);
                    break;

                case SortOrder.Desc:
                    query = this.jobAppRepo.SortByDesc(ctx.SortColumn, query);
                    break;
                }
            }

            var jobApplications = query.Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map <JobApplicationModel>);

            return(Json(new { JobApplications = jobApplications, TotalCount = totalCount }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 12
0
        public JsonResult GetGridData(GridContext ctx)
        {
            IQueryable<JobApplication> query = this.jobAppRepo.OrderBy(x => x.Id);

            //if (ctx.Filters.Any(f => f.Filter1.Field.Equals("ReqNotLow")))
            //{
            //    var jobId = ctx.Filters.Select(x => x.Filter1).Single(x => x.Field.Equals("JobId")).Value;
            //    query = this.SelectHasAllRequiredSkillsAndNotLower(long.Parse(jobId));
            //    var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("ReqNotLow"));
            //    ctx.Filters.Remove(filter);
            //}
            //else if (ctx.Filters.Any(f => f.Filter1.Field.Equals("Req")))
            //{
            //    var jobId = ctx.Filters.Select(x => x.Filter1).Single(x => x.Field.Equals("JobId")).Value;
            //    query = this.SelectHasAllRequiredSkills(long.Parse(jobId));
            //    var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("Req"));
            //    ctx.Filters.Remove(filter);
            //}
            //else
            //{
            //    query = this.jobAppRepo.OrderBy(x => x.Id);
            //}

            var totalCount = query.Count();

            if (ctx.HasFilters)
            {
                query = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                    case SortOrder.Asc:
                        query = this.jobAppRepo.SortByAsc(ctx.SortColumn, query);
                        break;

                    case SortOrder.Desc:
                        query = this.jobAppRepo.SortByDesc(ctx.SortColumn, query);
                        break;
                }
            }

            var jobApplications = query.Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map<JobApplicationModel>);

            return Json(new { JobApplications = jobApplications, TotalCount = totalCount }, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 13
0
        public JsonResult GetGridData(GridContext ctx)
        {
            IQueryable <Job> query;

            if (ctx.Filters.Any(x => x.Filter1.Field.Equals("ProjectFormalizeNameId")))
            {
                var projectFormalizeNameId = long.Parse(ctx.Filters.Select(x => x.Filter1).Single(c => c.Field.Equals("ProjectFormalizeNameId")).Value);
                query = this.jobsRepo.Where(x => x.Project.ProjectFormalizeNameId == projectFormalizeNameId);
                var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("ProjectFormalizeNameId"));
                ctx.Filters.Remove(filter);
            }
            else
            {
                query = this.jobsRepo;
            }

            var totalCount = query.Count();

            if (ctx.HasFilters)
            {
                query      = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                case SortOrder.Asc:
                    query = this.jobsRepo.SortByAsc(ctx.SortColumn, query);
                    break;

                case SortOrder.Desc:
                    query = this.jobsRepo.SortByDesc(ctx.SortColumn, query);
                    break;
                }
            }

            var jobs = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map <SearchJobModel>);

            return(Json(new { Jobs = jobs, TotalCount = totalCount }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 14
0
        public JsonResult GetGridData(GridContext ctx)
        {
            IQueryable<User> query = this.usersRepo.Where(x => this.CurrentSelectedCandidatesIds.Contains(x.Id));
            var totalCount = query.Count();

            if (ctx.HasFilters)
            {
                query = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                    case SortOrder.Asc:
                        query = this.usersRepo.SortByAsc(ctx.SortColumn, query);
                        break;

                    case SortOrder.Desc:
                        query = this.usersRepo.SortByDesc(ctx.SortColumn, query);
                        break;
                }
            }

            var data = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map<User, SelectedCandidateModel>);

            return Json(new { Data = data, TotalCount = totalCount }, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 15
0
        public JsonResult GetCandidatesGridData(GridContext ctx)
        {
            IQueryable <JobApplication> query;

            if (ctx.Filters.Any(f => f.Filter1.Field.Equals("ReqNotLow")))
            {
                var jobId = ctx.Filters.Select(x => x.Filter1).Single(x => x.Field.Equals("JobId")).Value;
                query = this.SelectHasAllRequiredSkillsAndNotLower(long.Parse(jobId));
                var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("ReqNotLow"));
                ctx.Filters.Remove(filter);
            }
            else if (ctx.Filters.Any(f => f.Filter1.Field.Equals("Req")))
            {
                var jobId = ctx.Filters.Select(x => x.Filter1).Single(x => x.Field.Equals("JobId")).Value;
                query = this.SelectHasAllRequiredSkills(long.Parse(jobId));
                var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("Req"));
                ctx.Filters.Remove(filter);
            }
            else
            {
                query = this.jobAppRepo.OrderBy(x => x.Id);
            }

            var totalCount = query.Count();

            if (ctx.HasFilters)
            {
                query      = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                case SortOrder.Asc:
                    query = this.jobAppRepo.SortByAsc(ctx.SortColumn, query);
                    break;

                case SortOrder.Desc:
                    query = this.jobAppRepo.SortByDesc(ctx.SortColumn, query);
                    break;
                }
            }

            var jobApplications = query.Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map <CandidateModel>).ToList();

            foreach (var jobApp in jobApplications)
            {
                // Calculate PERCENT MATCH JOB PROFILE SKILLS
                var job = this.jobsRepo.FindOne(new ByIdSpecify <Job>(this.CurrentJobId));

                var jobSkills     = job.JobSkills;
                var userSkills    = this.usersRepo.FindOne(new ByIdSpecify <User>(jobApp.UserId)).UsersSkills;
                int usersSkillSum = 0;
                var jobSkillSum   = 0;
                foreach (var jobSkill in jobSkills)
                {
                    int userEsitmate = 0;
                    if (userSkills.Any(x => x.SkillId == jobSkill.SkillId))
                    {
                        userEsitmate = userSkills.Single(x => x.SkillId == jobSkill.SkillId).Estimate;
                    }

                    jobApp.PercentMatchJobProfile += ((double)userEsitmate / 10 - (double)jobSkill.Estimate / 10) * (double)jobSkill.Estimate / 10;
                    //jobApp.Variance += Math.Pow((double)userEsitmate / 10, 2) - Math.Pow((double)jobSkill.Estimate / 10, 2);
                    jobApp.Variance += Math.Pow((double)userEsitmate / 10 - (double)jobSkill.Estimate / 10, 2);
                    usersSkillSum   += userEsitmate;
                    jobSkillSum     += jobSkill.Estimate;
                }


                jobApp.PercentMatchJobProfile = 1 + jobApp.PercentMatchJobProfile;
                jobApp.Variance = Math.Round(jobApp.Variance / (jobSkillSum), 2);
                //var totalJobSkillEst = jobSkills.Sum(x => x.Estimate);
                //var candPercentage = jobApp.PercentMatchJobProfile * 100 / totalJobSkillEst;
                //jobApp.PercentMatchJobProfile = (candPercentage < 0) ? 100 - Math.Abs(candPercentage) : candPercentage;
            }

            return(Json(new { JobApplications = jobApplications.OrderByDescending(x => x.PercentMatchJobProfile), TotalCount = totalCount }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 16
0
        public JsonResult GetGridData(GridContext ctx)
        {
            IQueryable<Job> query;
            if (ctx.Filters.Any(x => x.Filter1.Field.Equals("ProjectFormalizeNameId")))
            {
                var projectFormalizeNameId = long.Parse(ctx.Filters.Select(x => x.Filter1).Single(c => c.Field.Equals("ProjectFormalizeNameId")).Value);
                query = this.jobsRepo.Where(x => x.Project.ProjectFormalizeNameId == projectFormalizeNameId);
                var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("ProjectFormalizeNameId"));
                ctx.Filters.Remove(filter);
            }
            else
            {
               query = this.jobsRepo;
            }

            var totalCount = query.Count();

            if (ctx.HasFilters)
            {
                query = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                    case SortOrder.Asc:
                        query = this.jobsRepo.SortByAsc(ctx.SortColumn, query);
                        break;

                    case SortOrder.Desc:
                        query = this.jobsRepo.SortByDesc(ctx.SortColumn, query);
                        break;
                }
            }

            var jobs = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map<SearchJobModel>);

            return Json(new { Jobs = jobs, TotalCount = totalCount }, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 17
0
        public JsonResult GetGridData(GridContext ctx)
        {
            IQueryable <User> query = this.usersRepo.Where(x => x.JobApplications.Any(a => a.Job.ProjectId == this.CurrentProjectId));
            var totalCount          = query.Count();

            if (ctx.HasFilters)
            {
                query      = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                case SortOrder.Asc:
                    query = this.usersRepo.SortByAsc(ctx.SortColumn, query);
                    break;

                case SortOrder.Desc:
                    query = this.usersRepo.SortByDesc(ctx.SortColumn, query);
                    break;
                }
            }

            var users = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList();

            var data = new List <CandidateModel>();

            foreach (var user in users)
            {
                var candidate = Mapper.Map <CandidateModel>(user);
                // HasSelected
                if (user.Jobs.Any(x => x.ProjectId == this.CurrentProjectId))
                {
                    candidate.HasSelected = true;
                }
                else // Not Selected
                {
                    candidate.HasSelected = false;
                }
                // Has Tested
                if (user.TestResults.Any(x => user.AssignedTests.Any(a => a.Id == x.TestId)))
                {
                    candidate.HasTested = true;
                }
                else //Not Tested
                {
                    candidate.HasTested = false;
                }

                // Interview INFO
                var jobApp = user.JobApplications.First(x => x.Job.ProjectId == this.CurrentProjectId);
                candidate.HasInterviewed   = jobApp.HasInterviewed;
                candidate.InterviewResult  = jobApp.InterviewResult;
                candidate.InterviewComment = jobApp.InterviewComment;
                // Calculate PERCENT MATCH JOB PROFILE SKILLS
                var job = jobApp.Job;
                candidate.JobId = job.Id;
                var jobSkills     = job.JobSkills;
                var userSkills    = user.UsersSkills;
                int usersSkillSum = 0;
                var jobSkillSum   = 0;
                foreach (var jobSkill in jobSkills)
                {
                    int userEsitmate = 0;
                    if (userSkills.Any(x => x.SkillId == jobSkill.SkillId))
                    {
                        userEsitmate = userSkills.Single(x => x.SkillId == jobSkill.SkillId).Estimate;
                    }

                    candidate.PercentMatchJobProfile += ((double)userEsitmate / 10 - (double)jobSkill.Estimate / 10) * (double)jobSkill.Estimate / 10;
                    //candidate.Variance += Math.Pow((double)userEsitmate / 10, 2) - Math.Pow((double)jobSkill.Estimate / 10, 2);
                    candidate.Variance += Math.Pow((double)userEsitmate / 10 - (double)jobSkill.Estimate / 10, 2);
                    usersSkillSum      += userEsitmate;
                    jobSkillSum        += jobSkill.Estimate;
                }

                candidate.PercentMatchJobProfile = 1 + candidate.PercentMatchJobProfile;
                candidate.Variance = Math.Round(candidate.Variance / (jobSkillSum), 2);
                //var totalJobSkillEst = jobSkills.Sum(x => x.Estimate);
                //var candPercentage = candidate.PercentMatchJobProfile * 100 / totalJobSkillEst;
                //candidate.PercentMatchJobProfile = (candPercentage<0) ? 100 -  Math.Abs(candPercentage) : candPercentage;

                // Calculate TESTS RESULTS
                var assignedTests = user.AssignedTests;
                var testCompleted = assignedTests.Count(assignedTest => user.TestResults.Any(x => x.TestId == assignedTest.Id));
                candidate.TestsCompleted = string.Format("{0} of {1}", testCompleted, assignedTests.Count);

                data.Add(candidate);
            }

            return(Json(new { Data = data.OrderByDescending(x => x.PercentMatchJobProfile), TotalCount = totalCount }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetGridData(GridContext ctx)
        {
            IQueryable<User> query = this.usersRepo.Where(x => x.JobApplications.Any(a=>a.Job.ProjectId == this.CurrentProjectId));
            var totalCount = query.Count();

            if (ctx.HasFilters)
            {
                query = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                    case SortOrder.Asc:
                        query = this.usersRepo.SortByAsc(ctx.SortColumn, query);
                        break;

                    case SortOrder.Desc:
                        query = this.usersRepo.SortByDesc(ctx.SortColumn, query);
                        break;
                }
            }

            var users = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList();

            var data = new List<CandidateModel>();
            foreach (var user in users)
            {
                var candidate = Mapper.Map<CandidateModel>(user);
                // HasSelected
                if (user.Jobs.Any(x => x.ProjectId == this.CurrentProjectId))
                {
                    candidate.HasSelected = true;
                }
                else // Not Selected
                {
                    candidate.HasSelected = false;
                }
                // Has Tested
                if (user.TestResults.Any(x=>user.AssignedTests.Any(a=>a.Id == x.TestId)))
                {
                    candidate.HasTested = true;
                }
                else //Not Tested
                {
                    candidate.HasTested = false;
                }

                // Interview INFO
                var jobApp = user.JobApplications.First(x => x.Job.ProjectId == this.CurrentProjectId);
                candidate.HasInterviewed = jobApp.HasInterviewed;
                candidate.InterviewResult = jobApp.InterviewResult;
                candidate.InterviewComment = jobApp.InterviewComment;
                // Calculate PERCENT MATCH JOB PROFILE SKILLS
                var job = jobApp.Job;
                candidate.JobId = job.Id;
                var jobSkills = job.JobSkills;
                var userSkills = user.UsersSkills;
                int usersSkillSum = 0;
                var jobSkillSum = 0;
                foreach (var jobSkill in jobSkills)
                {
                    int userEsitmate = 0;
                    if (userSkills.Any(x => x.SkillId == jobSkill.SkillId))
                    {
                        userEsitmate = userSkills.Single(x => x.SkillId == jobSkill.SkillId).Estimate;
                    }

                    candidate.PercentMatchJobProfile += ((double)userEsitmate / 10 - (double)jobSkill.Estimate / 10) * (double)jobSkill.Estimate / 10;
                    //candidate.Variance += Math.Pow((double)userEsitmate / 10, 2) - Math.Pow((double)jobSkill.Estimate / 10, 2);
                    candidate.Variance += Math.Pow((double)userEsitmate / 10 - (double)jobSkill.Estimate / 10, 2);
                    usersSkillSum += userEsitmate;
                    jobSkillSum += jobSkill.Estimate;
                }

                candidate.PercentMatchJobProfile = 1 + candidate.PercentMatchJobProfile;
                candidate.Variance = Math.Round(candidate.Variance / (jobSkillSum), 2);
                //var totalJobSkillEst = jobSkills.Sum(x => x.Estimate);
                //var candPercentage = candidate.PercentMatchJobProfile * 100 / totalJobSkillEst;
                //candidate.PercentMatchJobProfile = (candPercentage<0) ? 100 -  Math.Abs(candPercentage) : candPercentage;

                // Calculate TESTS RESULTS
                var assignedTests = user.AssignedTests;
                var testCompleted = assignedTests.Count(assignedTest => user.TestResults.Any(x => x.TestId == assignedTest.Id));
                candidate.TestsCompleted = string.Format("{0} of {1}", testCompleted, assignedTests.Count);

                data.Add(candidate);
            }

            return Json(new { Data = data.OrderByDescending(x=>x.PercentMatchJobProfile), TotalCount = totalCount }, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 19
0
        public JsonResult GetCandidatesGridData(GridContext ctx)
        {
            IQueryable<JobApplication> query;

            if (ctx.Filters.Any(f => f.Filter1.Field.Equals("ReqNotLow")))
            {
                var jobId = ctx.Filters.Select(x => x.Filter1).Single(x => x.Field.Equals("JobId")).Value;
                query = this.SelectHasAllRequiredSkillsAndNotLower(long.Parse(jobId));
                var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("ReqNotLow"));
                ctx.Filters.Remove(filter);
            }
            else if (ctx.Filters.Any(f => f.Filter1.Field.Equals("Req")))
            {
                var jobId = ctx.Filters.Select(x => x.Filter1).Single(x => x.Field.Equals("JobId")).Value;
                query = this.SelectHasAllRequiredSkills(long.Parse(jobId));
                var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("Req"));
                ctx.Filters.Remove(filter);
            }
            else
            {
                query = this.jobAppRepo.OrderBy(x => x.Id);
            }

            var totalCount = query.Count();

            if (ctx.HasFilters)
            {
                query = ctx.ApplyFilters(query);
                totalCount = query.Count();
            }

            if (ctx.HasSorting)
            {
                switch (ctx.SortOrder)
                {
                    case SortOrder.Asc:
                        query = this.jobAppRepo.SortByAsc(ctx.SortColumn, query);
                        break;

                    case SortOrder.Desc:
                        query = this.jobAppRepo.SortByDesc(ctx.SortColumn, query);
                        break;
                }
            }

            var jobApplications = query.Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map<CandidateModel>).ToList();

            foreach (var jobApp in jobApplications)
            {
                // Calculate PERCENT MATCH JOB PROFILE SKILLS
                var job = this.jobsRepo.FindOne(new ByIdSpecify<Job>(this.CurrentJobId));

                var jobSkills = job.JobSkills;
                var userSkills = this.usersRepo.FindOne(new ByIdSpecify<User>(jobApp.UserId)).UsersSkills;
                int usersSkillSum = 0;
                var jobSkillSum = 0;
                foreach (var jobSkill in jobSkills)
                {
                    int userEsitmate = 0;
                    if (userSkills.Any(x => x.SkillId == jobSkill.SkillId))
                    {
                        userEsitmate = userSkills.Single(x => x.SkillId == jobSkill.SkillId).Estimate;
                    }

                    jobApp.PercentMatchJobProfile += ((double)userEsitmate / 10 - (double)jobSkill.Estimate / 10) * (double)jobSkill.Estimate / 10;
                    //jobApp.Variance += Math.Pow((double)userEsitmate / 10, 2) - Math.Pow((double)jobSkill.Estimate / 10, 2);
                    jobApp.Variance += Math.Pow((double)userEsitmate / 10 - (double)jobSkill.Estimate / 10, 2);
                    usersSkillSum += userEsitmate;
                    jobSkillSum += jobSkill.Estimate;
                }

                jobApp.PercentMatchJobProfile = 1 + jobApp.PercentMatchJobProfile;
                jobApp.Variance = Math.Round(jobApp.Variance / (jobSkillSum), 2);
                //var totalJobSkillEst = jobSkills.Sum(x => x.Estimate);
                //var candPercentage = jobApp.PercentMatchJobProfile * 100 / totalJobSkillEst;
                //jobApp.PercentMatchJobProfile = (candPercentage < 0) ? 100 - Math.Abs(candPercentage) : candPercentage;

            }

            return Json(new { JobApplications = jobApplications.OrderByDescending(x=>x.PercentMatchJobProfile), TotalCount = totalCount }, JsonRequestBehavior.AllowGet);
        }