public List <int> MatchMentor(MentorUser mentor) { List <int> matched = new List <int>(mentor.Mentees); List <User> mentees = new List <User>(mentor.Mentees); int k = 0; foreach (int i in mentor.Languages) { var l = MenteelR.FindByLangIdAll(i); if (l != null) { foreach (MenteeLanguage ml in l) { if (MenteeR.FindById((int)ml.MenteeID).HasMentor == 0) { matched.Add((int)ml.MenteeID); MenteeR.FindById((int)ml.MenteeID).HasMentor = 1; // dodac info do tablicy matches var match = new Matches(); match.MenteeID = ml.MenteeID; match.MentorID = mentor.Id; MatchesR.Add(match); k++; return(matched); } } } } return(matched); }
public override User GetUser(Mentor _mentor) { var mentor = new MentorUser(_mentor.Name, _mentor.Surname, _mentor.Email, _mentor.Gender, _mentor.Disability, _mentor.C_Mentees, _matcher); if (_mentor.Age != null) { System.Diagnostics.Debug.WriteLine("przed set age"); mentor.Age = (int)_mentor.Age; System.Diagnostics.Debug.WriteLine("po set age"); } if (_mentor.StartDate != null) { mentor.StartDate = (System.DateTime)_mentor.StartDate; } List <MentorLanguage> mentorLanguages = _mlr.FindByIdAll(_mentor.MentorID); List <int> languages = new List <int>(); foreach (MentorLanguage ml in mentorLanguages) { languages.Add((int)ml.LanguageID); } mentor.Languages = languages; List <MentorPreferences> mentorPreferences = _mpr.FindByIdAll(_mentor.MentorID); List <int> preferences = new List <int>(); foreach (MentorPreferences mp in mentorPreferences) { preferences.Add((int)mp.NationalityID); } mentor.PrefNationalities = preferences; return(mentor); }