public void UpdateEmployeeSatisfactionScore(int yearsWorkedId, int satisfactionScore)
        {
            var satisfactionScoreEmployee = _satisfactionScoresService.GetSatisfactionScores()
                                            .FirstOrDefault(satisfaction => satisfaction.SatisfactionScore == satisfactionScore);

            var employeeYearsWorked = _bloggingContext.YearsWorkedEmployees.FirstOrDefault(employee => employee.YearsWorkedId == yearsWorkedId);

            employeeYearsWorked.SatisfactionScoreId = satisfactionScoreEmployee.SatisfactionScoreId;

            _bloggingContext.SaveChanges();
        }
Пример #2
0
        public IEnumerable <YearsSatisfactionsViewModel> GetEmployeeYearsSatisfacions(int employeeId)
        {
            var employeesYearsWorked = _bloggingContext.YearsWorkedEmployees.Where(yearsWorked => yearsWorked.EmployeeId == employeeId);

            var employeeSatisfactions = _satisfactionScoresService.GetSatisfactionScores();

            return((from empYearWorked in employeesYearsWorked
                    join satisf in employeeSatisfactions on empYearWorked.SatisfactionScoreId equals satisf.SatisfactionScoreId
                    select new YearsSatisfactionsViewModel()
            {
                YearsWorkedId = empYearWorked.YearsWorkedId,
                SatisfactionScore = satisf.SatisfactionScore,
                YearsWorked = empYearWorked.YearsWorked
            }).OrderByDescending(emp => int.Parse(emp.YearsWorked)));
        }