private void SearchButton_Click(object sender, RoutedEventArgs e) { errorArea.Visibility = areasCMB.SelectedValue == null ? Visibility.Visible : Visibility.Hidden; errordate.Visibility = myCalendar.SelectedDates.Count() == 0 ? Visibility.Visible : Visibility.Hidden; if (errordate.Visibility == Visibility.Visible || errorArea.Visibility == Visibility.Visible) { return; } UserDetailsWindow newDetails = new UserDetailsWindow(); newDetails.ShowDialog(); if (newDetails.txtUserFName.Text == "" || newDetails.txtUserLName.Text == "" || newDetails.txtYourMail.Text == "") { return; } myGuestRequest.FirstName = newDetails.FirstName; myGuestRequest.LastName = newDetails.LastName; myGuestRequest.MailAddress = newDetails.UserMail; myGuestRequest.Pool = poolCMB.SelectedValue == null ? Enum_s.RequestOption.אפשרי : (Enum_s.RequestOption)poolCMB.SelectedValue; myGuestRequest.Jacuzzi = jaccuziCMB.SelectedValue == null ? Enum_s.RequestOption.אפשרי : (Enum_s.RequestOption)jaccuziCMB.SelectedValue; myGuestRequest.Garden = gardenCMB.SelectedValue == null ? Enum_s.RequestOption.אפשרי : (Enum_s.RequestOption)gardenCMB.SelectedValue; myGuestRequest.Wifi = wifiCMB.SelectedValue == null ? Enum_s.RequestOption.אפשרי : (Enum_s.RequestOption)wifiCMB.SelectedValue; myGuestRequest.EntryDate = myCalendar.SelectedDates.First(); myGuestRequest.ReleaseDate = myCalendar.SelectedDates.Last(); myGuestRequest.Adults = int.Parse(adults.Text); myGuestRequest.Children = int.Parse(children.Text); myGuestRequest.Type = typeCMB.SelectedValue == null ? Enum_s.HostingUnitTypes.הכל : (Enum_s.HostingUnitTypes)typeCMB.SelectedValue; myGuestRequest.Area = (Enum_s.Areas)areasCMB.SelectedValue; myGuestRequest.SubArea = subAreaCMB.SelectedValue == null ? (Enum_s.SubArea)subAreaCMB.Items.CurrentItem : (Enum_s.SubArea)subAreaCMB.SelectedValue; try { bl.AddGuestRequest(myGuestRequest); MessageBox.Show("שלום " + myGuestRequest.FirstName + "\n בקשתך נקלטה בהצלחה! בדקות הקרובות יישלח אלייך אימייל עם הצעות אירוח מתאימות", "", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.None, MessageBoxOptions.RightAlign); myGuestRequest = null; myGuestRequest = new GuestRequest(); areasCMB.SelectedValue = null; this.NavigationService.Content = new MainPage(); } catch (ThreadStateException) { MessageBox.Show("שלום " + myGuestRequest.FirstName + "!\n" + "בקשתך נקלטה בהצלחה!" + '\n' + "מצטערים, אירעה שגיאה בעת שליחת המייל ובו הצעות אירוח. ", "", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.None, MessageBoxOptions.RightAlign); myGuestRequest = null; myGuestRequest = new GuestRequest(); } catch (Exception ex) { MessageBox.Show("שלום " + myGuestRequest.FirstName + "!\n" + ex.Message, "", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.None, MessageBoxOptions.RightAlign); myGuestRequest = null; myGuestRequest = new GuestRequest(); } }
private void Button_Click(object sender, RoutedEventArgs e) { DataContext = myguestRequest; myguestRequest.Adults = Int32.Parse(Adults.Text.ToString()); myguestRequest.Children = Int32.Parse(Children.Text.ToString()); myguestRequest.GuestRequestKey = GetA8digitNumber(); try { bl.AddGuestRequest(myguestRequest); MessageBox.Show("בקשתך התקבלה", "הצלחה", MessageBoxButton.OK, MessageBoxImage.Information); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "הודעת שגיאה", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void AddButton_Click(object sender, RoutedEventArgs e) //when we click on the button ADD { try { if (guestRequest.PrivateName == null || guestRequest.FamilyName == null) // we have to fill out all the required fields { throw new ArgumentException("Please fill out all required fields"); } guestRequest.Adults = NumAdults.Value; guestRequest.Children = NumChildren.Value; new MessageSuccess(this, bl.AddGuestRequest(guestRequest)).ShowDialog(); Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Guest Request", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void AddRequest(object sender, RoutedEventArgs e) { try { if (PoolComboxBox.SelectedItem == null || PublicTransportationComboxBox.SelectedItem == null || JacuzziComboxBox.SelectedItem == null || ViewComboxBox.SelectedItem == null || smokingComboxBox.SelectedItem == null || RoomServiceComboxBox.SelectedItem == null || AreaComboxBox.SelectedItem == null || GardenComboxBox.SelectedItem == null || ChildrensAttractionComboxBox.SelectedItem == null || WifiComboxBox.SelectedItem == null || TelevisionComboxBox.SelectedItem == null || SnackBarComboxBox.SelectedItem == null || LastNameTextBox.Text == "" || FirstNameTextBox.Text == "" || EmailTextBox.Text == "" || AdultTextBox.Text == "" || ChildrenTextBox.Text == "" || EntryDateDatePicker.SelectedDate == null || RealeaseDateDatePicker.SelectedDate == null) { throw new NullReferenceException("please fill out all of the fields"); } if (!Regex.IsMatch(this.AdultTextBox.Text.ToString(), @"^\d+$")) { throw new InvalidOperationException("invaild number of adults"); } if (!Regex.IsMatch(this.ChildrenTextBox.Text.ToString(), @"^\d+$")) { throw new InvalidOperationException("invaild number of Children"); } request.pool = (BE.Pool)PoolComboxBox.SelectedItem; request.publicTransportation = (BE.PublicTransportation)PublicTransportationComboxBox.SelectedItem; request.jacuzzi = (BE.Jacuzzi)JacuzziComboxBox.SelectedItem; request.view = (BE.View)ViewComboxBox.SelectedItem; request.smoking = (BE.Smoking)smokingComboxBox.SelectedItem; request.roomService = (BE.RoomService)RoomServiceComboxBox.SelectedItem; request.area = (BE.Area)AreaComboxBox.SelectedItem; request.garden = (BE.Garden)GardenComboxBox.SelectedItem; request.childrensAttractions = (BE.ChildrensAttractions)ChildrensAttractionComboxBox.SelectedItem; request.wifi = (BE.Wifi)WifiComboxBox.SelectedItem; request.tv = (BE.Television)TelevisionComboxBox.SelectedItem; request.snackBar = (BE.SnackBar)SnackBarComboxBox.SelectedItem; //request.area = (BE.Area)AreaComboxBox.SelectedItem; request.FamilyName = this.LastNameTextBox.Text; request.PrivateName = this.FirstNameTextBox.Text; request.MailAddress = this.EmailTextBox.Text; request.Adults = int.Parse(this.AdultTextBox.Text); request.Children = int.Parse(this.ChildrenTextBox.Text); string date1, date2; // date1 = EntryDateDatePicker.SelectedDate.ToString(); request.EntryDate = Convert.ToDateTime(EntryDateDatePicker.SelectedDate.ToString()); // date2 = RealeaseDateDatePicker.SelectedDate.ToString(); request.ReleaseDate = Convert.ToDateTime(RealeaseDateDatePicker.SelectedDate.ToString()); this.DataContext = request; bl.AddGuestRequest(request); request = new BE.GuestRequest(); MessageBoxResult result = MessageBox.Show("Thank You, your request has been received. Would you like to make another request?", "Status", MessageBoxButton.YesNo, MessageBoxImage.Information); switch (result) { case MessageBoxResult.Yes: this.Close(); Window AddGuestRequestWindow = new AddGuestRequestWindow(); AddGuestRequestWindow.Show(); break; case MessageBoxResult.No: this.Close(); break; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
static void Main(string[] args) { DateTime entryDate = new DateTime(2020, 4, 5), releaseDate = new DateTime(2020, 5, 12); BE.Host host = new BE.Host() { HostKey = ++BE.Configuration.HostKey, Balance = 105, PrivateName = "no", FamilyName = "money", PhoneNumber = "05050505", Email = "*****@*****.**", CollectionClearance = true, BankBranchDetails = new BE.BankBranch() { BankNumber = ++BE.Configuration.BankNumber, BankName = "take your money", BranchAddress = "take your money city", BranchCity = "no money city", BranchNumber = 15 }, BankAccountNumber = 130559, }; BE.GuestRequest guestRequest = new BE.GuestRequest { GuestRequestKey = ++BE.Configuration.GuestRequestKey, PrivateName = "shachar", FamilyName = "markovich", Email = "*****@*****.**", Stat = BE.Enums.Status.NotYetApproved, RegistrationDate = DateTime.Now, EntryDate = new DateTime(2020, 8, 9), ReleaseDate = new DateTime(2020, 8, 12), Area = BE.Enums.Area.Center, type = BE.Enums.UnitType.Hotel, Adults = 2, Children = 3, Pool = true, Jecuzzi = true, Garden = true, ChildrenAttractions = true }; BE.HostingUnit hostingUnit = new BE.HostingUnit() { HostingUnitKey = ++BE.Configuration.HostingUnitKey, HostingUnitName = "hotel california", Owner = host, type = BE.Enums.UnitType.Hotel, Area = BE.Enums.Area.Center, Diary = new bool[BE.Configuration._month, BE.Configuration._days], }; BE.Order order = new BE.Order() { OrderKey = ++BE.Configuration.OrderKey, HostingUnitKey = hostingUnit.HostingUnitKey, GuestRequestKey = guestRequest.GuestRequestKey, Status = guestRequest.Stat, CreateDate = DateTime.Now, OrderDate = new DateTime(2020, 3, 3) }; _bl.AddGuestRequest(guestRequest); _bl.AddHostingUnit(hostingUnit); _bl.AddOrder(order); Console.WriteLine("adding the next instance Successfully:\n"); Console.WriteLine(host); Console.WriteLine(); Console.WriteLine(guestRequest); Console.WriteLine(); Console.WriteLine(order); Clear(); if (_bl.IsDateArmor(hostingUnit, entryDate, releaseDate)) { Console.WriteLine("the following hostingUnit has free rooms between " + entryDate.toString() + " to " + releaseDate.toString()); Console.WriteLine(hostingUnit); Clear(); } Console.WriteLine($"host.Balance before taking fee: {host.Balance}"); _bl.TakeFee(order); List <BE.HostingUnit> unit2 = _bl.AccordingTo(unit => hostingUnit.Owner.HostKey == unit.Owner.HostKey); Console.WriteLine($"host.Balance after taking fee: {unit2.Single().Owner.Balance}"); Clear(); Console.WriteLine($"hostingUnit.diary before update:\n{hostingUnit.Diary.toString()}"); _bl.UpdateCalendar(hostingUnit, entryDate, releaseDate); unit2 = _bl.AccordingTo(unit => hostingUnit.HostingUnitKey == unit.HostingUnitKey); Console.WriteLine($"hostingUnit.diary after update:\n{unit2.Single().Diary.toString()}"); Clear(); _bl.SendEmail(host /*FROM*/, "*****@*****.**" /*TO*/); int daysNumber = _bl.OrderCount(guestRequest); Console.WriteLine($"number of orders sent to {guestRequest.GuestRequestKey} is: {daysNumber}"); daysNumber = _bl.ApprovedCount(hostingUnit); Console.WriteLine($"number of all order that have been closed for the hosting unit {hostingUnit.HostingUnitKey} is: {daysNumber}"); Clear(); List <BE.HostingUnit> c = _bl.ListOptionsFree(entryDate, daysNumber); foreach (var item in c) { Console.WriteLine(item); } Console.WriteLine("\n"); List <BE.Order> d = _bl.AtLeastnDays(daysNumber); foreach (var item in c) { Console.WriteLine(item); } Clear(); List <IGrouping <BE.Enums.Area, BE.GuestRequest> > f = _bl.GroupGuestRequestByArea(); List <IGrouping <int, BE.GuestRequest> > g = _bl.GroupGuestRequestByPeopleCount(); List <IGrouping <int, BE.Host> > h = _bl.GroupHostByfHostingUnitCount(); List <IGrouping <BE.Enums.Area, BE.HostingUnit> > i = _bl.GroupHostingUnitByArea(); }
private void addButton_Click(object sender, RoutedEventArgs e) { int int1; int adultint; int.TryParse(adults1TextBox.Text, out adultint); int childrenint; int.TryParse(children1TextBox.Text, out childrenint); int error = 0; try { if (PrivateName1TextBox.Text == "" && error == 0)//need to fill out name (we dont care if his name is a number) { MessageBox.Show("need to fill out private name"); error++; PrivateName1TextBox.Clear(); PrivateName1TextBox.Focus(); } else if (FamilyName1TextBox.Text == "" && error == 0)//need to fill out name (we dont care if his name is a number) { MessageBox.Show("need to fill out family name"); error++; FamilyName1TextBox.Clear(); FamilyName1TextBox.Focus(); } else if ((adults1TextBox.Text != "") && (!(int.TryParse(adults1TextBox.Text, out int1))) && (error == 0))//num of adults has to be a number { MessageBox.Show("num of adults has to be filled with a number"); error++; adults1TextBox.Clear(); adults1TextBox.Focus(); } else if ((children1TextBox.Text != "") && (!(int.TryParse(children1TextBox.Text, out int1))) && (error == 0))//num of adults has to be a number { MessageBox.Show("num of children has to be filled with a number"); error++; children1TextBox.Clear(); children1TextBox.Focus(); } else if (adultint < 0) { MessageBox.Show("num of adults has to be equel or larger then 0"); error++; adults1TextBox.Clear(); adults1TextBox.Focus(); } else if (childrenint < 0) { MessageBox.Show("num of children has to be equel or larger then 0"); error++; children1TextBox.Clear(); children1TextBox.Focus(); } else if ((childrenint + adultint) <= 0) { MessageBox.Show("num of guests must be be equel or larger then 1"); error++; adults1TextBox.Clear(); children1TextBox.Clear(); adults1TextBox.Focus(); } else if (!(IsValidEmail(mailAddress1TextBox.Text)) || mailAddress1TextBox.Text == "") { MessageBox.Show("Enter a valid email address"); error++; mailAddress1TextBox.Clear(); mailAddress1TextBox.Focus(); } if (error == 0) { bl.AddGuestRequest(guest); MessageBox.Show("Guest Request Added, Key:" + guest.GuestRequestKey1); this.GuestRequestDetailsGrid.DataContext = guest; Window GuestRequestWindow = new GuestRequest(); GuestRequestWindow.Show(); this.Close(); } } catch (FormatException) { MessageBox.Show("Please check your input and try again"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void initGuestRequests() { List <GuestRequest> guestRequestList = new List <GuestRequest>() { new GuestRequest() { GuestRequestKey = 1, FirstName = "Ron", LastName = "Cohen", MailAddress = "*****@*****.**", Status = Enum_s.GuestRequestStatus.Open, RegistrationDate = DateTime.Now, EntryDate = DateTime.Now.AddDays(1), ReleaseDate = DateTime.Now.AddDays(5), Area = Enum_s.Areas.צפון, SubArea = Enum_s.SubArea.חיפה, Type = Enum_s.HostingUnitTypes.מלון, Adults = 2, Children = 3, Pool = Enum_s.RequestOption.כן, Jacuzzi = Enum_s.RequestOption.כן, Garden = Enum_s.RequestOption.לא, ChildrenAttractions = Enum_s.RequestOption.כן }, new GuestRequest() { GuestRequestKey = 2, FirstName = "Dar", LastName = "Levi", MailAddress = "*****@*****.**", Status = Enum_s.GuestRequestStatus.Open, RegistrationDate = DateTime.Now, EntryDate = DateTime.Now.AddDays(8), ReleaseDate = DateTime.Now.AddDays(15), Area = Enum_s.Areas.מרכז, SubArea = Enum_s.SubArea.תל_אביב, Type = Enum_s.HostingUnitTypes.דירה, Adults = 3, Children = 0, Pool = Enum_s.RequestOption.אפשרי, Jacuzzi = Enum_s.RequestOption.אפשרי, Garden = Enum_s.RequestOption.כן, ChildrenAttractions = Enum_s.RequestOption.לא }, new GuestRequest() { GuestRequestKey = 3, FirstName = "Eyal", LastName = "Rot", MailAddress = "*****@*****.**", Status = Enum_s.GuestRequestStatus.Open, RegistrationDate = DateTime.Now, EntryDate = DateTime.Now.AddDays(50), ReleaseDate = DateTime.Now.AddDays(60), Area = Enum_s.Areas.דרום, SubArea = Enum_s.SubArea.אילת, Type = Enum_s.HostingUnitTypes.מלון, Adults = 4, Children = 4, Pool = Enum_s.RequestOption.כן, Jacuzzi = Enum_s.RequestOption.כן, Garden = Enum_s.RequestOption.אפשרי, ChildrenAttractions = Enum_s.RequestOption.כן }, new GuestRequest() { GuestRequestKey = 4, FirstName = "Itay", LastName = "Mark", MailAddress = "*****@*****.**", Status = Enum_s.GuestRequestStatus.Open, RegistrationDate = DateTime.Now, EntryDate = DateTime.Now.AddDays(12), ReleaseDate = DateTime.Now.AddDays(19), Area = Enum_s.Areas.צפון, SubArea = Enum_s.SubArea.גליל, Type = Enum_s.HostingUnitTypes.בקתה, Adults = 2, Children = 0, Pool = Enum_s.RequestOption.לא, Jacuzzi = Enum_s.RequestOption.כן, Garden = Enum_s.RequestOption.לא, ChildrenAttractions = Enum_s.RequestOption.לא }, new GuestRequest() { GuestRequestKey = 5, FirstName = "Tomer", LastName = "Halpern", MailAddress = "*****@*****.**", Status = Enum_s.GuestRequestStatus.Open, RegistrationDate = DateTime.Now, EntryDate = DateTime.Now.AddDays(2), ReleaseDate = DateTime.Now.AddDays(7), Area = Enum_s.Areas.ירושלים, SubArea = Enum_s.SubArea.ירושלים, Type = Enum_s.HostingUnitTypes.מלון, Adults = 3, Children = 2, Pool = Enum_s.RequestOption.כן, Jacuzzi = Enum_s.RequestOption.כן, Garden = Enum_s.RequestOption.כן, ChildrenAttractions = Enum_s.RequestOption.כן } }; foreach (var item in guestRequestList) { try { bl.AddGuestRequest(item); } catch (Exception) { } } }
static void Main(string[] args) { BL.IBL bl = BL.BlFactory.GetBL(); #region hosting units initializing List <HostingUnit> HostingUnitList = new List <HostingUnit>() { new HostingUnit() { HostingUnitKey = 1, Owner = new Host() { HostKey = 1, FirstName = "Efraim", LastName = "Miller", PhoneNumber = "0545851233", MailAddress = "*****@*****.**", BankBranchDetails = new BankBranch() { BankNumber = 11, BankName = "Discount", BranchNumber = 34, BranchAddress = "Kaplan 2", BranchCity = "Tel Aviv" }, BankAccountNumber = "1601245551", CollectionClearance = true, Commission = 0 }, HostingUnitName = "Kalanit", Diary = new bool[12, 31], Area = Enum_s.Areas.צפון, SubArea = Enum_s.SubArea.גליל, Type = Enum_s.HostingUnitTypes.קמפינג, Adults = 2, Children = 4, Pool = true, Jacuzzi = false, Garden = true, ChildrenAttractions = true }, new HostingUnit() { HostingUnitKey = 2, Owner = new Host() { HostKey = 2, FirstName = "Israel", LastName = "Avramov", PhoneNumber = "0527188451", MailAddress = "*****@*****.**", BankBranchDetails = new BankBranch() { BankNumber = 12, BankName = "Hapoalim", BranchNumber = 520, BranchAddress = "Kanfe Nesharim 22", BranchCity = "Jerusalem" }, BankAccountNumber = "1612348133", CollectionClearance = false, Commission = 0 }, HostingUnitName = "Antiques", Diary = new bool[12, 31], Area = Enum_s.Areas.ירושלים, SubArea = Enum_s.SubArea.ירושלים, Type = Enum_s.HostingUnitTypes.דירה, Adults = 4, Children = 2, Pool = false, Jacuzzi = false, Garden = false, ChildrenAttractions = false }, new HostingUnit() { HostingUnitKey = 3, Owner = new Host() { HostKey = 3, FirstName = "Yafit", LastName = "Halevi", PhoneNumber = "0587760213", MailAddress = "*****@*****.**", BankBranchDetails = new BankBranch() { BankNumber = 20, BankName = "Mizrahi Tefahot", BranchNumber = 464, BranchAddress = "Kakal 130", BranchCity = "Beer Sheba" }, BankAccountNumber = "1616342139", CollectionClearance = true, Commission = 0 }, HostingUnitName = "Flower", Diary = new bool[12, 31], Area = Enum_s.Areas.דרום, SubArea = Enum_s.SubArea.באר_שבע, Type = Enum_s.HostingUnitTypes.בקתה, Adults = 2, Children = 0, Pool = true, Jacuzzi = true, Garden = false, ChildrenAttractions = false }, new HostingUnit() { HostingUnitKey = 4, Owner = new Host() { HostKey = 4, FirstName = "Yizhak", LastName = "Shamir", PhoneNumber = "0512054332", MailAddress = "*****@*****.**", BankBranchDetails = new BankBranch() { BankNumber = 11, BankName = "Discount", BranchNumber = 3, BranchAddress = "Shderot Hatmarim, Shalom Center", BranchCity = "Eilat" }, BankAccountNumber = "1694527361", CollectionClearance = false, Commission = 0 }, HostingUnitName = "BlueSea", Diary = new bool[12, 31], Area = Enum_s.Areas.דרום, SubArea = Enum_s.SubArea.אילת, Type = Enum_s.HostingUnitTypes.מלון, Adults = 2, Children = 2, Pool = true, Jacuzzi = false, Garden = true, ChildrenAttractions = true }, new HostingUnit() { HostingUnitKey = 5, Owner = new Host() { HostKey = 5, FirstName = "Ruth", LastName = "Miller", PhoneNumber = "0587760213", MailAddress = "*****@*****.**", BankBranchDetails = new BankBranch() { BankNumber = 11, BankName = "Discount", BranchNumber = 331, BranchAddress = "Beit Hateomim 15", BranchCity = "Jerusalem" }, BankAccountNumber = "1615978523", CollectionClearance = false, Commission = 0 }, HostingUnitName = "Hordus", Diary = new bool[12, 31], Area = Enum_s.Areas.ירושלים, SubArea = Enum_s.SubArea.ירושלים, Type = Enum_s.HostingUnitTypes.בקתה, Adults = 4, Children = 4, Pool = false, Jacuzzi = true, Garden = true, ChildrenAttractions = true } }; foreach (var item in HostingUnitList) { try { bl.AddHostingUnit(item); } catch (Exception) { } } #endregion #region guest requests initializing List <GuestRequest> guestRequestList = new List <GuestRequest>() { new GuestRequest() { GuestRequestKey = 1, FirstName = "Ron", LastName = "Cohen", MailAddress = "*****@*****.**", Status = Enum_s.GuestRequestStatus.Open, RegistrationDate = DateTime.Now, EntryDate = DateTime.Now.AddDays(1), ReleaseDate = DateTime.Now.AddDays(5), Area = Enum_s.Areas.צפון, SubArea = Enum_s.SubArea.חיפה, Type = Enum_s.HostingUnitTypes.מלון, Adults = 2, Children = 3, Pool = Enum_s.RequestOption.כן, Jacuzzi = Enum_s.RequestOption.כן, Garden = Enum_s.RequestOption.לא, ChildrenAttractions = Enum_s.RequestOption.כן }, new GuestRequest() { GuestRequestKey = 2, FirstName = "Dar", LastName = "Levi", MailAddress = "*****@*****.**", Status = Enum_s.GuestRequestStatus.Open, RegistrationDate = DateTime.Now, EntryDate = DateTime.Now.AddDays(8), ReleaseDate = DateTime.Now.AddDays(15), Area = Enum_s.Areas.מרכז, SubArea = Enum_s.SubArea.תל_אביב, Type = Enum_s.HostingUnitTypes.דירה, Adults = 3, Children = 0, Pool = Enum_s.RequestOption.אפשרי, Jacuzzi = Enum_s.RequestOption.אפשרי, Garden = Enum_s.RequestOption.כן, ChildrenAttractions = Enum_s.RequestOption.לא }, new GuestRequest() { GuestRequestKey = 3, FirstName = "Eyal", LastName = "Rot", MailAddress = "*****@*****.**", Status = Enum_s.GuestRequestStatus.Open, RegistrationDate = DateTime.Now, EntryDate = DateTime.Now.AddDays(50), ReleaseDate = DateTime.Now.AddDays(60), Area = Enum_s.Areas.דרום, SubArea = Enum_s.SubArea.אילת, Type = Enum_s.HostingUnitTypes.מלון, Adults = 4, Children = 4, Pool = Enum_s.RequestOption.כן, Jacuzzi = Enum_s.RequestOption.כן, Garden = Enum_s.RequestOption.אפשרי, ChildrenAttractions = Enum_s.RequestOption.כן }, new GuestRequest() { GuestRequestKey = 4, FirstName = "Itay", LastName = "Mark", MailAddress = "*****@*****.**", Status = Enum_s.GuestRequestStatus.Open, RegistrationDate = DateTime.Now, EntryDate = DateTime.Now.AddDays(12), ReleaseDate = DateTime.Now.AddDays(19), Area = Enum_s.Areas.צפון, SubArea = Enum_s.SubArea.גליל, Type = Enum_s.HostingUnitTypes.בקתה, Adults = 2, Children = 0, Pool = Enum_s.RequestOption.לא, Jacuzzi = Enum_s.RequestOption.כן, Garden = Enum_s.RequestOption.לא, ChildrenAttractions = Enum_s.RequestOption.לא }, new GuestRequest() { GuestRequestKey = 5, FirstName = "Tomer", LastName = "Halpern", MailAddress = "*****@*****.**", Status = Enum_s.GuestRequestStatus.Open, RegistrationDate = DateTime.Now, EntryDate = DateTime.Now.AddDays(2), ReleaseDate = DateTime.Now.AddDays(7), Area = Enum_s.Areas.ירושלים, SubArea = Enum_s.SubArea.ירושלים, Type = Enum_s.HostingUnitTypes.מלון, Adults = 3, Children = 2, Pool = Enum_s.RequestOption.כן, Jacuzzi = Enum_s.RequestOption.כן, Garden = Enum_s.RequestOption.כן, ChildrenAttractions = Enum_s.RequestOption.כן } }; foreach (var item in guestRequestList) { try { bl.AddGuestRequest(item); } catch (Exception) { } } #endregion Console.WriteLine("All The Hosting Units:\n"); foreach (var item in HostingUnitList) { Console.WriteLine(item); } Console.WriteLine("All The Guest Request:\n"); foreach (var item in guestRequestList) { Console.WriteLine(item); } Console.WriteLine("All The Orders:\n"); Console.WriteLine("Hello User\nThis is Searching And Maching Vacation System.\n" + "Menu:\nA: Add Guest Request\nB: Add Hosting Unit\nC: Update Hosting Unit\n" + "D: Delete Hosting Unit\nE: Update Order Status\nF: Delete Order\nG: Show Hosting Units inventory" + "\nH: Show Guest Requests inventory\nI: Show Orders inventory\nJ: Show specific Order\nK: Show " + "specific hosting unit\nL: Show Expired Orders\nM: Show sum of orders for specific guest\nN: Sum" + "orders which sended or responded\nO: Show guest requests by areas\nP: Show guest requests by number" + "of adults\nQ: Show guest requests by number of children\nR: Show hosts by number og their hosting units" + "\nS: Show hosting units by areas\nX: Exit"); string choice, tmp; do { Console.Write("Please enter youe choice: "); choice = Console.ReadLine(); switch (choice) { case "A": GuestRequest newGuestRequest = addRequest(); try { bl.AddGuestRequest(newGuestRequest); Console.WriteLine("Your request received successfully! request ID is: " + newGuestRequest.GuestRequestKey.ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "B": HostingUnit newHostingUnit = addUnit(); try { bl.AddHostingUnit(newHostingUnit); Console.WriteLine("Your hosting unit received successfully! hosting unit ID is: " + newHostingUnit.HostingUnitKey.ToString() + " host ID is: " + newHostingUnit.Owner.HostKey.ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "C": Console.Write("Enter your hosting unit's ID: "); tmp = Console.ReadLine(); HostingUnit updateHostingUnit = addUnit(); updateHostingUnit.HostingUnitKey = long.Parse(tmp); try { updateHostingUnit.Owner.HostKey = bl.GetHostingUnitByKey(long.Parse(tmp)).Owner.HostKey; bl.UpdateHostingUnit(updateHostingUnit); Console.WriteLine("Hosting unit updates successfully!"); } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "D": Console.Write("Enter your hosting unit's ID for deleting: "); tmp = Console.ReadLine(); try { bl.DeleteHostingUnit(bl.GetHostingUnitByKey(long.Parse(tmp))); Console.WriteLine("Hosting unit deleted successfully!"); } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "E": Console.Write("Enter your host ID: "); tmp = Console.ReadLine(); Console.WriteLine("Here is the orders for your hosting units:"); List <Order> ordersForHost = bl.ReceiveOrdersForHost(long.Parse(tmp)); if (ordersForHost.Count != 0) { foreach (var item in ordersForHost) { Console.WriteLine(item); } Console.WriteLine("Enter the required order key which you wand to update it's status"); string orderKey = Console.ReadLine(); Console.WriteLine("Do you want to make a deal/ close order due to gest disinterest?" + " answer 1 - for making a deal, 2 - for closing order"); tmp = Console.ReadLine(); while (tmp != "1" && tmp != "2") { Console.WriteLine("Invalid answer, please enter correct answer."); tmp = Console.ReadLine(); } try { Order updateOrder = bl.GetOrderByKey(long.Parse(orderKey)); updateOrder.Status = tmp == "1" ? Enum_s.OrderStatus.נסגר_בשל_הענות : Enum_s.OrderStatus.נסגר_בשל_חוסר_הענות; bl.UpdateOrder(updateOrder); Console.WriteLine("Order status updates successfully!"); } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { Console.WriteLine("There are no orders for you."); } break; case "F": Console.Write("Enter order ID for cancelation: "); tmp = Console.ReadLine(); try { bl.DeleteOrder(bl.GetOrderByKey(long.Parse(tmp))); Console.WriteLine("Order canceled successfully!"); } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "G": Console.WriteLine("Hosting units inventory:"); foreach (var item in bl.ReceiveHostingUnitList()) { Console.WriteLine(item); } break; case "H": Console.WriteLine("Guest requests inventory:"); foreach (var item in bl.ReceiveGuestRequestList()) { Console.WriteLine(item); } break; case "I": Console.WriteLine("Orders inventory:"); foreach (var item in bl.ReceiveOrderList()) { Console.WriteLine(item); } break; case "J": Console.WriteLine("Enter required order ID: "); tmp = Console.ReadLine(); try { Console.WriteLine(bl.GetOrderByKey(long.Parse(tmp))); } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "K": Console.WriteLine("Enter required hosting unit ID: "); tmp = Console.ReadLine(); try { Console.WriteLine(bl.GetHostingUnitByKey(long.Parse(tmp))); } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "L": foreach (var item in bl.ExpiredOrders()) { Console.WriteLine(item); } break; case "M": Console.Write("Enter guest request ID: "); tmp = Console.ReadLine(); try { GuestRequest myGuestRequest = bl.GetGuestRequestByKey(long.Parse(tmp)); Console.WriteLine(bl.SumOrdersForGuest(myGuestRequest)); } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "N": Console.Write("Enter hosting unit ID: "); tmp = Console.ReadLine(); try { HostingUnit newHostingUnit1 = bl.GetHostingUnitByKey(long.Parse(tmp)); Console.WriteLine("Sum of responded or sended orders: " + bl.SumOrdersSendedOrResponded(newHostingUnit1, x => x.Status == Enum_s.OrderStatus.נשלח_מייל)); } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "O": foreach (var item in bl.GroupGuestRequestByAreas()) { Console.WriteLine(item.Key); foreach (var item2 in item) { Console.WriteLine(item2); } } break; case "P": foreach (var item in bl.GroupGuestRequestByNumberOfAdults()) { Console.WriteLine(item.Key); foreach (var item2 in item) { Console.WriteLine(item2); } } break; case "Q": foreach (var item in bl.GroupGuestRequestByNumberOfChildren()) { Console.WriteLine(item.Key); foreach (var item2 in item) { Console.WriteLine(item2); } } break; case "R": foreach (var item in bl.GroupHostByNumberOfHostingUnit()) { Console.WriteLine(item.Key); foreach (var item2 in item) { Console.WriteLine(item2); } } break; case "S": foreach (var item in bl.GroupHostingUnitByAreas()) { Console.WriteLine(item.Key); foreach (var item2 in item) { Console.WriteLine(item2); } } break; default: Console.WriteLine("Invalid choice."); break; } } while (choice != "X"); }