예제 #1
0
        public HostingUnit GetHostingUnit(int key)
        {
            hostingUnitHandler.Load();
            HostingUnitXml findHostingUnit = (from unit in hostingUnits
                                              where unit.Key == key
                                              select unit).FirstOrDefault();

            if (findHostingUnit != null && findHostingUnit.Status == ActivityStatus.ACTIVE)
            {
                return(Tools.Conv_Xml_To_DO(findHostingUnit.Clone()));
            }
            throw new Exception("היחידה אינה קיימת במערכת");///need to check if hosting unit status is active?????
        }
예제 #2
0
        public bool DisableHostingUnit(int key)
        {
            hostingUnitHandler.Load();
            HostingUnitXml findHostingUnit = (from unit in hostingUnits
                                              where unit.Key == key
                                              select unit).FirstOrDefault();

            if (findHostingUnit != null)
            {
                findHostingUnit.Status = ActivityStatus.INACTIVE;
                hostingUnitHandler.Save();
                return(true);
            }
            throw new Exception("היחידה אינה קיימת במערכת");
        }
예제 #3
0
        public bool UpdateHostingUnit(HostingUnit item)
        {
            hostingUnitHandler.Load();
            HostingUnitXml findHostingUnit = (from unit in hostingUnits
                                              where unit.Key == item.Key
                                              select unit).FirstOrDefault();

            if (findHostingUnit != null)
            {
                hostingUnits.Remove(findHostingUnit);
                hostingUnits.Add(Tools.conv_DO_To_Xml(item.Clone()));
                hostingUnitHandler.Save();
                return(true);
            }
            throw new Exception("היחידה אינה קיימת במערכת");
        }
 public static DO.HostingUnit Conv_Xml_To_DO(HostingUnitXml item)
 {
     DO.HostingUnit temp = new DO.HostingUnit();
     temp.Area = (DO.Areas)item.Area;
     temp.ChildrensAttractions = item.ChildrensAttractions;
     temp.Diary           = item.Diary;
     temp.Garden          = item.Garden;
     temp.HostId          = item.HostId;
     temp.HostingUnitName = item.HostingUnitName;
     temp.Jacuzzi         = item.Jacuzzi;
     temp.Key             = item.Key;
     temp.NumOfOffers     = item.NumOfOffers;
     temp.Pool            = item.Pool;
     temp.pricePerNight   = item.pricePerNight;
     temp.Rooms           = item.Rooms;
     temp.Status          = (DO.ActivityStatus)item.Status;
     temp.Type            = (DO.HostingType)item.Type;
     return(temp);
 }
예제 #5
0
        public int AddHostingUnit(HostingUnit item)
        {
            hostingUnitHandler.Load();
            HostingUnitXml findHostingUnit = (from unit in hostingUnits
                                              where unit.Key == item.Key
                                              select unit).FirstOrDefault();

            if (findHostingUnit == null)
            {
                Config   = config.LoadConfig();
                item.Key = int.Parse(Config["HostingUnitKey"]);
                hostingUnits.Add(Tools.conv_DO_To_Xml(item.Clone()));
                hostingUnitHandler.Save();
                setConfig("HostingUnitKey", (item.Key + 1).ToString());
                return(item.Key);
            }
            if (findHostingUnit != null && findHostingUnit.Status == ActivityStatus.INACTIVE)
            {
                findHostingUnit.Status = ActivityStatus.ACTIVE;
                hostingUnitHandler.Save();
                return(findHostingUnit.Key);
            }
            throw new Exception("יחידת האירוח כבר קיימת במערכת");
        }