Exemplo n.º 1
0
        public HostingUnit RecieveHostingUnit(int key)
        {
            HostingUnitRoot = XElement.Load(HostingUnitPath);
            HostingUnitXML hostingUnitXML = new HostingUnitXML();

            try
            {
                hostingUnitXML = (from HU in HostingUnitRoot.Elements()
                                  where int.Parse(HU.Element("Key").Value) == key
                                  select new HostingUnitXML()
                {
                    Key = int.Parse(HU.Element("Key").Value),
                    Owner = int.Parse(HU.Element("Owner").Value),
                    PricePerNight = int.Parse(HU.Element("PricePerNight").Value),
                    HostingUnitName = HU.Element("HostingUnitName").Value,
                    Area = (DO.Location)Enum.Parse(typeof(DO.Location), HU.Element("Area").Value),
                    Diary_XML = (from boolean in HU.Element("Diary").Elements()
                                 select bool.Parse(boolean.Value)).ToArray(),
                    Status = (DO.Status)Enum.Parse(typeof(DO.Status), HU.Element("Status").Value),
                    WIFI = bool.Parse(HU.Element("WIFI").Value),
                    SwimmingPool = bool.Parse(HU.Element("SwimmingPool").Value),
                    Kitchen = bool.Parse(HU.Element("Kitchen").Value),
                    TV = bool.Parse(HU.Element("TV").Value),
                    Jacuzzi = bool.Parse(HU.Element("Jacuzzi").Value),
                    ImageLink1 = HU.Element("ImageLink1").Value,
                    ImageLink2 = HU.Element("ImageLink2").Value,
                    ImageLink3 = HU.Element("ImageLink3").Value
                }).FirstOrDefault();
            }
            catch
            {
                return(null);
            }
            return(hostingUnitXML == null ? null : hostingUnitXML.ConvertToDO());
        }
Exemplo n.º 2
0
        public List <HostingUnitXML> GetHostingunits()
        {
            HostingUnitRoot = XElement.Load(HostingUnitPath);
            List <HostingUnitXML> hostingunits;

            try
            {
                hostingunits = (from HU in HostingUnitRoot.Elements()
                                select new HostingUnitXML()
                {
                    Key = int.Parse(HU.Element("Key").Value),
                    Owner = int.Parse(HU.Element("Owner").Value),
                    PricePerNight = int.Parse(HU.Element("PricePerNight").Value),
                    HostingUnitName = HU.Element("HostingUnitName").Value,
                    Area = (DO.Location)Enum.Parse(typeof(DO.Location), HU.Element("Area").Value),
                    Diary_XML = (from boolean in HU.Element("Diary").Elements()
                                 select bool.Parse(boolean.Value)).ToArray(),
                    Status = (DO.Status)Enum.Parse(typeof(DO.Status), HU.Element("Status").Value),
                    WIFI = bool.Parse(HU.Element("WIFI").Value),
                    SwimmingPool = bool.Parse(HU.Element("SwimmingPool").Value),
                    Kitchen = bool.Parse(HU.Element("Kitchen").Value),
                    TV = bool.Parse(HU.Element("TV").Value),
                    Jacuzzi = bool.Parse(HU.Element("Jacuzzi").Value),
                    ImageLink1 = HU.Element("ImageLink1").Value,
                    ImageLink2 = HU.Element("ImageLink2").Value,
                    ImageLink3 = HU.Element("ImageLink3").Value
                }).ToList();
            }
            catch (Exception)
            {
                throw;
            }

            return(hostingunits);
        }
Exemplo n.º 3
0
        public void RemoveHostingUnit(int key)
        {
            HostingUnitRoot = XElement.Load(HostingUnitPath);
            XElement Temp;

            try
            {
                Temp = (from HU in HostingUnitRoot.Elements()
                        where int.Parse(HU.Element("Key").Value) == key
                        select HU).FirstOrDefault();
            }
            catch (Exception)
            {
                throw new Exception("הייתה תקלה  במחיקת ישות מסוג יחידת אירוח");
            }
            Temp.Remove();
            HostingUnitRoot.Save(HostingUnitPath);
        }