Ejemplo n.º 1
0
        private void Addbutton_Click(object sender, RoutedEventArgs e)
        {
            hostingUnit.Owner = host;
            hostingUnit.VacationProperties = vacProp;
            try
            {
                bl.AddHostingUnit(hostingUnit);
                MessageBox.Show(hostingUnit.HostingUnitName + " was added successfuly.");

                hostingUnit             = new HostingUnit();
                NewUnitGrid.DataContext = hostingUnit;
                vacProp = new VacationProperties();
                VcationPropertiesGrid.DataContext = vacProp;
            }
            catch (BlArgumentNullException)
            {
                MessageBox.Show("There was a problem. Please try again later.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (BlNoVacationeersException)
            {
                MessageBox.Show("Please add some vacationeers.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (BlPriceLowException)
            {
                MessageBox.Show("The price you chose is too low.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (BlNameTooShortException)
            {
                MessageBox.Show("The Name has to be at least 5 characters.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (BlNameAlreadyExistException)
            {
                MessageBox.Show("The Name already exist. Please try another name.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 2
0
        private void Add_Button_Click(object sender, RoutedEventArgs e)
        {
            HostingUnit hostingUnit = new HostingUnit();

            bL.SetHostingUnitKey(hostingUnit);
            hostingUnit.HostingUnitName     = hostingUnitNameTextBox.Text;
            hostingUnit.Owner               = currentHost;
            hostingUnit.area                = (Area)areaComboBox.SelectedItem;
            hostingUnit.jacuzzi             = (bool)jaccuziBox.IsChecked ? Jaccuzzi.Yes : Jaccuzzi.No;
            hostingUnit.pool                = (bool)poolBox.IsChecked ? Pool.Yes : Pool.No;
            hostingUnit.childrenAttractions = (bool)childrenAttractionBox.IsChecked ? ChildrensAttractions.Yes : ChildrensAttractions.No;
            hostingUnit.garden              = (bool)gardenBox.IsChecked ? Garden.Yes : Garden.No;
            hostingUnit.type                = (Type)HostingUnitTypeComboBox.SelectedItem;
            hostingUnit.NumOfAdults         = int.Parse(NumOfAdultsTextBox.Text);
            hostingUnit.NumOfChildren       = int.Parse(NumOfChildrenTextBox.Text);
            hostingUnit.City                = cityTextBox1.Text;
            hostingUnit.Street              = streetTextBox1.Text;
            hostingUnit.HouseNumber         = houseNumberTextBox1.Text;
            hostingUnit.PriceForAdult       = int.Parse(adultPrice.Text);
            hostingUnit.PriceForChild       = int.Parse(childPrice.Text);
            hostingUnit.Pictures            = new string[10];
            for (int i = 0; i < 10; i++)
            {
                var textBoxName = string.Format("pic{0}", i);
                var textBox     = (TextBox)this.FindName(textBoxName);
                hostingUnit.Pictures[i] = textBox.Text;
            }

            bL.AddHostingUnit(hostingUnit);
            MessageBox.Show($"You successfully saved the Hosting Unit!", "OK!", MessageBoxButton.OK, MessageBoxImage.Information);
            this.Close();
            new HostInterface(currentHost.MailAddress).ShowDialog();
        }
Ejemplo n.º 3
0
 private void AddHostingUnit_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         unit.Owner = host;
         myIbL.AddHostingUnit(unit);
         unit = new HostingUnit();
         AddUnitGrid.DataContext = unit;
     }
     catch (Exception)
     {
         MessageBox.Show("There Was a problem. Please try again soon", "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
 private void ButtonOk_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (TextBox_of_hostingunit_name != null)
         {
             My_HostUnit.HostingUnitName = TextBox_of_hostingunit_name.Text.ToString();
         }
         if (TextBox_price_Of_Night_To_Adult != null)
         {
             My_HostUnit.price_Of_Night_To_Adult = double.Parse(TextBox_price_Of_Night_To_Adult.Text);
         }
         if (TextBox_price_Of_Night_To_Child != null)
         {
             My_HostUnit.price_Of_Night_To_Child = double.Parse(TextBox_price_Of_Night_To_Child.Text);
         }
         if (ComboBox_of_Type.SelectedItem != null)
         {
             My_HostUnit.Type = CheckEnums.CheckType(ComboBox_of_Type.SelectionBoxItem.ToString());
         }
         if (TextBox_of_Adults != null)
         {
             My_HostUnit.Adults = int.Parse(TextBox_of_Adults.Text);
         }
         if (TextBox_of_children != null)
         {
             My_HostUnit.Children = int.Parse(TextBox_of_children.Text);
         }
         if (ComboBox_of_Area.SelectedItem != null)
         {
             My_HostUnit.Area = CheckEnums.CheckArea(ComboBox_of_Area.SelectionBoxItem.ToString());
         }
         if (TextBox_of_number_SubArea != null)
         {
             My_HostUnit.SubArea = TextBox_of_number_SubArea.Text.ToString();
         }
         if (ComboBox_of_pool.SelectedItem != null)
         {
             My_HostUnit.Pool = CheckEnums.CheckYes_Or_No(ComboBox_of_pool.SelectionBoxItem.ToString());
         }
         if (ComboBox_of_Jacuzzi.SelectedItem != null)
         {
             My_HostUnit.Jacuzzi = CheckEnums.CheckYes_Or_No(ComboBox_of_Jacuzzi.SelectionBoxItem.ToString());
         }
         if (ComboBox_of_Garden.SelectedItem != null)
         {
             My_HostUnit.Garden = CheckEnums.CheckYes_Or_No(ComboBox_of_Garden.SelectionBoxItem.ToString());
         }
         if (ComboBox_of_ChildrensAttractions.SelectedItem != null)
         {
             My_HostUnit.ChildrensAttractions = CheckEnums.CheckYes_Or_No(ComboBox_of_ChildrensAttractions.SelectionBoxItem.ToString());
         }
         My_HostUnit.Owner = host;
         bl.AddHostingUnit(My_HostUnit);
         MessageBox_Project x = new MessageBox_Project("!!מעולה ", "יחידת האירוח  נוספה בהצלחה ");
         x.ShowDialog();
         MyHostWindow a = new MyHostWindow(host);
         a.Show();
     }
     catch (ArgumentException exp)
     {
         MessageBox.Show(exp.Message);
     }
 }
        static void Main(string[] args)
        {
            Creator us = new Creator
            {
                Username        = "******",
                Password        = "******",
                TotalCommission = 0
            };
            Host sori = new Host
            {
                BankAccountNumber = 12345,
                BankBranchDetails = new BankBranch
                {
                    BankName      = "pagi",
                    BankNumber    = 12345,
                    BranchAddress = "kanfei",
                    BranchCity    = "harnof",
                    BranchNumber  = 455
                },
                CollectionClearance = true,
                FamilyName          = "teigman",
                HostKey             = 0537208407,
                MailAddress         = "*****@*****.**",
                PhoneNumber         = 0583215876,
                PrivateName         = "sori"
            };
            Host esti = new Host
            {
                BankAccountNumber = 12345,
                BankBranchDetails = new BankBranch
                {
                    BankName      = "pagi",
                    BankNumber    = 12345,
                    BranchAddress = "arielli",
                    BranchCity    = "beitar",
                    BranchNumber  = 992
                },
                CollectionClearance = true,
                FamilyName          = "burack",
                HostKey             = 315320945,
                MailAddress         = "*****@*****.**",
                PhoneNumber         = 0537208407,
                PrivateName         = "esther"
            };
            IBL          ibl = FactoryBL.getBL();
            GuestRequest gr  = new GuestRequest
            {
                PrivateName      = "wanted",
                FamilyName       = "dead or alive",
                RegistrationDate = Configuration.today,
                EntryDate        = new DateTime(2020, 7, 03),
                ReleaseDate      = new DateTime(2020, 7, 07),
                MailAddress      = "*****@*****.**",
                Type             = VacationType.Hotel,
                Adults           = 2,
                Children         = 3,
                Pet     = false,
                Area    = VacationArea.Center,
                SubArea = "beitar",
                ChildrensAttractions = Choices.Yes,
                FitnessCenter        = Choices.DontCare,
                Garden  = Choices.DontCare,
                Jacuzzi = Choices.Yes,
                Parking = Choices.Yes,
                Pool    = Choices.Yes,
                Stars   = StarRating.four_star,
                Status  = Status.Active,
                WiFi    = Choices.Yes
            };
            GuestRequest gr1 = new GuestRequest
            {
                PrivateName      = "wanted",
                FamilyName       = "dead or alive",
                RegistrationDate = Configuration.today,
                EntryDate        = new DateTime(2020, 8, 03),
                ReleaseDate      = new DateTime(2020, 8, 05),
                MailAddress      = "*****@*****.**",
                Type             = VacationType.Hotel,
                Adults           = 2,
                Children         = 3,
                Pet     = false,
                Area    = VacationArea.South,
                SubArea = "Herzliya",
                ChildrensAttractions = Choices.Yes,
                FitnessCenter        = Choices.DontCare,
                Garden  = Choices.DontCare,
                Jacuzzi = Choices.Yes,
                Parking = Choices.Yes,
                Pool    = Choices.Yes,
                Stars   = StarRating.four_star,
                Status  = Status.Active,
                WiFi    = Choices.Yes
            };
            GuestRequest gr2 = new GuestRequest
            {
                PrivateName      = "sori",
                FamilyName       = "teigman",
                RegistrationDate = Configuration.today,
                EntryDate        = new DateTime(2020, 9, 05),
                ReleaseDate      = new DateTime(2020, 9, 10),
                MailAddress      = "*****@*****.**",
                Type             = VacationType.BeachHouse,
                Adults           = 2,
                Children         = 1,
                Pet     = false,
                Area    = VacationArea.Jerusalem,
                SubArea = "Tiberias",
                ChildrensAttractions = Choices.No,
                FitnessCenter        = Choices.Yes,
                Garden  = Choices.No,
                Jacuzzi = Choices.Yes,
                Parking = Choices.Yes,
                Pool    = Choices.Yes,
                Stars   = StarRating.five_star,
                WiFi    = Choices.Yes
            };


            HostingUnit hu = new HostingUnit
            {
                HostingUnitName      = "sleep",
                Owner                = esti,
                Pet                  = false,
                Area                 = VacationArea.Center,
                SubArea              = "Tiberias",
                ChildrensAttractions = false,
                FitnessCenter        = true,
                Garden               = false,
                Jacuzzi              = true,
                Parking              = true,
                Pool                 = true,
                Stars                = StarRating.five_star,
                WiFi                 = true,
                Beds                 = 3,
                Type                 = VacationType.BeachHouse
            };
            HostingUnit hu1 = new HostingUnit
            {
                //HostingUnitKey = Configuration.HostingUnitKey_s++,
                HostingUnitName      = "Fanta Sea",
                Owner                = sori,
                Pet                  = false,
                Area                 = VacationArea.South,
                SubArea              = "Netanya",
                ChildrensAttractions = true,
                FitnessCenter        = false,
                Garden               = true,
                Jacuzzi              = true,
                Parking              = true,
                Pool                 = true,
                Stars                = StarRating.four_star,
                WiFi                 = true,
                Beds                 = 5,
                Type                 = VacationType.Hotel
            };
            HostingUnit hu2 = new HostingUnit
            {
                HostingUnitName = "Fixed",

                Owner   = sori,
                Pet     = false,
                Area    = VacationArea.North,
                SubArea = "Netanya",
                ChildrensAttractions = true,
                FitnessCenter        = false,
                Garden  = true,
                Jacuzzi = true,
                Parking = true,
                Pool    = true,
                Stars   = StarRating.four_star,
                WiFi    = true,
                Beds    = 5,
                Type    = VacationType.Hotel
            };

            try
            {
                ibl.addreq(gr);
                ibl.addreq(gr1);
                ibl.addreq(gr2);
                ibl.AddHostingUnit(hu);
                //hu.HostingUnitName = "fix";
                //ibl.UpdateHostingUnit(hu);
                ibl.AddHostingUnit(hu1);
                ibl.AddHostingUnit(hu2);
            }
            catch (Exception a)
            {
                Console.WriteLine(a.Message);
            }

            IEnumerable <GuestRequest> myRequests;
            //IEnumerable<IGrouping<int, HostingUnit>> myUnits = ibl.GroupHUByHosts();
            //foreach (IGrouping<int, HostingUnit> h in myUnits)
            //{
            //    foreach (HostingUnit hUnit in h)
            //    {
            //        myRequests = ibl.AllRequestsThatMatch(ibl.BuildPredicate(hUnit));
            //        foreach (GuestRequest item in myRequests)
            //        {
            //            try
            //            {
            //                ibl.AddOrder(ibl.CreateOrder(hUnit.HostingUnitKey, item.GuestRequestKey));
            //            }
            //            catch (Exception A)
            //            {
            //                Console.WriteLine(A.Message);
            //            }
            //        }
            //    }
            //}
            IEnumerable <Order> orders = ibl.GetsOpenOrders();
            //ibl.ChangeRequestStatus(orders.Last());
            IEnumerable <Order> orders2 = ibl.GetsOpenOrders();

            Console.WriteLine("\n");
            foreach (Order item in orders2)
            {
                Console.WriteLine(item);
                Console.WriteLine("\n");
            }

            ibl.TotalCommissionCalculator(us);
            Console.WriteLine(us.TotalCommission);
            //ibl.GroupByNumOfUnits();
            IEnumerable <HostingUnit> li = ibl.searchHUbyOwner(esti.HostKey);

            Console.WriteLine("hi\n");
            foreach (HostingUnit item in li)
            {
                Console.WriteLine(item);
                Console.WriteLine("\n");
            }
        }
Ejemplo n.º 6
0
        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            int  numberOfCommish;
            bool numVal = int.TryParse(commission1TextBox.Text, out numberOfCommish);

            try
            {
                unit.Owner1 = new BE.Host();
                unit.Owner1 = owner;
                if (hostingUnitNameTextBox.Text == "")
                {
                    MessageBox.Show("must enter a HostingUnit name!");
                    hostingUnitNameTextBox.Clear();
                    hostingUnitNameTextBox.Focus();
                }
                else if (commission1TextBox.Text == "" || numberOfCommish <= 0 || (numVal == false))
                {
                    MessageBox.Show("must enter HostingUnit Commision!");
                    commission1TextBox.Clear();
                    commission1TextBox.Focus();
                }
                else if (Area1.Text == "Please Select")
                {
                    MessageBox.Show("must enter HostingUnit Area!");
                    Area1.Focus();
                }
                else
                {
                    string selected1 = Area1.SelectedItem.ToString();
                    selected1 = selected1.Substring(selected1.IndexOf(' '));

                    if (selected1 == " North")
                    {
                        unit.AreaOfHostingUnit = BEEnum.Area.North;
                    }
                    else if (selected1 == " South")
                    {
                        unit.AreaOfHostingUnit = BEEnum.Area.South;
                    }
                    else if (selected1 == " Center")
                    {
                        unit.AreaOfHostingUnit = BEEnum.Area.Center;
                    }
                    else if (selected1 == " Jerusalem")
                    {
                        unit.AreaOfHostingUnit = BEEnum.Area.Jerusalem;
                    }

                    bl.AddHostingUnit(unit);
                    MessageBox.Show("Hosting Unit Added, Key:" + unit.HostingUnitKey1);
                    this.DataContext = unit;
                    Window HostingUnitWindow = new HostWindow(username);
                    HostingUnitWindow.Show();
                    this.Close();
                }
            }

            catch (FormatException)
            {
                MessageBox.Show("Please check your input and try again");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            //try
            //{
            IBL bl = FactoryBL.getBL();

            #region Hosting Unit
            HostingUnit h1 = new HostingUnit()
            {
                HostingUnitName      = "apple",
                Area                 = BE.Enum.Area.Center,
                Type                 = BE.Enum.ResortType.Hotel,
                Pool                 = BE.Enum.Pool.Necessary,
                Jacuzzi              = BE.Enum.Jacuzzi.NotInterested,
                Garden               = BE.Enum.Garden.NotInterested,
                ChildrensAttractions = BE.Enum.ChildrensAttractions.Necessary,
                Spooky               = BE.Enum.Spooky.ALittileBit,
                Owner                = new Host()
                {
                    HostKey             = "315206482",
                    PrivateName         = "dan",
                    FamilyName          = "cohen",
                    PhoneNumber         = (0543198488).ToString(),
                    MailAddress         = "*****@*****.**",
                    BankAccountNumber   = 118833,
                    CollectionClearance = true,
                    BankBranchDetails   = new BankBranch()
                    {
                        BankNumber    = ++Configuration.bankNumber,
                        BankName      = "hapoalim",
                        BranchNumber  = 18,
                        BranchAddress = "beit hadfus 78",
                        BranchCity    = "tlv"
                    }
                }
            };
            h1.Diary[4, 4] = true;
            h1.Diary[4, 5] = true;
            h1.Diary[4, 6] = true;

            HostingUnit h2 = new HostingUnit()
            {
                HostingUnitName      = "pear",
                Area                 = BE.Enum.Area.East,
                Type                 = BE.Enum.ResortType.Tzimer,
                Pool                 = BE.Enum.Pool.Necessary,
                Jacuzzi              = BE.Enum.Jacuzzi.NotInterested,
                Garden               = BE.Enum.Garden.Optional,
                ChildrensAttractions = BE.Enum.ChildrensAttractions.Necessary,
                Spooky               = BE.Enum.Spooky.ALittileBit,
                Owner                = new Host()
                {
                    HostKey             = "209387125",
                    PrivateName         = "yosi",
                    FamilyName          = "cohen",
                    PhoneNumber         = (0543198488).ToString(),
                    MailAddress         = "*****@*****.**",
                    BankAccountNumber   = 912233,
                    CollectionClearance = true,
                    BankBranchDetails   = new BankBranch()
                    {
                        BankNumber    = ++Configuration.bankNumber,
                        BankName      = "leumi",
                        BranchNumber  = 19,
                        BranchAddress = "beit hadfus 78",
                        BranchCity    = "tlv"
                    }
                }
            };
            h2.Diary[8, 4] = true;
            h2.Diary[8, 5] = true;
            h2.Diary[8, 6] = true;
            HostingUnit h3 = new HostingUnit()
            {
                HostingUnitName      = "orange",
                Area                 = BE.Enum.Area.Center,
                Type                 = BE.Enum.ResortType.Tent,
                Pool                 = BE.Enum.Pool.NotInterested,
                Jacuzzi              = BE.Enum.Jacuzzi.Optional,
                Garden               = BE.Enum.Garden.Necessary,
                ChildrensAttractions = BE.Enum.ChildrensAttractions.Necessary,
                Spooky               = BE.Enum.Spooky.ALittileBit,
                Owner                = new Host()
                {
                    HostKey             = "318336062",
                    PrivateName         = "ron",
                    FamilyName          = "cohen",
                    PhoneNumber         = (0543198488).ToString(),
                    MailAddress         = "*****@*****.**",
                    BankAccountNumber   = 141414,
                    CollectionClearance = true,
                    BankBranchDetails   = new BankBranch()
                    {
                        BankNumber    = ++Configuration.bankNumber,
                        BankName      = "leumi",
                        BranchNumber  = 14,
                        BranchAddress = "beit hadfus 78",
                        BranchCity    = "tlv"
                    }
                }
            };
            h3.Diary[4, 4] = true;
            h3.Diary[4, 5] = true;
            h3.Diary[4, 6] = true;
            HostingUnit h4 = new HostingUnit()
            {
                HostingUnitName      = "grape",
                Area                 = BE.Enum.Area.East,
                Type                 = BE.Enum.ResortType.Tent,
                Pool                 = BE.Enum.Pool.NotInterested,
                Jacuzzi              = BE.Enum.Jacuzzi.Optional,
                Garden               = BE.Enum.Garden.Necessary,
                ChildrensAttractions = BE.Enum.ChildrensAttractions.Necessary,
                Spooky               = BE.Enum.Spooky.ALittileBit,
                Owner                = new Host()
                {
                    HostKey             = "029567567",
                    PrivateName         = "yael shoshana",
                    FamilyName          = "chaya",
                    PhoneNumber         = (0543198488).ToString(),
                    MailAddress         = "*****@*****.**",
                    BankAccountNumber   = 112236,
                    CollectionClearance = true,
                    BankBranchDetails   = new BankBranch()
                    {
                        BankNumber    = ++Configuration.bankNumber,
                        BankName      = "leumi",
                        BranchNumber  = 16,
                        BranchAddress = "beit hadfus 78",
                        BranchCity    = "tlv"
                    }
                }
            };
            h4.Diary[2, 4] = true;
            h4.Diary[2, 5] = true;
            h4.Diary[2, 6] = true;

            HostingUnit h5 = new HostingUnit()
            {
                HostingUnitName      = "olive",
                Area                 = BE.Enum.Area.East,
                Type                 = BE.Enum.ResortType.Tent,
                Pool                 = BE.Enum.Pool.NotInterested,
                Jacuzzi              = BE.Enum.Jacuzzi.Optional,
                Garden               = BE.Enum.Garden.Necessary,
                ChildrensAttractions = BE.Enum.ChildrensAttractions.Necessary,
                Spooky               = BE.Enum.Spooky.ALittileBit,
                Owner                = new Host()
                {
                    HostKey             = "029567567",
                    PrivateName         = "yael shoshana",
                    FamilyName          = "chaya",
                    PhoneNumber         = (0543198488).ToString(),
                    MailAddress         = "*****@*****.**",
                    BankAccountNumber   = 112236,
                    CollectionClearance = true,
                    BankBranchDetails   = new BankBranch()
                    {
                        BankNumber    = ++Configuration.bankNumber,
                        BankName      = "leumi",
                        BranchNumber  = 16,
                        BranchAddress = "beit hadfus 78",
                        BranchCity    = "tlv"
                    }
                }
            };
            h5.Diary[2, 4] = true;
            h5.Diary[2, 5] = true;
            h5.Diary[2, 6] = true;

            bl.AddHostingUnit(h1);
            bl.AddHostingUnit(h2);
            bl.AddHostingUnit(h3);
            bl.AddHostingUnit(h4);
            bl.AddHostingUnit(h5);

            foreach (var item in bl.GetHostingUnitCopy())
            {
                Console.WriteLine("hosting unit: \n" + item + "\n");
            }
            h4.HostingUnitName = "banana";
            bl.UpdateHostingUnit(h4);
            foreach (var item in bl.GetHostingUnitCopy())
            {
                Console.WriteLine("Hosting Unit: \n" + item + "\n");
            }

            //Console.WriteLine("hosting unit group by area: \n");
            //var v = bl.GetAllHostingUnitsGroupByArea();
            //foreach (var item in v)
            //{
            //    Console.WriteLine(item.Key);
            //    foreach (var w in item)
            //        Console.WriteLine(w);
            //}

            DateTime temp = new DateTime(2020, 4, 4);
            //Console.WriteLine("get available days: \n");
            //var vd = bl.GetAvailableDays(temp, 2);
            //foreach(var item6 in vd)
            //{
            //    Console.WriteLine();
            //}
            var vd = bl.GetAvailableDays(temp, 2);
            int i  = 1;
            foreach (var item6 in vd)
            {
                Console.WriteLine("hosting unit #" + i + ": \n" + item6);
                i++;
            }

            //int i = 1;
            //foreach (var item in bl.GetHostingUnitCopy())
            //{

            //    Console.WriteLine("hosting unit #" +i+ ": \n" + bl.GetAvailableDays(temp, 2) + "\n");
            //    i++;
            //}
            #endregion

            #region Guest Request
            GuestRequest g1 = new GuestRequest()
            {
                PrivateName          = "yosi",
                FamilyName           = "cohen",
                MailAddress          = "*****@*****.**",
                Status               = BE.Enum.CustomerOrderStatus.Open,
                RegistrationDate     = new DateTime(2020, 1, 1),
                EntryDate            = new DateTime(2020, 4, 3),
                ReleaseDate          = new DateTime(2020, 4, 6),
                Area                 = BE.Enum.Area.Center,
                Type                 = BE.Enum.ResortType.Hotel,
                Adults               = 4,
                Children             = 5,
                Pool                 = BE.Enum.Pool.Necessary,
                Jacuzzi              = BE.Enum.Jacuzzi.NotInterested,
                Garden               = BE.Enum.Garden.NotInterested,
                ChildrensAttractions = BE.Enum.ChildrensAttractions.Necessary,
                GuestRequestKey      = ++Configuration.guestRequestKey,
                Spooky               = BE.Enum.Spooky.ALittileBit
            };

            GuestRequest g2 = new GuestRequest()
            {
                PrivateName          = "ron",
                FamilyName           = "cohen",
                MailAddress          = "*****@*****.**",
                Status               = BE.Enum.CustomerOrderStatus.Open,
                RegistrationDate     = new DateTime(2020, 1, 1),
                EntryDate            = new DateTime(2020, 3, 4),
                ReleaseDate          = new DateTime(2020, 3, 6),
                Area                 = BE.Enum.Area.East,
                Type                 = BE.Enum.ResortType.Tzimer,
                Adults               = 3,
                Children             = 2,
                Pool                 = BE.Enum.Pool.Necessary,
                Jacuzzi              = BE.Enum.Jacuzzi.NotInterested,
                Garden               = BE.Enum.Garden.Optional,
                ChildrensAttractions = BE.Enum.ChildrensAttractions.Necessary,
                GuestRequestKey      = ++Configuration.guestRequestKey,
                Spooky               = BE.Enum.Spooky.ALittileBit
            };

            GuestRequest g3 = new GuestRequest()
            {
                PrivateName          = "dan",
                FamilyName           = "cohen",
                MailAddress          = "*****@*****.**",
                Status               = BE.Enum.CustomerOrderStatus.Open,
                RegistrationDate     = new DateTime(2020, 1, 1),
                EntryDate            = new DateTime(2020, 4, 3),
                ReleaseDate          = new DateTime(2020, 4, 6),
                Area                 = BE.Enum.Area.Center,
                Type                 = BE.Enum.ResortType.Tent,
                Adults               = 3,
                Children             = 6,
                Pool                 = BE.Enum.Pool.NotInterested,
                Jacuzzi              = BE.Enum.Jacuzzi.Optional,
                Garden               = BE.Enum.Garden.Necessary,
                ChildrensAttractions = BE.Enum.ChildrensAttractions.Necessary,
                GuestRequestKey      = ++Configuration.guestRequestKey,
                Spooky               = BE.Enum.Spooky.ALittileBit,
            };


            GuestRequest g4 = new GuestRequest()
            {
                PrivateName          = "yahoo",
                FamilyName           = "cohen",
                MailAddress          = "*****@*****.**",
                Status               = BE.Enum.CustomerOrderStatus.Open,
                RegistrationDate     = new DateTime(2020, 1, 1),
                EntryDate            = new DateTime(2020, 2, 4),
                ReleaseDate          = new DateTime(2020, 2, 6),
                Area                 = BE.Enum.Area.East,
                Type                 = BE.Enum.ResortType.Tent,
                Adults               = 1,
                Children             = 4,
                Pool                 = BE.Enum.Pool.NotInterested,
                Jacuzzi              = BE.Enum.Jacuzzi.Optional,
                Garden               = BE.Enum.Garden.Necessary,
                ChildrensAttractions = BE.Enum.ChildrensAttractions.Necessary,
                GuestRequestKey      = ++Configuration.guestRequestKey,
                Spooky               = BE.Enum.Spooky.ALittileBit
            };
            bl.AddGuestRequest(g1);
            bl.AddGuestRequest(g2);
            bl.AddGuestRequest(g3);
            bl.AddGuestRequest(g4);
            foreach (var item in bl.GetGuests())
            {
                Console.WriteLine("hosting unit: \n" + item + "\n");
            }

            g2.FamilyName = "Levi";
            bl.UpdateGuestRequest(g2);

            Console.WriteLine("Hosting Unit after changes: ");
            foreach (var item in bl.GetGuests())
            {
                Console.WriteLine("hosting unit: \n" + item + "\n");
            }


            Console.WriteLine("groups by amount of people: \n");
            var r = bl.GetAllGuestsRequestsGropuByAmountOfPeople();
            foreach (var item in r)
            {
                Console.WriteLine(item.Key);
                foreach (var w in item)
                {
                    Console.WriteLine(w);
                }
            }

            Console.WriteLine("groups by area: \n");
            var b = bl.GetsAllGuestRequestsGroupsByArea();
            foreach (var item in b)
            {
                Console.WriteLine(item.Key);
                foreach (var w in item)
                {
                    Console.WriteLine(w);
                }
            }

            #endregion

            #region Order

            Order o1 = new Order()
            {
                Status          = BE.Enum.OrderStatus.NotYetAddressed,
                CreateDate      = new DateTime(2019, 2, 1),
                OrderDate       = new DateTime(2020, 4, 4),
                HostingUnitKey  = h1.HostingUnitKey,
                GuestRequestKey = g2.GuestRequestKey
            };

            Order o2 = new Order()
            {
                Status          = BE.Enum.OrderStatus.NotYetAddressed,
                CreateDate      = new DateTime(2019, 4, 1),
                OrderDate       = new DateTime(2020, 3, 4),
                HostingUnitKey  = h2.HostingUnitKey,
                GuestRequestKey = g1.GuestRequestKey
            };

            Order o3 = new Order()
            {
                Status          = BE.Enum.OrderStatus.NotYetAddressed,
                CreateDate      = new DateTime(2019, 4, 1),
                OrderDate       = new DateTime(2020, 4, 4),
                HostingUnitKey  = h3.HostingUnitKey,
                GuestRequestKey = g4.GuestRequestKey
            };

            Order o4 = new Order()
            {
                Status          = BE.Enum.OrderStatus.NotYetAddressed,
                CreateDate      = new DateTime(2019, 2, 2),
                OrderDate       = new DateTime(2020, 2, 4),
                HostingUnitKey  = h4.HostingUnitKey,
                GuestRequestKey = g3.GuestRequestKey
            };

            Order o5 = new Order()
            {
                Status          = BE.Enum.OrderStatus.NotYetAddressed,
                CreateDate      = new DateTime(2019, 6, 1),
                OrderDate       = new DateTime(2020, 6, 3),
                HostingUnitKey  = h1.HostingUnitKey,
                GuestRequestKey = g2.GuestRequestKey
            };

            bl.AddOrder(o1);
            bl.AddOrder(o2);
            bl.AddOrder(o3);
            bl.AddOrder(o4);
            bl.AddOrder(o5);


            foreach (var item0 in bl.GetOrders())
            {
                Console.WriteLine("Order: \n" + item0 + "\n");
            }

            bl.RemoveHostingUnit(h5.HostingUnitKey);

            Console.WriteLine("after removing: ");
            foreach (var item1 in bl.GetHostingUnitCopy())
            {
                Console.WriteLine("Hosting Unit: \n" + item1 + "\n");
            }
            Console.WriteLine("amount of finalize: " + bl.AmountOfFinalizedOrders(h2));


            Console.WriteLine("amount of invetation: \n" + bl.AmountOfInvetations(g1));

            bl.UpdateOrder(o1);
            bl.UpdateOrder(o2);

            Console.WriteLine("after updating: \n");
            foreach (var item2 in bl.GetOrders())
            {
                Console.WriteLine("Order: \n" + item2 + "\n");
            }

            Console.WriteLine("amount of orders: ");
            foreach (var item7 in bl.AmountOfOrders(4))
            {
                Console.WriteLine("order: " + item7 + "\n");
            }

            #endregion

            foreach (var item3 in bl.GetBankBranches())
            {
                Console.WriteLine("Branch: " + item3);
            }

            DateTime d1 = new DateTime(2019, 3, 3);
            DateTime d2 = new DateTime(2019, 3, 10);
            Console.WriteLine("amount of days between 2 given days: " + bl.AmountOfDaysBetween(d1, d2));
            Console.WriteLine("amount of days between given day and today: " + bl.AmountOfDaysBetween(d2));
            Console.WriteLine("hosting units grouped by hosts");
            var l = bl.GetAllHostsGruopByAmountOfHostingUnits();
            foreach (var item4 in l)
            {
                Console.WriteLine(item4.Key);
                foreach (var w in item4)
                {
                    Console.WriteLine(w);
                }
            }


            foreach (var item5 in bl.CustomerDemands(x => x.Area == g1.Area))
            {
                Console.WriteLine("demands: \n" + item5);
            }

            Console.WriteLine("bye bye :P");
            Console.ReadKey();
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            IBL bl = FactoryBL.getIBL();

            #region gs
            GuestRequest guesty  = new GuestRequest();
            GuestRequest guesty1 = new GuestRequest();
            GuestRequest guesty2 = new GuestRequest();

            guesty.EntryDate1   = new DateTime(2020, 7, 7);
            guesty.ReleaseDate1 = new DateTime(2020, 7, 15);
            guesty.PrivateName1 = "moshe";
            guesty.Children1    = 5;

            guesty1.EntryDate1   = new DateTime(2020, 5, 7);
            guesty1.ReleaseDate1 = new DateTime(2020, 7, 23);
            guesty1.PrivateName1 = "binyamin";
            guesty1.Children1    = 5;

            guesty2.EntryDate1   = new DateTime(2020, 5, 7);
            guesty2.ReleaseDate1 = new DateTime(2020, 6, 15);
            guesty2.PrivateName1 = "dovid";
            guesty2.Children1    = 5;

            try
            {
                bl.AddGuestRequest(guesty);
                bl.AddGuestRequest(guesty1);
                bl.AddGuestRequest(guesty2);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            guesty.area1        = BEEnum.Area.Center;
            guesty.Children1    = 3;
            guesty.PrivateName1 = "notmoshe";

            try
            {
                bl.UpdateGuestRequest(guesty);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            try
            {
                bl.DeleteGuestRequest(guesty1);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            try
            {
                Console.WriteLine("_________________________________________________________________________\n" +
                                  " All Guest Requests:");
                foreach (GuestRequest i in bl.GetAllGuestRequest())
                {
                    Console.WriteLine(i);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            #endregion
            #region hosting unit tests
            HostingUnit unit1 = new HostingUnit();
            HostingUnit unit2 = new HostingUnit();
            HostingUnit unit3 = new HostingUnit();
            HostingUnit unit5 = new HostingUnit();
            unit1.AreaOfHostingUnit        = BEEnum.Area.All;
            unit2.AreaOfHostingUnit        = BEEnum.Area.Center;
            unit3.AreaOfHostingUnit        = BEEnum.Area.North;
            unit1.hasChildrensAttractions1 = true;
            unit2.hasJaccuzzi1             = true;
            unit3.hasPool1     = true;
            unit5.hasGarden1   = true;
            unit5.hasJaccuzzi1 = true;
            Host parp = new Host();
            parp.PrivateName1 = "mcawesome";
            parp.FamilyName1  = "village";
            //bl.AddHost(parp);
            unit1.Owner1 = parp;
            unit2.Owner1 = new Host();
            unit3.Owner1 = parp;
            unit5.Owner1 = parp;

            try//test for  adding hosting units
            {
                bl.AddHostingUnit(unit1);
                bl.AddHostingUnit(unit2);
                bl.AddHostingUnit(unit3);
                bl.AddHostingUnit(unit5);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            try//test for getAllHostingUnits after adding
            {
                Console.WriteLine(" _________________________________________________________________________\n All Hosting Units:");
                foreach (var item in bl.GetAllHostingUnits())
                {
                    Console.WriteLine(item.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }
            unit1.HostingUnitName1 = "zimmer";
            unit2.hasPool1         = true;
            unit3.HostingUnitName1 = "jimmering";
            try//test to make sure the original didnt changewithout update
            {
                Console.WriteLine(" _________________________________________________________________________\n All Hosting Units:");
                foreach (var item in bl.GetAllHostingUnits())
                {
                    Console.WriteLine(item.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }
            try//test to make sure update works
            {
                bl.UpdateHostingUnit(unit1);
                bl.UpdateHostingUnit(unit2);
                bl.UpdateHostingUnit(unit3);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }
            try//printing out to see if update works
            {
                Console.WriteLine(" _________________________________________________________________________\n All Hosting Units:");
                foreach (var item in bl.GetAllHostingUnits())
                {
                    Console.WriteLine(item.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }
            try//tets for delete hosting unit
            {
                bl.DeleteHostingUnit(unit2);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            try//printing to see if deleted one was printed
            {
                Console.WriteLine(" _________________________________________________________________________\n All Hosting Units:");
                foreach (var item in bl.GetAllHostingUnits())
                {
                    Console.WriteLine(item.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }
            HostingUnit unit4 = new HostingUnit();
            unit4.AreaOfHostingUnit = BEEnum.Area.Jerusalem;
            unit4.Owner1            = new Host();
            bl.AddHostingUnit(unit4);
            try//basic test for grouping, may be cn=hanged
            {
                Console.WriteLine(" _________________________________________________________________________\n Areas that exist in the hosting units");

                foreach (var item in bl.GroupByAreaOfHostingUnit())
                {
                    Console.WriteLine(item.Key.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }
            try//test for calcnumofhosts, using parp which is in two seperate hosting units , set higher inthe code
            {
                Console.WriteLine(" _________________________________________________________________________\n Test for number of hosting units in one host");

                bl.CalcNumOfHostingUnits();
                foreach (var item in bl.GetAllHosts())
                {
                    Console.WriteLine(item.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }
            try// test for the function all units with attractions
            {
                Console.WriteLine("_________________________________________________________________________\n All units with children attractions:");
                foreach (var item in bl.allUnitsWithchildrensattractions())
                {
                    Console.WriteLine(item.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }

            try// test for the function all units with pools
            {
                Console.WriteLine("_________________________________________________________________________\n All units with Pools:");
                foreach (var item in bl.allUnitsWithPools())
                {
                    Console.WriteLine(item.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }

            try// test for the function all units with Gardens
            {
                Console.WriteLine("_________________________________________________________________________\n All units with Gardnes:");
                foreach (var item in bl.allUnitsWithGardens())
                {
                    Console.WriteLine(item.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }

            try// test for the function all units with Jacccuzzis
            {
                Console.WriteLine("_________________________________________________________________________\n All units with jaccuzzi:");
                foreach (var item in bl.allUnitsWithJaccuzzis())
                {
                    Console.WriteLine(item.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }
            #endregion
            Order order1 = new Order();
            Order order2 = new Order();
            Order order3 = new Order();
            order1.GuestRequestKey1 = guesty.GuestRequestKey1;
            order1.HostingUnitKey1  = unit1.HostingUnitKey1;
            order2.GuestRequestKey1 = guesty.GuestRequestKey1;
            order2.HostingUnitKey1  = unit3.HostingUnitKey1;
            order3.GuestRequestKey1 = guesty.GuestRequestKey1;
            order3.HostingUnitKey1  = unit4.HostingUnitKey1;

            try
            {
                bl.AddOrder(order1);
                bl.AddOrder(order2);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }
            try
            {
                Console.WriteLine(" _________________________________________________________________________\n All Orders :");

                foreach (var item in bl.GetAllOrders())
                {
                    Console.WriteLine(item.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }
            order1.Status1 = BEEnum.Status.mailSent;
            unit1.Owner1.CollectionClearance1 = true;
            order2.Status1 = BEEnum.Status.dealMade;
            try
            {
                bl.UpdateOrder(order1);
                bl.UpdateOrder(order2);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }
            try
            {
                Console.WriteLine(" _________________________________________________________________________\n All Orders :");

                foreach (var item in bl.GetAllOrders())
                {
                    Console.WriteLine(item.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }
            try
            {
                Console.WriteLine(" _________________________________________________________________________\n All Orders older than x :");

                foreach (var item in bl.OlderOrders(0))
                {
                    Console.WriteLine(item.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            try
            {
                Console.WriteLine(" _________________________________________________________________________");

                Console.WriteLine("number of orders sent to this guest suggestion: " + bl.GuestOrderSuggestions(guesty));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);;
            }
            try
            {
                Console.WriteLine(" _________________________________________________________________________\n All the Banks :");

                foreach (var item in bl.GetAllBanks())
                {
                    Console.WriteLine(item.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.ReadKey();
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            IBL BL1 = FactoryBL.getBL();

            //example1  of HostingUnit
            HostingUnit h1 = new HostingUnit();

            h1.HostingUnitKey    = ++Configuration.HostingUnitKeySeq;
            h1.Owner.HostKey     = 00000002;
            h1.Owner.PrivateName = "יוסי";
            h1.Owner.FamilyName  = "כהן";
            h1.Owner.PhoneNumber = 0509876543;
            h1.Owner.MailAddress = "*****@*****.**";
            h1.Owner.BankBranchDetails.BankNumber    = 12;
            h1.Owner.BankBranchDetails.BankName      = "הפועלים";
            h1.Owner.BankBranchDetails.BranchNumber  = 78;
            h1.Owner.BankBranchDetails.BranchAddress = " יפו 67";
            h1.Owner.BankBranchDetails.BranchCity    = " תל-אביב";
            h1.Owner.BankAccountNumber   = 166685;
            h1.Owner.CollectionClearance = true;
            h1.HostingUnitName           = "נוף הגליל";
            h1.Adults               = 9;
            h1.Area                 = Areas.Center;
            h1.Children             = 6;
            h1.ChildrensAttractions = true;
            h1.Garden               = false;
            h1.Jacuzzi              = false;
            h1.Pool                 = true;
            h1.Type                 = Type_Unit.Zimmer;
            h1.Diary                = new bool[12, 31];

            //example2  of HostingUnit
            HostingUnit h2 = new HostingUnit();

            h2.HostingUnitKey    = ++Configuration.HostingUnitKeySeq;
            h2.Owner.HostKey     = 00000002;
            h2.Owner.PrivateName = "עופר";
            h2.Owner.FamilyName  = "לוי";
            h2.Owner.PhoneNumber = 0509876543;
            h2.Owner.MailAddress = "*****@*****.**";
            h2.Owner.BankBranchDetails.BankNumber    = 11;
            h2.Owner.BankBranchDetails.BankName      = "דיסקונט";
            h2.Owner.BankBranchDetails.BranchNumber  = 78;
            h2.Owner.BankBranchDetails.BranchAddress = " שמואל הנביא 25";
            h2.Owner.BankBranchDetails.BranchCity    = " ירושלים";
            h2.Owner.BankAccountNumber   = 166685;
            h2.Owner.CollectionClearance = true;
            h2.HostingUnitName           = "קראון הוטל";
            h2.Adults               = 2;
            h2.Area                 = Areas.Jerusalem;
            h2.Children             = 2;
            h2.ChildrensAttractions = false;
            h2.Garden               = true;
            h2.Jacuzzi              = true;
            h2.Pool                 = true;
            h2.Type                 = Type_Unit.HotelRoom;
            h2.Diary                = new bool[12, 31];

            //example1  of GuestRequest
            GuestRequest g1 = new GuestRequest();

            g1.GuestRequestKey      = ++Configuration.guestRequestKeySeq;
            g1.PrivateName          = "נועה";
            g1.FamilyName           = "חלפון";
            g1.MailAddress          = "*****@*****.**";
            g1.StatusRequest        = Request_Status.Active;
            g1.RegistrationDate     = DateTime.Now;
            g1.EntryDate            = new DateTime(2020, 2, 8);
            g1.ReleaseDate          = new DateTime(2020, 2, 10);
            g1.Area                 = Areas.Jerusalem;
            g1.SubArea              = Request_SubArea.Jerusalem;
            g1.Type                 = Type_Unit.HotelRoom;
            g1.Adults               = 2;
            g1.Children             = 2;
            g1.Pool                 = Option.Possible;
            g1.Jacuzzi              = Option.Not_interested;
            g1.Garden               = Option.Not_interested;
            g1.ChildrensAttractions = Option.Possible;

            //example1  of GuestRequest
            GuestRequest g2 = new GuestRequest();

            g2.GuestRequestKey      = ++Configuration.guestRequestKeySeq;
            g2.PrivateName          = "יעל";
            g2.FamilyName           = "גולד";
            g2.MailAddress          = "*****@*****.**";
            g2.StatusRequest        = Request_Status.Active;
            g2.RegistrationDate     = DateTime.Now;
            g2.EntryDate            = new DateTime(2020, 2, 4);
            g2.ReleaseDate          = new DateTime(2020, 2, 8);
            g2.Area                 = Areas.North;
            g2.SubArea              = Request_SubArea.Hermon;
            g2.Type                 = Type_Unit.HostingUnit;
            g2.Adults               = 3;
            g2.Children             = 4;
            g2.Pool                 = Option.Necessary;
            g2.Jacuzzi              = Option.Not_interested;
            g2.Garden               = Option.Possible;
            g2.ChildrensAttractions = Option.Necessary;

            //example3  of GuestRequest
            GuestRequest g3 = new GuestRequest();

            g3.GuestRequestKey      = ++Configuration.guestRequestKeySeq;
            g3.PrivateName          = "שירה";
            g3.FamilyName           = "הדר";
            g3.MailAddress          = "*****@*****.**";
            g3.StatusRequest        = Request_Status.Active;
            g3.RegistrationDate     = DateTime.Now;
            g3.EntryDate            = new DateTime(2020, 3, 5);
            g3.ReleaseDate          = new DateTime(2020, 3, 6);
            g3.Area                 = Areas.Center;
            g3.SubArea              = Request_SubArea.Tel_Aviv;
            g3.Type                 = Type_Unit.Zimmer;
            g3.Adults               = 2;
            g3.Children             = 5;
            g3.Pool                 = Option.Possible;
            g3.Jacuzzi              = Option.Not_interested;
            g3.Garden               = Option.Necessary;
            g3.ChildrensAttractions = Option.Not_interested;
            g3.ChildrensAttractions = Option.Not_interested;

            //1
            Console.WriteLine("Add ClientRequest:");
            try
            {
                BL1.AddClientRequest(g1);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            //2
            try
            {
                BL1.AddClientRequest(g2);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            //3
            try
            {
                BL1.AddClientRequest(g3);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            //הוספת יחידות אירוח ------------------------------
            //1
            Console.WriteLine("\nAdd HostingUnit:");
            try
            {
                BL1.AddHostingUnit(h1);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            //2
            try
            {
                BL1.AddHostingUnit(h2);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            //הוספת הזמנה---------------------------------
            foreach (var item in BL1.Lorder().ToList())
            {
                BL1.AddOrder(item);
            }
            //הדפסת הרשימות-----------------------------------
            Console.WriteLine("\nGuestRequestList: \n");
            foreach (var item in BL1.LGrequest())
            {
                Console.WriteLine(item);
                // Console.WriteLine("  \n   ");
            }
            Console.WriteLine("HostingUnitsList: \n");
            foreach (var item in BL1.Lunit())
            {
                Console.WriteLine(item);
                // Console.WriteLine("  \n   ");
            }
            Console.WriteLine("BankBranchList: \n");
            foreach (var item in BL1.Lbank())
            {
                Console.WriteLine(item);
                Console.WriteLine("  \n   ");
            }
            Console.WriteLine("OrderList: \n");
            foreach (var item in BL1.Lorder())
            {
                Console.WriteLine(item);
                Console.WriteLine("  \n   ");
            }
            //שליחת מיילים-----------------------

            foreach (var item in BL1.Lorder().ToList())
            {
                try
                {
                    // BL1.UpdateOrder(item);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    //  Console.WriteLine("  \n  ");
                }
            }
            //עדכון יחידה------------------------------
            h1.Adults++;
            try
            {
                BL1.UpdateHostingUnit(h1);
                // Console.WriteLine("  \n  ");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                //  Console.WriteLine("  \n  ");
            }
        }
        static void Main(string[] args)
        {
            IBL          bl = BLImp.getBL();
            GuestRequest gr = new GuestRequest
            {
                Adults               = 2,
                Area                 = Enums.Area.Jerusalem,
                Children             = 2,
                ChildrensAttractions = Enums.IsInterested.Uninterested,
                EntryDate            = new DateTime(2019, 5, 2),
                FamilyName           = "Ben Komay",
                Garden               = Enums.IsInterested.Necessary,
                Jacuzzi              = Enums.IsInterested.Necessary,
                MailAddress          = "*****@*****.**",
                Pool                 = Enums.IsInterested.Possible,
                PrivateName          = "Ellen",
                RegistrationDate     = new DateTime(2019, 1, 12),
                ReleaseDate          = new DateTime(2019, 7, 30),
                Status               = Enums.RequestStatus.Open,
                Type                 = Enums.HostingUnitType.Hotel
            };

            bl.AddGuestRequest(gr);

            HostingUnit hu = new HostingUnit
            {
                Area                        = Enums.Area.North,
                HostingUnitName             = "Black Nose World",
                Diary                       = null,
                IsThereChildrensAttractions = false,
                IsThereGarden               = true,
                IsThereJacuzzi              = true,
                IsTherePool                 = true,
                NumberOfPlacesForAdults     = 4,
                NumberOfPlacesForChildren   = 1,
                Type                        = Enums.HostingUnitType.Zimmer
            };
            Host schnorer = new Host
            {
                BankAccountNumber = 5000,
                BankBranchDetails = new BankBranch
                {
                    BankAccountNumber = 10000,
                    BankName          = "Mizrachi",
                    BankNumber        = 100,
                    BranchAddress     = "31 Maple St.",
                    BranchCity        = "Police",
                    BranchNumber      = 1221
                },
                CollectionClearance = true,
                FamilyName          = "Slaggish",
                HostKey             = 31262,
                MailAddress         = "*****@*****.**",
                PhoneNumber         = "12015684586",
                PrivateName         = "Schnorer",
            };

            hu.Owner = schnorer;
            try
            {
                bl.AddHostingUnit(hu);
            }
            catch (AlreadyExistsException e)
            {
                Console.WriteLine(e.Message);
            }

            HostingUnit hu2 = new HostingUnit()
            {
                Area                        = Enums.Area.Jerusalem,
                HostingUnitName             = "Black Falcon",
                IsThereChildrensAttractions = false,
                IsThereGarden               = true,
                IsThereJacuzzi              = true,
                IsTherePool                 = true,
                NumberOfPlacesForAdults     = 3,
                NumberOfPlacesForChildren   = 2,
                Owner                       = schnorer,
                Type                        = Enums.HostingUnitType.Hotel
            };

            try
            {
                bl.AddHostingUnit(hu2);
            }
            catch (AlreadyExistsException e)
            {
                Console.WriteLine(e.Message);
            }

            Order o = new Order()
            {
                CreateDate      = new DateTime(2019, 2, 25),
                GuestRequestKey = gr.GuestRequestKey,
                HostingUnitKey  = hu2.HostingUnitKey,
                OrderDate       = new DateTime(2019, 4, 2),
                Status          = Enums.OrderStatus.UnTreated
            };

            try
            {
                bl.AddOrder(o);
            }
            catch (AlreadyExistsException e)
            {
                Console.WriteLine(e.Message);
            }

            // Now let's make it fail

            try
            {
                bl.AddOrder(o);
            } w
            catch (AlreadyExistsException e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("available hostingunits:");

            try
            {
                foreach (var i in bl.GetAllAvailableHostingUnit(new DateTime(2019, 3, 2), 60))
                {
                    Console.WriteLine(i);
                }
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("guestrequests requiring a pool:");
            foreach (var i in bl.GetAllGuestRequestWhere(isGuestRequestWithPool))
            {
                Console.WriteLine(i);
            }

            Console.WriteLine("all bank accounts:");

            try
            {
                foreach (var i in bl.GetAllBankAccounts())
                {
                    Console.WriteLine(i);
                }
            }
            catch (NoItemsException e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("Amount of orders to the guest:");

            try
            {
                Console.WriteLine(bl.GetAmountOfOrderToGuest(gr.GuestRequestKey));
            }
            catch (NoItemsException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 11
0
        private void done_Click(object sender, RoutedEventArgs e) //creates a hosting unit out of the owners info
        {
            IBL _bl = BL.FactoryBL.getBL();                       //creates an instance of bl
            int temp;

            bool flag       = true;
            bool email_flag = true;

            try
            {
                email_flag = _bl.IsValidEmail(Email.Text);
            }
            catch// (Exception a)
            {
                Email.Clear();
                Email.Text        = "Enter Your Email Address";
                Email.BorderBrush = Brushes.Red;
                flag       = false;
                email_flag = false;
            }

            if (BankInfoTabUserControl.DataGrid.SelectedItem == null)
            {
                //if equals null
                flag = false;
            }

            if (ID.Text == "Enter Your ID")
            {
                flag           = false;
                ID.BorderBrush = Brushes.Red;
            }
            else if (!Int32.TryParse(ID.Text, out temp))
            {
                flag           = false;
                ID.BorderBrush = Brushes.Red;
            }

            if (Fname.Text == "Enter Your First Name")
            {
                flag = false;
                Fname.BorderBrush = Brushes.Red;
            }

            if (Lname.Text == "Enter Your Last Name")
            {
                flag = false;
                Lname.BorderBrush = Brushes.Red;
            }

            if (HUname.Text == "Give Your Property a Name")
            {
                flag = false;
                HUname.BorderBrush = Brushes.Red;
            }


            if (cbSubArea.SelectedValue == null)
            {
                flag = false;
                cbSubArea.Foreground = Brushes.Red;
            }


            if (cbArea.SelectedValue == null)
            {
                flag = false;
                cbArea.Foreground = Brushes.Red;
            }


            if (Beds.Text == "Amount of Beds Your Property has")
            {
                flag             = false;
                Beds.BorderBrush = Brushes.Red;
            }
            else if (!Int32.TryParse(Beds.Text, out temp))
            {
                flag             = false;
                Beds.BorderBrush = Brushes.Red;
            }

            if (Phonenum.Text == "Enter Your Phone Number")
            {
                flag = false;
                Phonenum.BorderBrush = Brushes.Red;
            }
            else if (!Int32.TryParse(Phonenum.Text, out temp))
            {
                flag = false;
                Phonenum.BorderBrush = Brushes.Red;
            }

            if (BankAcctNum.Text == "Enter Your Bank Account Number")
            {
                flag = false;
                BankAcctNum.BorderBrush = Brushes.Red;
            }
            else if (!Int32.TryParse(BankAcctNum.Text, out temp))
            {
                flag = false;
                BankAcctNum.BorderBrush = Brushes.Red;
            }

            if (cbType.SelectedValue == null)
            {
                flag = false;
                cbType.Foreground = Brushes.Red;
            }

            if (lblRating.Text.ToString() == "0")
            {
                flag = false;
                errorStars.Visibility = Visibility.Visible;
            }
            else
            {
                errorStars.Visibility = Visibility.Hidden;
            }


            if (flag)
            {
                HostingUnit hu = new HostingUnit();
                Host        h  = new Host();
                BankBranch  b  = (BankBranch)BankInfoTabUserControl.DataGrid.SelectedItem;

                h.HostKey             = Convert.ToInt32(ID.Text);
                h.PrivateName         = Fname.Text;
                h.FamilyName          = Lname.Text;
                h.PhoneNumber         = Convert.ToInt32(Phonenum.Text);
                h.MailAddress         = Email.Text;
                h.BankBranchDetails   = b;
                h.CollectionClearance = (bool)CollectionClearance.IsChecked;
                h.BankAccountNumber   = Convert.ToInt32(BankAcctNum.Text);

                hu.HostingUnitName      = HUname.Text;
                hu.Owner                = h;
                hu.Area                 = (VacationArea)Enum.Parse(typeof(VacationArea), cbArea.SelectedValue.ToString(), true);
                hu.SubArea              = cbSubArea.SelectedValue.ToString();
                hu.Type                 = (VacationType)Enum.Parse(typeof(VacationType), cbType.SelectedValue.ToString(), true);
                hu.Beds                 = Convert.ToInt32(Beds.Text);
                hu.Pet                  = (bool)Pets.IsChecked;
                hu.WiFi                 = (bool)Wifi.IsChecked;
                hu.Parking              = (bool)Parking.IsChecked;
                hu.Pool                 = (bool)Pool.IsChecked;
                hu.Jacuzzi              = (bool)Jacuzzi.IsChecked;
                hu.Garden               = (bool)Garden.IsChecked;
                hu.ChildrensAttractions = (bool)chiAttract.IsChecked;
                hu.FitnessCenter        = (bool)FitnessCenter.IsChecked;
                hu.Stars                = (StarRating)Enum.Parse(typeof(StarRating), lblRating.Text.ToString(), true);
                try
                {
                    _bl.AddHostingUnit(hu);
                    MessageBox.Show("Here is your new property key code. Please save for future reference.\n Your Key: " + hu.HostingUnitKey, "Important Information", MessageBoxButton.OK, MessageBoxImage.Information);
                    this.NavigationService.Navigate(new MainPage());
                }
                catch (Exception a)
                {
                    MessageBox.Show(a.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Missing important information, please fill everything out to continue.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }