예제 #1
0
 public HostingUnit GetGuestRequest_RrtrunHostingUnit(GuestRequest g)
 {
     foreach (var item in Dal_XML_imp.GetHostingUnitFromXml())
     {
         if (g.Adults == item.Adults && g.Area == item.Area && g.Children == item.Children &&
             g.ChildrensAttractions == item.ChildrensAttractions && g.Pool == item.Pool &&
             g.Jacuzzi == item.Jacuzzi && g.Garden == item.Garden && g.SubArea == item.SubArea &&
             g.Type == item.Type)
         {
             if (one_of_available_units(g.EntryDate, (g.ReleaseDate - g.EntryDate).Days) != null)
             {
                 return(item);
             }
             else
             {
                 throw new NotImplementedException("התאריכים שבחרת תפוסים אנא בחר תאריכים אחרים ");
             }
         }
         else
         {
             throw new NotImplementedException("אין יחידת אירוח שמתאימה לדרישה המבוקשת");
         }
     }
     return(null); //לא נימצאה יחידת אירוח שתואמת לדרישות של הלקוח
 }
예제 #2
0
        /// <summary>
        /// add test to the xml file of test in test path. only new test without grade and result
        /// </summary>
        /// <param name="test"></param>
        public static void AddTest_PartialDetails(Test test)
        {
            Tests_xml();
            XElement ID = new XElement("Id", Dal_XML_imp.ID_FromConfigXML().ToString("00000000"));

            Dal_XML_imp.configXML_advancingID(); //call to function that adavances id

            XElement testerId  = new XElement("TesterId", test.TesterId);
            XElement traineeId = new XElement("TraineeId", test.TraineeId);

            XElement date = new XElement("Date", XmlConvert.ToString(test.Date, "yyyy-MM-ddTHH:mm:ss"));

            XElement houseNumber = new XElement("houseNumber", test.Address.houseNumber);
            XElement street      = new XElement("street", test.Address.street);
            XElement city        = new XElement("city", test.Address.city);
            XElement address     = new XElement("Address", houseNumber, street, city);

            XElement GearBox = new XElement("GearBox", (int)(test.GearBox));
            XElement carType = new XElement("Car", (int)test.Car);
            XElement test1_ReverseParking      = new XElement("Test1_ReverseParking");
            XElement test2_KeepingSafeDistance = new XElement("Test2_KeepingSafeDistance");
            XElement test3_UsingMirrors        = new XElement("Test3_UsingMirrors");
            XElement test4_UsingTurnSignals    = new XElement("Test4_UsingTurnSignals");
            XElement test5_LegalSpeed          = new XElement("Test5_LegalSpeed");
            XElement succeeded = new XElement("Succeeded");
            XElement notes     = new XElement("Notes");

            XElement Test = new XElement("test", ID, testerId, traineeId, date, address, GearBox, carType, test1_ReverseParking, test2_KeepingSafeDistance, test3_UsingMirrors, test4_UsingTurnSignals, test5_LegalSpeed, succeeded, notes);

            XElement test_root = XElement.Load(TestPath);

            test_root.Add(Test);
            test_root.Save(TestPath);
        }
예제 #3
0
 public static Dal_XML_imp GetIdal()
 {
     if (dal == null)
     {
         dal = new Dal_XML_imp();
     }
     return(dal);
 }
예제 #4
0
 public List <HostingUnit> My_HostingUnitList()
 {
     if (Dal_XML_imp.GetHostingUnitFromXml() == null)
     {
         throw new Exception("רשימת יחידות האירוח ריקה");
     }
     return(Dal_XML_imp.GetHostingUnitFromXml().Select(hu => (HostingUnit)hu.Clone()).ToList());
 }
예제 #5
0
 public List <Order> My_OrdersList()
 {
     if (Dal_XML_imp.GetOrderFromXml() == null)
     {
         throw new NotImplementedException("רשימת הזמנות ריקה");
     }
     return(Dal_XML_imp.GetOrderFromXml().Select(hu => (Order)hu.Clone()).ToList());
 }
예제 #6
0
 public List <MyGuest> MyGest_List()
 {
     if (Dal_XML_imp.GetGuestFromXml() == null)
     {
         throw new NotImplementedException("רשימת אורחים ריקה");
     }
     return(Dal_XML_imp.GetGuestFromXml().Select(hu => (MyGuest)hu.Clone()).ToList());
 }
예제 #7
0
 public List <GuestRequest> My_GuestRequestList()
 {
     if (Dal_XML_imp.GetGuestRequestFromXml() == null)
     {
         throw new NotImplementedException("רשימת דרישות לקוח ריקה");
     }
     return(Dal_XML_imp.GetGuestRequestFromXml().Select(hu => (GuestRequest)hu.Clone()).ToList());
 }
 public static Dal_XML_imp GetInstance()
 {
     if (instance == null)
     {
         instance = new Dal_XML_imp();
     }
     return(instance);
 }
예제 #9
0
 /// <summary>
 /// This is the factory method of Dal_XML_imp
 /// </summary>
 /// <returns>The <see cref="instance"/> of the singleton factory (singletory)</returns>
 public static IDAL GetDAL()
 {
     if (instance == null)
     {
         instance = new Dal_XML_imp();
         return(instance);
     }
     return(instance);
 }
예제 #10
0
 /// <summary>
 /// delete one tester
 /// </summary>
 /// <param name="tester"></param>
 public void DeleteTester(Tester tester)
 {
     if (DataSource.testers.RemoveAll(item => item.Id == tester.Id) == 0)
     {
         throw new Exception("failed to remove, tester with the same ID not found");
     }
     Dal_XML_imp.DeleteTester(tester);
     testerEvent(this, null);
 }
예제 #11
0
 /// <summary>
 /// delete one trainee
 /// </summary>
 /// <param name="trainee"></param>
 public void DeleteTrainee(Trainee trainee)
 {
     if (DataSource.trainees.RemoveAll(item => item.Id == trainee.Id) == 0)
     {
         throw new Exception("failed to remove, trainee with the same ID not found");
     }
     Dal_XML_imp.DeleteTrainee(trainee);
     traineeEvent(this, null);
 }
예제 #12
0
 /// <summary>
 /// add one tester
 /// </summary>
 /// <param name="tester"></param>
 public void AddTester(Tester tester)
 {
     if (DataSource.testers.Find(item => item.Id == tester.Id) != null)
     {
         throw new Exception("cant add the tester, there are another tester with the same id");
     }
     DataSource.testers.Add(tester);
     Dal_XML_imp.SaveToXML <List <Tester> >(DataSource.testers, Dal_XML_imp.TesterPath);
     testerEvent(DAL_imp.Instance, null);
 }
예제 #13
0
 /// <summary>
 /// add one trainee
 /// </summary>
 /// <param name="trainee"></param>
 public void AddTrainee(Trainee trainee)
 {
     if (DataSource.trainees.Find(item => item.Id == trainee.Id) != null)
     {
         throw new Exception("cant add the trainee, there are another trainee with the same id");
     }
     DataSource.trainees.Add(trainee);
     Dal_XML_imp.SaveToXML <List <Trainee> >(DataSource.trainees, Dal_XML_imp.TraineePath);
     traineeEvent(this, null);
 }
예제 #14
0
 public HostingUnit GetName_GiveHostingUnit(string My_Name)
 {
     foreach (var item in Dal_XML_imp.GetHostingUnitFromXml())
     {
         if (item.HostingUnitName == My_Name)
         {
             return(item);
         }
     }
     return(null); //השם של היחידה לא נמצא ברשימה
 }
예제 #15
0
        MyHost IDAL.getMyHost(int Location_list)
        {
            if (Location_list >= 0)

            {
                return(Dal_XML_imp.GetMyHostFromXml(Location_list));
            }
            else
            {
                throw new NotImplementedException("האורח לא נמצא במערכת");
            }
        }
예제 #16
0
 public void UpdateHostingUnit(HostingUnit My_HostingUnit)
 {
     foreach (var item in DataSource.My_HostingUnitList)
     {
         if (item.hosting_unit_key == My_HostingUnit.hosting_unit_key)
         {
             Dal_XML_imp.RemoveHostingUnitToXml(item.hosting_unit_key);
             --Configuration.HostingUnitKey;
         }
     }
     Dal_XML_imp.AddHostingUnitToXml(My_HostingUnit.Clone());
     ++Configuration.HostingUnitKey;
 }
예제 #17
0
 /// <summary>
 /// delete one test
 /// </summary>
 /// <param name="test"></param>
 public void DeleteTest(Test test)
 {
     foreach (Test item in DataSource.tests)
     {
         if (item.Id == test.Id)
         {
             DataSource.tests.Remove(item);
             Dal_XML_imp.DeleteTest(item);
             testEvent(this, null);
             return;
         }
     }
     throw new Exception("failed to remove, test with the same ID not found");
 }
예제 #18
0
 private DAL_imp()
 {
     if (File.Exists(Dal_XML_imp.TesterPath))
     {
         DataSource.testers = Dal_XML_imp.LoadFromXML <List <Tester> >(Dal_XML_imp.TesterPath);
     }
     if (File.Exists(Dal_XML_imp.TraineePath))
     {
         DataSource.trainees = Dal_XML_imp.LoadFromXML <List <Trainee> >(Dal_XML_imp.TraineePath);
     }
     if (File.Exists(Dal_XML_imp.TestPath))
     {
         DataSource.tests = Dal_XML_imp.Instance.GetAllTests();
     }
 }
예제 #19
0
        /// <summary>
        /// add new test. it also give the test new id
        /// </summary>
        /// <param name="test"></param>
        public void AddTest(Test test)
        {
            test.Id = Dal_XML_imp.ID_FromConfigXML().ToString("00000000");

            ////add 0 at the start of the id antil there is 8 digits
            //StringBuilder builder = new StringBuilder();
            //for (int i = test.Id.Length; i < 8; i++)
            //    builder.Append(0);
            //builder.Append(test.Id);
            //test.Id = builder.ToString();
            //Configuration.test_id++;
            DataSource.tests.Add(test);

            Dal_XML_imp.AddTest_PartialDetails(test);
            testEvent(this, null);
        }
예제 #20
0
        public void deleteHostingUnit(HostingUnit My_HostingUnit)
        {
            var L = from item in Dal_XML_imp.GetHostingUnitFromXml()
                    where My_HostingUnit.hosting_unit_key == item.hosting_unit_key
                    select item;

            if (L == null)
            {
                throw new NotImplementedException("not found");
            }
            else
            {
                Dal_XML_imp.RemoveHostingUnitToXml(My_HostingUnit.hosting_unit_key);
                --Configuration.HostingUnitKey;
            }
        }
예제 #21
0
        /// <summary>
        /// update on trainee, include id update
        /// </summary>
        /// <param name="trainee"></param>
        /// <param name="old_ID"></param>
        public void UpdateTrainee(Trainee trainee, string old_ID)
        {
            int index = 0;;

            foreach (Trainee item in DataSource.trainees)
            {
                if (item.Id == old_ID)
                {
                    DataSource.trainees[index] = trainee;
                    Dal_XML_imp.SaveToXML <List <Trainee> >(DataSource.trainees, Dal_XML_imp.TraineePath);
                    traineeEvent(this, null);
                    return;
                }
                index++;
            }
            throw new Exception("failed to update, trainee with the same ID not found");
        }
예제 #22
0
        /// <summary>
        /// update one tester, include id update
        /// </summary>
        /// <param name="tester">the new tester</param>
        /// <param name="oldId">the old id</param>
        public void UpdateTester(Tester tester, string oldId)
        {
            int index = 0;

            foreach (Tester item in DataSource.testers)
            {
                if (item.Id == oldId)
                {
                    DataSource.testers[index] = tester;
                    Dal_XML_imp.SaveToXML <List <Tester> >(DataSource.testers, Dal_XML_imp.TesterPath);
                    testerEvent(this, null);
                    return;
                }
                index++;
            }
            throw new Exception("failed to update, the tester old ID not found");
        }
예제 #23
0
        void IDAL.update_GuestRequest(GuestRequest My_GuestRequest)// עידכון דרישת לקוח- עידכון סטטוס
        {
            bool ezer = false;

            foreach (var item in Dal_XML_imp.GetGuestRequestFromXml())
            {
                if (item.guest_request_key == My_GuestRequest.guest_request_key)
                {
                    ezer        = true;
                    item.Status = My_GuestRequest.Status;
                }
            }
            if (ezer == false) //אין את הלקוח ברשימה
            {
                Dal_XML_imp.AddGuestRequestToXml(My_GuestRequest.Clone());
                ++Configuration.GuestRequestKey;
                throw new NotImplementedException("The customer is not on the list so add again");
            }
        }
예제 #24
0
        public int FindGuestRequest(long key)
        {
            int  Location = 0;
            bool help     = false;

            foreach (var item in Dal_XML_imp.GetGuestRequestFromXml())
            {
                if (item.guest_request_key == key && Configuration.GuestRequestKey != 10000000)
                {
                    help = true;
                    return(Location);
                }
                Location++;
            }
            if (help == false)
            {
                throw new NotImplementedException("דרישת הלקוח לא נמצאה במערכת");
            }
            return(0);
        }
예제 #25
0
        public int FindMyGuest(string id)
        {
            int  Location = 0;
            bool help     = false;

            foreach (var item in Dal_XML_imp.GetGuestFromXml())
            {
                if (item.Id == id)
                {
                    help = true;
                    return(Location);
                }
                Location++;
            }
            if (help == false)
            {
                throw new NotImplementedException("האורח לא נמצא במערכת");
            }
            return(0);
        }
예제 #26
0
        public void AddHost(MyHost My_Host)
        {
            bool ezer = false;

            foreach (var item in Dal_XML_imp.GetMyHostFromXml())
            {
                if (item.Id_host == My_Host.Id_host)
                {
                    ezer = true;
                }
            }
            if (ezer == false) //אין את הלקוח ברשימה
            {
                Dal_XML_imp.AddMyHostToXml(My_Host.Clone());
            }
            else
            {
                throw new NotImplementedException("המארח כבר רשום במערכת");
            }
        }
예제 #27
0
        public void UpdateOrder(Order My_Order)
        {
            bool ezer = false;

            foreach (var item in Dal_XML_imp.GetOrderFromXml())

            {
                if (item.Order_key == My_Order.Order_key)
                {
                    ezer        = true;
                    item.Status = My_Order.Status;
                }
            }
            if (ezer == false) //אין את ההזמנה ברשימה
            {
                Dal_XML_imp.AddOrderToXml(My_Order.Clone());
                Configuration.OrderKey++;
                throw new NotImplementedException("The order is not on the list so add again");
            }
        }
예제 #28
0
        public HostingUnit one_of_available_units(DateTime d1, int days)
        {
            bool Approved = true;

            foreach (var item in Dal_XML_imp.GetHostingUnitFromXml())
            {
                for (int index = 0; index < days; index++, d1 = d1.AddDays(1))
                {
                    if (item.Diary[d1.Month - 1, d1.Day - 1] == true)
                    {
                        Approved = false;
                    }
                }
                if (Approved)// היחידה פנויה
                {
                    return(item);
                }
            }
            return(null);
        }
예제 #29
0
        /// <summary>
        /// update one test. test id mustn't change
        /// </summary>
        /// <param name="test"></param>
        public void UpdateTest(Test test)
        {
            if (test.Id == null)
            {
                throw new Exception("failed to update, cant make test without ID");
            }
            int index = 0;;

            foreach (Test item in DataSource.tests)
            {
                if (item.Id == test.Id)
                {
                    DataSource.tests[index] = test;
                    Dal_XML_imp.UpdateTest(test);
                    testEvent(this, null);
                    return;
                }
                index++;
            }
            throw new Exception("failed to update, test with the same ID not found");
        }
예제 #30
0
        public void AddOrder(Order My_Order)
        {
            bool ezer = false;

            foreach (var item in Dal_XML_imp.GetOrderFromXml())
            {
                if (item.Order_key == My_Order.Order_key)
                {
                    ezer = true;
                }
            }
            if (ezer == false) // לא נמצא כבר ברשימה
            {
                Dal_XML_imp.AddOrderToXml(My_Order.Clone());
                ++Configuration.OrderKey;
            }
            else // ezer= true
            {
                throw new NotImplementedException("ההזמנה נמצאת כבר ברשימה");
            }
        }