static void Main(string[] args) { try { #region INIT IBL mybl = FactoryBL.Instance; Dictionary <DayOfWeek, KeyValuePair <int, int> > tmpDate = new Dictionary <DayOfWeek, KeyValuePair <int, int> > { { DayOfWeek.Monday, new KeyValuePair <int, int>(0700, 1600) } }; List <String> tmpChildren = new List <String>(); tmpChildren.Add("201046869"); tmpChildren.Add("316301191"); //tmpChildren.Add("2010"); Address address = new Address { house = "7", city = "Jerusalem", country = "Israel", addressLine2 = "what is it??", flat = "7", floor = "-3.5", postCode = "1234567", street = "Beit Ha-Defus" }; BankAccount bank = new BankAccount { bankName = Bank.Discount, branchAddress = address, accountNumber = 12345678, branchNumber = 290 }; Person person = new Person { dateOfBirth = new DateTime(1996, 11, 2), email = "*****@*****.**", mobile = "0584465913", personAddress = address, landLinePhone = "02-5807777", ID = "316301191", firstName = "ISRAELA", lastName = "ISRAELI" }; Parent parent = new Parent { dateOfBirth = new DateTime(1996, 11, 2), email = "*****@*****.**", mobile = "0584465913", personAddress = address, landLinePhone = "02-5807777", ID = "316301191", firstName = "ISRAELA", lastName = "ISRAELI", childrenId = tmpChildren, areaToSearchNanny = address, parentWorkhours = tmpDate }; Parent parent1 = new Parent { dateOfBirth = new DateTime(1996, 11, 2), email = "*****@*****.**", mobile = "0584465913", personAddress = address, landLinePhone = "02-5807777", ID = "201046869", firstName = "ISRAELA", lastName = "ISRAELI", childrenId = tmpChildren, areaToSearchNanny = address, parentWorkhours = tmpDate }; List <Language> temp = new List <Language>(); temp.Add(Language.Arabic); temp.Add(Language.English); List <SKILLS> temp2 = new List <SKILLS>(); temp2.Add(SKILLS.Calm); List <String> temp3 = new List <String>(); temp3.Add("great nanny!"); temp3.Add("Stupid nanny!"); Dictionary <DayOfWeek, KeyValuePair <int, int> > tempDic = new Dictionary <DayOfWeek, KeyValuePair <int, int> >(); tempDic.Add(DayOfWeek.Sunday, new KeyValuePair <int, int>(8, 12)); Nanny nanny = new Nanny { expYears = 2, maxChildren = 3, minAge = 1, maxAge = 8, costPerHour = 25, costPerMonth = 1000, currentStars = 4, dateOfBirth = new DateTime(1996, 11, 2), email = "*****@*****.**", firstName = "Malka", ID = "201046869", isLift = false, isVacation = false, landLinePhone = "02-5847689", lastName = "Isacker", mobile = "0657849375", nannyAccount = bank, nannyGender = Gender.female, nannyLanguage = temp, nannySkills = temp2, personAddress = address, recommendations = temp3, workField = Specialization.Babysitter, workhours = tempDic }; temp.Add(Language.French); temp.Reverse(); Nanny nanny1 = new Nanny { expYears = 2, maxChildren = 3, minAge = 2, maxAge = 9, costPerHour = 25, costPerMonth = 1000, currentStars = 4, dateOfBirth = new DateTime(1996, 11, 2), email = "*****@*****.**", firstName = "Malka", ID = "316301191", isLift = true, isVacation = true, landLinePhone = "02-5847689", lastName = "Isacker", mobile = "0657849375", nannyAccount = bank, nannyGender = Gender.female, nannyLanguage = temp, nannySkills = temp2, personAddress = new Address { house = "9", city = "Beitar Illit", country = "Israel", addressLine2 = "what is it??", flat = "7", floor = "-3.5", postCode = "1234567", street = "HaRav Ya'akov Mutsafi" }, recommendations = temp3, workField = Specialization.Babysitter, workhours = tempDic }; List <Language> temppp = new List <Language>(); temppp.Add(Language.Hebrew); Child child = new Child { childDetails = new Dictionary <ChildInfo, string>(), childHMO = HMO.Maccabi, childLanguage = temppp, dateOfBirth = new DateTime(2016, 3, 12), firstName = "Malkkkkk", ID = "201046869", lastName = "Katzenelenbogenstein", parentId = "201046869", specialNeeds = true }; Child child1 = new Child { childDetails = new Dictionary <ChildInfo, string>(), childHMO = HMO.Maccabi, childLanguage = temppp, dateOfBirth = new DateTime(2016, 3, 12), firstName = "Malkkkkk", ID = "316301191", lastName = "Katzenelenbogenstein", parentId = "316301191", specialNeeds = true }; Contract contract = new Contract { ChildId = child.ID, contractID = "4566666", DurationOfEmployment = new KeyValuePair <DateTime, DateTime>(new DateTime(2000, 11, 2), new DateTime(2005, 11, 2)), hourWage = 90, isAnotherChild = true, isContract = true, isInterview = true, monthlyWage = 9000, NannyId = nanny.ID, ParentId = parent.ID, schedule = nanny.workhours }; Contract contract1 = new Contract { ChildId = child1.ID, contractID = "4566666", DurationOfEmployment = new KeyValuePair <DateTime, DateTime>(new DateTime(2000, 11, 2), new DateTime(2005, 11, 2)), hourWage = 90, isAnotherChild = true, isContract = true, isInterview = true, monthlyWage = 9000, NannyId = nanny1.ID, ParentId = parent1.ID, schedule = nanny1.workhours }; #endregion #region CHECK TOSTRING Console.WriteLine("Address:" + address.ToString()); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("Bank account:" + bank.ToString()); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("Person:" + person.ToString()); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("Parent: " + parent.ToString()); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("Nanny: " + nanny.ToString()); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("Child: " + child.ToString()); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("Contract: " + contract.ToString()); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); #endregion #region ADD mybl.addNanny(nanny); mybl.addNanny(nanny1); mybl.addParent(parent); mybl.addParent(parent1); mybl.addChild(child); mybl.addChild(child1); mybl.addContract(contract); mybl.addContract(contract1); #endregion #region GETALL mybl.getAllContracts(); mybl.getAllNanny(); mybl.getAllParents(); mybl.getAllChildren(); #endregion #region REMOVE mybl.removeContract(contract1.contractID); mybl.getAllContracts(); mybl.removeNanny(nanny1.ID); mybl.getAllNanny(); mybl.removeParent(parent1.ID); mybl.getAllParents(); mybl.getAllChildren(); mybl.removeChild(child1.ID); mybl.getAllChildren(); #endregion #region ADD mybl.addNanny(nanny1); mybl.addParent(parent1); mybl.addChild(child1); mybl.addChild(child); mybl.getAllContracts(); mybl.addContract(contract1); #endregion #region GETALL mybl.getAllContracts(); mybl.getAllNanny(); mybl.getAllParents(); mybl.getAllChildren(); #endregion #region WORKING FUNCTION int t = mybl.tamatVacation().Count; t = mybl.childrenWithNoNanny().Count; mybl.CalculateBill(true, contract1); mybl.CalculateBill(true, contract1); mybl.specificContracts(x => x.monthlyWage >= 1000); mybl.numberOfContracts(x => x.monthlyWage >= 1000); Dictionary <bool, List <Nanny> > tmp = mybl.nannyLift(); Dictionary <Language, List <Nanny> > tmp1 = mybl.nannyLanguage(); Dictionary <int, List <Nanny> > tmp2 = mybl.nannyAge(); Dictionary <int, List <Contract> > tmp3 = mybl.contractDistance(); mybl.initialMatch(parent, Gender.female, temp2, temp, 1, Specialization.Babysitter, 30, true, true, 3); mybl.betterMatchNanny(10000, parent, Gender.female, temp2, temp, 1, Specialization.Babysitter, 30, true, true, 3); #endregion //mybl.nannyTimeAddress(address, true, (Nanny n) => n.currentStars, 1);// arrival time = null why??? Console.WriteLine("done\n"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); //mybl.specificContracts(c => c.ChildId == "5"); //mybl.specificContracts(c => c.ChildId == "5"); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
private static void EditNan() { int id; Console.WriteLine("enter id to edit: "); id = int.Parse(Console.ReadLine()); Nanny nan = BlFactorySingleton.Instance.GetNannies().ToList().Find(x => x.Id == id); if (nan != null) { Console.WriteLine(nan.ToString()); Console.WriteLine("Enter new details. If you do not want to change, insert the existing one according to the list above"); string lastName; string firstName; DateTime dateOfBirth; int phonNumber; string address; bool elevator; int floor; int yearsOfExperience; int maxChildren; int minimumAgeOfChild; int maximumAgeOfChild; Payment typeOfPayment; double hourlyRate; double monthlyRate; bool[] workDays = new bool[6]; Day[] workHours = new Day[6]; VacationDaysBy vacationDaysBy; string recommendations; string theDay; int beginHour, beginMinute, endHour, endMinute; Console.WriteLine("enter last Name: "); lastName = Console.ReadLine(); Console.WriteLine("enter first Name: "); firstName = Console.ReadLine(); Console.WriteLine("enter date Of Birth: (dd mm yyyy)"); dateOfBirth = DateTime.Parse(Console.ReadLine()); Console.WriteLine("enter phone: "); phonNumber = int.Parse(Console.ReadLine()); Console.WriteLine("enter address: "); address = Console.ReadLine(); Console.WriteLine("enter elevator: (y/n)"); char elevat; do { elevat = char.Parse(Console.ReadLine()); switch (elevat) { case 'n': case 'N': elevator = false; break; case 'y': case 'Y': elevator = true; break; default: elevator = false; Console.WriteLine("ERROR"); break; } } while (elevat != 'y' && elevat != 'Y' && elevat != 'N' && elevat != 'n'); Console.WriteLine("enter floor: "); floor = int.Parse(Console.ReadLine()); Console.WriteLine("enter years of experience"); yearsOfExperience = int.Parse(Console.ReadLine()); Console.WriteLine("enter maximum age of kids: "); maximumAgeOfChild = int.Parse(Console.ReadLine()); Console.WriteLine("enter minimum age of kids: "); minimumAgeOfChild = int.Parse(Console.ReadLine()); Console.WriteLine("enter maximum number of kids: "); maxChildren = int.Parse(Console.ReadLine()); Console.WriteLine("enter payment method: (h for hourly pay, m for monthly pay)"); char pay; do { pay = char.Parse(Console.ReadLine()); switch (pay) { case 'm': case 'M': typeOfPayment = Payment.MONTHLY; Console.WriteLine("enter monthly Rate: "); monthlyRate = double.Parse(Console.ReadLine()); hourlyRate = 0; break; case 'h': case 'H': typeOfPayment = Payment.HOURLY; Console.WriteLine("enter hourly Rate: "); hourlyRate = double.Parse(Console.ReadLine()); monthlyRate = 0; break; default: hourlyRate = 0; monthlyRate = 0; typeOfPayment = Payment.HOURLY; Console.WriteLine("ERROR"); break; } } while (pay != 'h' && pay != 'H' && pay != 'm' && pay != 'M'); int nannySum = 0; Console.WriteLine("enter works day: "); for (int i = 0; i < 6; i++) { Console.WriteLine("day " + (i + 1) + ": (y/n)"); char day; do { day = char.Parse(Console.ReadLine()); switch (day) { case 'n': case 'N': workDays[i] = false; break; case 'y': case 'Y': nannySum++; workDays[i] = true; break; default: workDays[i] = false; Console.WriteLine("ERROR"); break; } } while (day != 'y' && day != 'Y' && day != 'N' && day != 'n'); } for (int i = 0; i < nannySum; i++) { Console.WriteLine("Enter the name of the day:"); theDay = Console.ReadLine(); Console.WriteLine("Enter the beginning hour:"); beginHour = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the minute of the beginning hour:"); beginMinute = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the end hour:"); endHour = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the minute of the end hour:"); endMinute = int.Parse(Console.ReadLine()); workHours[i] = new Day { TheDay = theDay, BeginningTime = new TimeSpan(beginHour, beginMinute, 0), EndTime = new TimeSpan(endHour, endMinute, 0) }; } Console.WriteLine("enter vacation day by: (m/t)"); char vacation; do { vacation = char.Parse(Console.ReadLine()); switch (vacation) { case 'm': case 'M': vacationDaysBy = VacationDaysBy.MINISTRY_OF_EDUCATION; break; case 't': case 'T': vacationDaysBy = VacationDaysBy.TAMAT; break; default: vacationDaysBy = VacationDaysBy.TAMAT; Console.WriteLine("ERROR"); break; } } while (vacation != 'm' && vacation != 'M' && vacation != 't' && vacation != 'T'); Console.WriteLine("enter recommendations: "); recommendations = Console.ReadLine(); Nanny newNan = new Nanny { Id = nan.Id, Address = address, DateOfBirth = dateOfBirth, MaximumAgeOfChild = maximumAgeOfChild, MinimumAgeOfChild = minimumAgeOfChild, Elevator = elevator, FirstName = firstName, Floor = floor, HourlyRate = hourlyRate, TypeOfPayment = typeOfPayment, LastName = lastName, MaxChildren = maxChildren, MonthlyRate = monthlyRate, PhonNumber = phonNumber, Recommendations = recommendations, VacationDays = vacationDaysBy, YearsOfExperience = yearsOfExperience, WorkDays = workDays, WorkHours = workHours }; try { BlFactorySingleton.Instance.UpdateNanny(newNan); } catch (Exception exp) { Console.WriteLine(exp.Message); } } else { Console.WriteLine("error: the nanny does not found!"); } }
private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { nanny = (Nanny)comboBox.SelectedItem; label1.Content = nanny.ToString(); }