public List <schedulingDTO> Get_parents_that_wait_to_class(int id) { var v = new PARENTSEntities(); List <scheduling> schedulingList = schedulingDAL.GetParentsThatWaitToClass(id); if (schedulingList == null) { return(new List <schedulingDTO>()); } List <schedulingDTO> schedulingDTOList = new List <schedulingDTO>(); schedulingList.ForEach(x => { perentsBL p = new perentsBL(); parents parents = new parents(); schedulingDTO s = new schedulingDTO(); parents = p.GetParentByIdStudent(x.id_student); s.code = x.code; s.code_class = x.code_class; s.hour_ = x.hour_; s.hour_enter = x.hour_enter; s.hour_exit = x.hour_exit; s.disableEnter = false; s.disableExit = false; s.nameMother = parents.first_name + " " + parents.last_name; s.idMother = parents.id; s.hour_reach = x.hour_reach; s.id_student = x.id_student; schedulingDTOList.Add(s); }); return(schedulingDTOList); }
//מחזירה לכל אמא את ילדיה public List <studentDTO> get_kids(string id_p) { parents p = DAL.perentsDAL.GetAllParents().FirstOrDefault(pp => pp.id == id_p); List <studens> ls = DAL.studensDAL.GetAllStudents().Where(s => s.id_parent == p.id).ToList(); List <studentDTO> studentListDTO = new List <studentDTO>(); ls.ForEach(x => { studentDTO s = new studentDTO(); s.id = x.id; s.code_class = x.code_class; s.id_parent = x.id_parent; s.first_name = x.first_name; s.last_name = x.last_name; studentListDTO.Add(s); }); return(studentListDTO); }
public parentsDTO GetParentById(string id) { parents parentsList = perentsDAL.GetParentById(id); if (parentsList == null) { return(null); } parentsDTO p = new parentsDTO(); p.code_instation = parentsList.code_instation; p.email = parentsList.email; p.first_name = parentsList.last_name; p.id = parentsList.id; p.telefone = parentsList.telefone; return(p); }
//מחזירה לכל אמא את ילדיה public List <studens> get_Allkids(string id_p) { parents p = DAL.perentsDAL.GetAllParents().FirstOrDefault(pp => pp.id == id_p); return(DAL.studensDAL.GetAllStudents().Where(s => s.id_parent == p.id).ToList()); }
public parents GetParentByIdStudent(string idS) { parents p = new parents(); return(p = DAL.perentsDAL.GetParentByIdStudent(idS)); }
//public List<studens> SortByEmail(List<studens> ls) //{ // return ls.OrderBy(x => x.parents.email).ToList(); //} //פונקצית הערכה //מקבלת אוסף -ליסט- של השיבוץ של כל בית הספר //ומחזירה ציון לשיבוץ //לפי //1. פרק הזמן שאמא לכמה בנות שוהה בבית הספר //2. רמת סטיה מבקשות של אמהות private int mark(List <scheduling> l) { List <parents> lst_par = perentsDAL.GetParentByCodeInstation(this.idMosad); double avg = 0; int mark = 100, cntExp = 0; TimeSpan from = new TimeSpan(00, 0, 0); TimeSpan to = new TimeSpan(00, 0, 0); TimeSpan min = new TimeSpan(23, 59, 0); TimeSpan max = new TimeSpan(00, 00, 0); TimeSpan temp; perentsBL pars = new perentsBL(); requestBL r = new requestBL(); //1. פרק הזמן שאמא לכמה בנות שוהה בבית הספר foreach (parents p in lst_par) { List <studens> lst_k = pars.get_Allkids(p.id); min = new TimeSpan(23, 59, 0); max = new TimeSpan(00, 00, 0); for (int i = 0; i < lst_k.Count(); i++) { //השוואה של timespan temp = l.Where(x => x.id_student == lst_k[i].id).FirstOrDefault().hour_; if (temp > (max)) { max = temp; } if (temp < min) { min = temp; } } avg = (max - min).TotalMinutes; avg = (max - min).TotalMinutes / lst_k.Count(); if (avg > 30) { cntExp++; } } mark = mark - cntExp; cntExp = 0; //2.רמת סטיה מבקשות של אמהות //עובר על רשימת האימהות foreach (parents pa in lst_par) { List <studens> lst_k = pars.get_Allkids(pa.id); List <studens> st; TimeSpan scheTime = new TimeSpan(); parents p = new parents(); request h = allRquest.Where(rr => rr.id_parent == pa.id).FirstOrDefault(); if (h != null) { from = h.from_hour; to = h.to_hour; st = lst_studens.Where(y => y.id_parent == pa.id).ToList(); //שולף מרשימת השיבוצים שהתקבלה את השעות של הילדים של ההורה foreach (studens item in lst_k) { scheTime = l.Where(e => e.id_student == item.id).Select(t => t.hour_).FirstOrDefault(); if (scheTime < from || scheTime > to) { cntExp++; } } } } mark = mark - cntExp; return(mark); }
//פונקצית שיבוץ לתלמידה בודדת // אם יכול לשבץ מוסיף לאוסף השיבוץ ומחזיר אמת //אחרת מחזיר שקר public bool Shibutz_stud(studens s) { //נשלוף את הבקשות של האמא //את השיבוצים של האחיות של התלמידה // את השעות הפנויות בכיתה שלה //וננסה לשבץ באופן שמתאים לכל הקריטריונים //בקשות parents p = new parents(); p = allParents .Where(t => t.id == s.id_parent).FirstOrDefault(); request r = allRquest .Where(rr => rr.id_parent == p.id).FirstOrDefault(); if (r == null) { r = new request(); r.id_parent = s.id_parent; r.from_hour = allTimes.Where(t => t.code_class == s.code_class).FirstOrDefault().from_hour; r.to_hour = allTimes.Where(t => t.code_class == s.code_class).FirstOrDefault().to_hour; } //שיבוצים של אחיות List <studens> lst_sis = allStudents .Where(a => a.id_parent == s.id_parent).ToList(); List <scheduling> lstSis = new List <scheduling>(); foreach (studens item in lst_sis) { scheduling scd = lstscheduling .Where(u => u.id_student == item.id) .FirstOrDefault(); if (scd != null) { lstSis.Add(scd); } } //שעות פנויות בכיתה ממוין לפי שעה List <studens> all_class = allStudents .Where(cc => cc.code_class == s.code_class).ToList(); List <scheduling> lstClassNotEmpty = new List <scheduling>(); foreach (var item in all_class) { scheduling scd = lstscheduling .Where(cc => cc.id_student == item.id).FirstOrDefault(); if (scd != null) { lstClassNotEmpty.Add(scd); } } lstClassNotEmpty = lstClassNotEmpty.OrderBy(ss => ss.hour_).ToList(); TimeSpan t1 = allTimes .Where(o => o.code_class == s.code_class) .FirstOrDefault().from_hour; TimeSpan t2 = allTimes .Where(o => o.code_class == s.code_class) .FirstOrDefault().to_hour; List <TimeSpan> lstClass = new List <TimeSpan>(); for (TimeSpan h = t1; h < t2; h += (new TimeSpan(0, 15, 0))) { if (lstClassNotEmpty.Where(ss => ss.hour_.Equals(h)).ToList().Count() == 1) { lstClass.Add(h); } else if (lstClassNotEmpty.Where(ss => ss.hour_.Equals(h)).ToList().Count() == 0) { lstClass.Add(h); lstClass.Add(h); } } //לולאה שעוברת על כל השעות שבטווח הבקשה של האמא //ומנסה לשבץ //אם הצליחה מחזירה אמת for (TimeSpan h = r.from_hour; h < r.to_hour; h += (new TimeSpan(0, 15, 0))) { if (lstSis == null || lstSis.Where(ss => ss.hour_.Equals(h)).FirstOrDefault() == null) { TimeSpan f = lstClass.Where(ss => ss == h).FirstOrDefault(); if (lstClass.Where(ss => ss == h).FirstOrDefault() != (new TimeSpan(00, 00, 00)) && h >= t1 && h < t2) { //שיבוץ בפועל //והחזרת אמת scheduling x = new scheduling(); x.code_class = s.code_class; x.hour_ = h; x.id_student = s.id; lstscheduling.Add(x); return(true); } } } //אם לא הצליחה //לולאה שעוברת על כל הטווח של הכיתה //ומנסה לשבץ foreach (TimeSpan h in lstClass) { if (lstSis == null || lstSis.Where(ss => ss.hour_.Equals(h)).FirstOrDefault() == null) { { //שיבוץ בפועל //והחזרת אמת scheduling x = new scheduling(); x.code_class = s.code_class; x.hour_ = h; x.id_student = s.id; lstscheduling.Add(x);; return(true); } } } //אם לא הצליחה יחזיר שקר return(false); }
public static void Main() { string[] input = Console.ReadLine().Split(new[] { ' ', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries).ToArray(); Dictionary <string, Person> persons = new Dictionary <string, Person>(); while (input[0] != "End") { if (!persons.ContainsKey(input[0])) { Person current = new Person(); current.name = input[0]; persons.Add(input[0], current); } switch (input[1]) { case "company": company comp = new company(); comp.name = input[2]; comp.department = input[3]; comp.salary = double.Parse(input[4]); persons[input[0]].Company = comp; break; case "pokemon": pokemon poke = new pokemon(); poke.name = input[2]; poke.type = input[3]; persons[input[0]].Pokemons.Add(poke); break; case "parents": parents parent = new parents(); parent.name = input[2]; parent.birthday = input[3]; persons[input[0]].Parents.Add(parent); break; case "children": children child = new children(); child.name = input[2]; child.birthday = input[3]; persons[input[0]].Children.Add(child); break; case "car": car car = new car(); car.model = input[2]; car.speed = input[3]; persons[input[0]].Car = car; break; } input = Console.ReadLine().Split(new[] { ' ', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries).ToArray(); } string person = Console.ReadLine(); var pers = persons.Where(x => x.Key == person).ToList(); foreach (var one in pers) { Console.WriteLine(one.Value.name); Console.WriteLine("Company:"); if (one.Value.Company != null) { Console.WriteLine($"{one.Value.Company.name} {one.Value.Company.department} {one.Value.Company.salary:f2}"); } Console.WriteLine("Car:"); if (one.Value.Car != null) { Console.WriteLine($"{one.Value.Car.model} {one.Value.Car.speed}"); } Console.WriteLine("Pokemon:"); if (one.Value.Pokemons != null) { foreach (var pokemon in one.Value.Pokemons) { Console.WriteLine($"{pokemon.name} {pokemon.type}"); } } Console.WriteLine("Parents:"); if (one.Value.Parents != null) { foreach (var parent in one.Value.Parents) { Console.WriteLine($"{parent.name} {parent.birthday}"); } } Console.WriteLine("Children:"); if (one.Value.Children != null) { foreach (var child in one.Value.Children) { Console.WriteLine($"{child.name} {child.birthday}"); } } } }
parents[p] = GetParent(parents[p]);
var(parents, sizes, expected) = scenarios;
public ParentMark(parents p, double avg) { this.par = p; this.avg = avg; }