public static string GetScoreName(this int score, int indicatorId, string professorCode, int termId) { var psCode = Convert.ToInt32(professorCode); if (indicatorId != 4) { IndicatorService indicatorService = new IndicatorService(new IndicatorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); return(indicatorService.Get(x => x.Id == indicatorId).Scores.OrderBy(s => s.Point) .FirstOrDefault(s => s.Point >= score) ?.Name); } else { var ps = new ProfessorService(new ProfessorRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var universityStudyPlace = ps.Get(x => x.ProfessorCode == psCode && x.Term.Id == termId).UniversityStudyPlace; var ss = new ScoreService(new ScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); var ulm = new UniversityLevelMappingService(new UniversityLevelMappingRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); if (universityStudyPlace != null && universityStudyPlace > 0) { var scoreId = ulm.Get(x => x.UniversityId == universityStudyPlace).Score.Id; var score1 = ss.Get(x => x.Id == scoreId); if (score1 != null) { return(score1.Name); } else { return(string.Empty); } } else { return(string.Empty); } } //var scoreService = new ScoreService(new ScoreRepository(new DatabaseFactory()), new UnitOfWork(new DatabaseFactory())); //return scoreService.Get(x => x.Id == scoreId.Value).Name; }