Exemple #1
0
        public async Task <ActionResult <EmployePositionRecommendation> > Get(int id)
        {
            //context.JobTitleRecommendations.Load();
            var recommendation = context.JobTitleRecommendations
                                 .Include(r => r.Employee)
                                 .Include(r => r._CourseToJobTitleRecommendationMappings).ThenInclude(m => m.Course)
                                 .Include(r => r.JobTitle)
                                 .Where(r => r.Employee.Id == id)
                                 .OrderByDescending(r => r.TimeStamp).ThenBy(r => r.Distance)
                                 .Take(5)
                                 .ToList();

            var employee = context.Employees
                           .Include(e => e.CourseResults)
                           .ThenInclude(cr => cr.Course)
                           .Include(e => e.JobHistory)
                           .ThenInclude(jh => jh.Title)
                           .Include(e => e.Competencies)
                           .ThenInclude(e => e.Competency)
                           .FirstOrDefault(e => e.Id == recommendation[0].Employee.Id);

            if (recommendation.Count == 0)
            {
                return(NoContent());
            }
            var result = new EmployePositionRecommendation(employee, recommendation.Select(r => new PositionRecommendation(r.JobTitle, r.CoursesToLearn)));

            return(Ok(result));
        }
        public async Task <EmployePositionRecommendation> Get(int employeeId)
        {
            EmployePositionRecommendation vm = cashe[employeeId];

            if (vm != null)
            {
                return(vm);
            }

            var courses   = context.LoadCourses();
            var positions = context.LoadPositions();
            var employee  = context.LoadEmpoyees().FirstOrDefault(e => e.Id == employeeId);

            if (employee == null)
            {
                return(null);
            }

            List <RecommendationSystemAnswerItem> recommendationSystemAnswers = await Request <List <RecommendationSystemAnswerItem> >(requestStringBuilder.GetEmployeeRecomendation(employeeId));

            List <PositionRecommendation> positionRecommendations = recommendationSystemAnswers.Select(
                a => new PositionRecommendation(
                    positions.First(p => p.Id == a.PositionId),
                    courses.Where(c => a.CourseIds.Contains(c.Id))
                    )
                ).ToList();
            var employePositionRecommendation = new EmployePositionRecommendation(employee, positionRecommendations);


            cashe[employeeId] = employePositionRecommendation;
            return(employePositionRecommendation);
        }