Ejemplo n.º 1
0
 /// <summary>
 /// Creates a copy of this instance
 /// </summary>
 /// <returns>A copy of this instance</returns>
 public object Clone()
 {
     return(new Heat
     {
         Beds = Beds.Select(bed => (BedOrChamber)bed?.Clone()).ToList(),
         Chambers = Chambers.Select(chamber => (BedOrChamber)chamber?.Clone()).ToList(),
         ColdExtrudeTemperature = ColdExtrudeTemperature,
         ColdRetractTemperature = ColdRetractTemperature,
         Extra = Extra.Select(extra => (ExtraHeater)extra.Clone()).ToList(),
         Heaters = Heaters.Select(heater => (Heater)heater.Clone()).ToList()
     });
 }
Ejemplo n.º 2
0
        public void Edit()
        {
            db = new WGHotelUSEntities();
            var ZHModel = _db.Room.Find(ID);

            if (ZHModel == null)
            {
                return;
            }
            var USModel = db.Room.Where(o => o.ParentId == ZHModel.ID).FirstOrDefault();

            if (USModel == null)
            {
                return;
            }

            ZHModel.Name   = NameZh;
            ZHModel.Notice = NoticeZh;

            USModel.Name   = NameUs;
            USModel.Notice = NameUs;

            //Room.Notice = NoticeZh;
            //ZHModel.BedType = BedType;
            var BedTypes = string.Empty;

            if (Beds != null && Beds.Count > 0)
            {
                BedTypes = string.Join(",", Beds);
            }
            ZHModel.BedType      = BedTypes;
            ZHModel.RoomType     = RoomType;
            ZHModel.Sell         = Sell;
            ZHModel.Enabled      = true;
            ZHModel.HasBreakfast = HasBreakfast;
            ZHModel.HOTELID      = HOTELID;
            ZHModel.Facilities   = string.Empty;
            ZHModel.Quantiy      = Quantiy;
            //_db.Room.Add(ZHModel);
            //_db.SaveChanges();

            try
            {
                var ENBed = new List <string>();
                if (Beds != null && Beds.Count > 0)
                {
                    var ENBeds = Beds.Select(int.Parse).ToList();
                    foreach (var b in ENBeds)
                    {
                        var data = db.CodeFile.Where(o => o.ItemType == "Bed" && o.ParentId == b).FirstOrDefault();
                        if (data != null)
                        {
                            ENBed.Add(data.ID.ToString());
                        }
                    }
                }


                var ENHotelId = db.Room.Where(o => o.ParentId == ZHModel.ID).FirstOrDefault().ID;

                USModel.BedType      = (ENBed == null || ENBed.Count <= 0) ? string.Empty : string.Join(",", ENBed);
                USModel.RoomType     = RoomType;
                USModel.Sell         = Sell;
                USModel.Enabled      = true;
                USModel.HasBreakfast = HasBreakfast;
                //USModel.HOTELID = ENHotelId;
                USModel.Facilities = string.Empty;
                USModel.Quantiy    = Quantiy;
                //db.Room.Add(USModel);
                db.SaveChanges();
                _db.SaveChanges();
                SaveImageStore(ZHModel.ID, USModel.ID);
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 3
0
        public void Create()
        {
            var ZHID      = 0;
            var USID      = 0;
            var ZHHotelID = 0;
            var BedTypes  = string.Empty;

            if (Beds != null && Beds.Count > 0)
            {
                BedTypes = string.Join(",", Beds);
            }
            using (var db = new WGHotelZHEntities())
            {
                var Room = new Room();
                Room.Name         = NameZh;
                Room.Notice       = NoticeZh;
                Room.Feature      = FeatureZh;
                Room.BedType      = BedTypes;
                Room.RoomType     = RoomType;
                Room.Sell         = Sell;
                Room.Enabled      = true;
                Room.HasBreakfast = HasBreakfast;
                Room.HOTELID      = HOTELID;
                Room.Facilities   = string.Empty;
                Room.Quantiy      = Quantiy;
                db.Room.Add(Room);
                db.SaveChanges();
                ZHID      = Room.ID;
                ZHHotelID = Room.HOTELID;
            }

            try
            {
                using (var db = new WGHotelUSEntities())
                {
                    var ENBed = new List <string>();
                    if (Beds != null && Beds.Count > 0)
                    {
                        var ENBeds = Beds.Select(int.Parse).ToList();
                        foreach (var b in ENBeds)
                        {
                            var data = db.CodeFile.Where(o => o.ItemType == "Bed" && o.ParentId == b).FirstOrDefault();
                            if (data != null)
                            {
                                ENBed.Add(data.ID.ToString());
                            }
                        }
                    }
                    var HotelID = db.Hotel.Where(o => o.ParentId == ZHHotelID).FirstOrDefault().ID;
                    var Room    = new Room();
                    Room.Name         = NameUs;
                    Room.Feature      = FeatureUs;
                    Room.Notice       = NoticeUs;
                    Room.BedType      = (ENBed == null || ENBed.Count <= 0) ? string.Empty : string.Join(",", ENBed);
                    Room.RoomType     = RoomType;
                    Room.Sell         = Sell;
                    Room.Enabled      = true;
                    Room.HasBreakfast = HasBreakfast;
                    Room.HOTELID      = HotelID;
                    Room.Facilities   = string.Empty;
                    Room.Quantiy      = Quantiy;
                    Room.ParentId     = ZHID;
                    db.Room.Add(Room);
                    db.SaveChanges();
                    USID = Room.ID;
                }

                SaveImageStore(ZHID, USID);
            }
            catch (Exception ex)
            {
                using (var db = new WGHotelZHEntities())
                {
                    var remove = db.Hotel.Where(o => o.ID == ZHID).FirstOrDefault();
                    if (remove != null)
                    {
                        db.Hotel.Remove(remove);
                        db.SaveChanges();
                    }
                }
            }
        }