// GET: api/Recommendations public List <RecomendedProjectDto> GetRecommendations(int id) { GeneralUser initiatior = db.Users.FirstOrDefault(gu => gu.Id == id); List <RecomendedProjectDto> result = new List <RecomendedProjectDto>(); if (initiatior != null) { List <Project> projectList = db.Projects.ToList(); foreach (Project project in new ProjectMatcher(initiatior).GetMatchingProvider(projectList)) { if (project.GetType() != initiatior.GetType()) { result.Add(new RecomendedProjectDto(project)); } } } return(result); }
// GET: api/Recommendations public List <RecommendedUserDto> GetRecommendations(int id) { GeneralUser initiatior = db.Users.FirstOrDefault(gu => gu.Id == id); List <RecommendedUserDto> result = new List <RecommendedUserDto>(); if (initiatior != null) { List <GeneralUser> otherTypeOfUsers = initiatior is StudentUser?db.Users.OfType <ProviderUser>().Cast <GeneralUser>().ToList() : db.Users.OfType <StudentUser>().Cast <GeneralUser>().ToList(); foreach (GeneralUser user in new ProviderMatcher(initiatior).GetMatchingProvider(otherTypeOfUsers)) { if (user.GetType() != initiatior.GetType()) { result.Add(new RecommendedUserDto(user)); } } } return(result); }