Beispiel #1
0
        public void Edit()
        {
            var _dbZH = new WGHotelZHEntities();
            var _dbEN = new WGHotelUSEntities();

            var Today = DateTime.Now;

            var ZH = _dbZH.CodeFile.Where(o => o.ID == ID && o.ItemCode == "Bed").FirstOrDefault();

            ZH.ItemCode        = "Bed";
            ZH.ItemType        = "Bed";
            ZH.ItemDescription = NameZH;

            ZH.Modified = Today;
            ZH.Modify   = Creator;
            ZH.Deleted  = Deleted;
            //_dbZH.CodeFile.Add(ZH);
            _dbZH.SaveChanges();

            var ParentId = ZH.ID;

            var EN = _dbEN.CodeFile.Where(o => o.ParentId == ParentId && o.ItemCode == "Bed").FirstOrDefault();

            EN.ItemCode        = "Bed";
            EN.ItemType        = "Bed";
            EN.ItemDescription = NameEN;

            EN.Modified = Today;
            EN.Modify   = Creator;
            EN.Deleted  = Deleted;


            _dbEN.SaveChanges();
        }
Beispiel #2
0
        public void Create()
        {
            var _dbZH = new WGHotelZHEntities();
            var _dbEN = new WGHotelUSEntities();

            var Today = DateTime.Now;

            var ZH = new CodeFile();

            ZH.ItemCode        = "Bed";
            ZH.ItemType        = "Bed";
            ZH.ItemDescription = NameZH;
            ZH.Created         = Today;
            ZH.Creator         = Creator;
            ZH.Modified        = Today;
            ZH.Modify          = Creator;
            ZH.Remark          = "Bed Type";
            _dbZH.CodeFile.Add(ZH);
            _dbZH.SaveChanges();

            var EN = new CodeFile();

            EN.ItemCode        = "Bed";
            EN.ItemType        = "Bed";
            EN.ItemDescription = NameEN;
            EN.Created         = Today;
            EN.Creator         = Creator;
            EN.Modified        = Today;
            EN.Modify          = Creator;
            EN.ParentId        = ZH.ID;
            EN.Remark          = "Bed Type";
            _dbEN.CodeFile.Add(EN);
            _dbEN.SaveChanges();
        }
Beispiel #3
0
        public void Edit()
        {
            var dbZH = new WGHotelZHEntities();
            var dbUS = new WGHotelUSEntities();
            var zh   = dbZH.GameSite.Find(ID);
            var us   = dbUS.GameSite.Where(o => o.ParentId == zh.ID).FirstOrDefault();

            zh.Remark = RemarkZH;
            zh.Sports = SportZH;
            zh.Type   = TypeZH;
            zh.Venue  = VenueZH;
            dbZH.SaveChanges();
            us.Venue  = VenueUS;
            us.Remark = RemarkUS;
            us.Sports = SportUS;
            us.Type   = TypeUS;
            dbUS.SaveChanges();
        }
Beispiel #4
0
        public void Edit()
        {
            var FactitlyZH = new Facility();

            using (var zh = new WGHotelZHEntities())
            {
                FactitlyZH         = zh.Facility.Find(ID);
                FactitlyZH.Name    = NameZH;
                FactitlyZH.Enabled = Enabled;
                zh.SaveChanges();
            }

            var FactitlyUS = new Facility();

            using (var us = new WGHotelUSEntities())
            {
                FactitlyUS         = us.Facility.Where(o => o.ParentId == FactitlyZH.ID).First();
                FactitlyUS.Name    = NameUS;
                FactitlyUS.Enabled = Enabled;
                us.SaveChanges();
            }
        }
Beispiel #5
0
        public void Create()
        {
            var dbZH = new WGHotelZHEntities();
            var dbUS = new WGHotelUSEntities();

            var GameZH = new GameSite();

            GameZH.Remark = RemarkZH;
            GameZH.Sports = SportZH;
            GameZH.Type   = TypeZH;
            GameZH.Venue  = VenueZH;
            dbZH.GameSite.Add(GameZH);
            dbZH.SaveChanges();
            var GameUS = new GameSite();

            GameUS.ParentId = GameZH.ID;
            GameUS.Remark   = RemarkUS;
            GameUS.Sports   = SportUS;
            GameUS.Type     = TypeUS;
            GameUS.Venue    = VenueUS;
            dbUS.GameSite.Add(GameUS);
            dbUS.SaveChanges();
        }
Beispiel #6
0
        public void Create()
        {
            var FactitlyZH = new Facility();

            FactitlyZH.Name    = NameZH;
            FactitlyZH.Enabled = true;
            using (var zh = new WGHotelZHEntities())
            {
                zh.Facility.Add(FactitlyZH);
                zh.SaveChanges();
            }

            var FactitlUS = new Facility();

            FactitlUS.Name     = NameUS;
            FactitlUS.Enabled  = true;
            FactitlUS.ParentId = FactitlyZH.ID;
            using (var us = new WGHotelUSEntities())
            {
                us.Facility.Add(FactitlUS);
                us.SaveChanges();
            }
        }
Beispiel #7
0
        public void Create()
        {
            var ZHdb    = new WGHotelZHEntities();
            var zhHotel = new Hotel();

            zhHotel.Name       = Namezh;
            zhHotel.Address    = Addresszh;
            zhHotel.Area       = Area;
            zhHotel.City       = City;
            zhHotel.Facilities = Facilies;
            zhHotel.Features   = Featurezh;
            zhHotel.Enabled    = true;
            zhHotel.LinkUrl    = LinkUrl;
            zhHotel.Game       = Game;
            zhHotel.Tel        = Tel;
            zhHotel.UserId     = UserId;


            ZHdb.Hotel.Add(zhHotel);
            ZHdb.SaveChanges();
            var ReferIdZH = zhHotel.ID;
            var ReferIdUS = 0;

            try
            {
                var USdb    = new WGHotelUSEntities();
                var HotelUs = new Hotel
                {
                    Name       = Nameus,
                    Address    = Addressus,
                    Area       = Area,
                    City       = City,
                    Facilities = Facilies,
                    Features   = Featureus,
                    Enabled    = true,
                    LinkUrl    = LinkUrl,
                    Game       = Game,
                    UserId     = UserId,
                    Tel        = Tel,
                    ParentId   = zhHotel.ID
                };
                USdb.Hotel.Add(HotelUs);

                USdb.SaveChanges();
                ReferIdUS = HotelUs.ID;

                var Session = HttpContext.Current.Session;

                if (Session[ImgKey] != null)
                {
                    var Basedb = new WGHotelBaseEntities();
                    var Now    = DateTime.Now;
                    var images = (List <ImageViewModel>)Session[ImgKey];
                    foreach (var img in images)
                    {
                        var fileName = Guid.NewGuid().GetHashCode().ToString("x");
                        Basedb.ImageStore.Add(new ImageStore
                        {
                            Created   = Now,
                            Extension = img.Extension,
                            Deleted   = false,
                            ReferIdUS = ReferIdUS,
                            ReferIdZH = ReferIdZH,
                            Type      = "Hotel",
                            Name      = fileName,
                            Image     = img.Image
                        });
                    }
                    Basedb.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                var ZH = ZHdb.Hotel.Find(zhHotel.ID);
                if (ZH != null)
                {
                    ZHdb.Hotel.Remove(ZH);
                    ZHdb.SaveChanges();
                }
            }
        }
Beispiel #8
0
        public void Edit()
        {
            var ZHdb    = new WGHotelZHEntities();
            var zhHotel = ZHdb.Hotel.Find(ID);

            zhHotel.Name       = Namezh;
            zhHotel.Address    = Addresszh;
            zhHotel.Area       = Area;
            zhHotel.City       = City;
            zhHotel.Facilities = Facilies;
            zhHotel.Features   = Featurezh;
            zhHotel.Enabled    = true;
            zhHotel.LinkUrl    = LinkUrl;
            zhHotel.Game       = Game;
            zhHotel.Tel        = Tel;
            //zhHotel.UserId = zhHotel.UserId;


            //ZHdb.Hotel.Add(zhHotel);

            var ReferIdZH = zhHotel.ID;

            try
            {
                var USdb    = new WGHotelUSEntities();
                var HotelUs = USdb.Hotel.Where(o => o.ParentId == ReferIdZH).FirstOrDefault();

                HotelUs.Name       = Nameus;
                HotelUs.Address    = Addressus;
                HotelUs.Area       = Area;
                HotelUs.City       = City;
                HotelUs.Facilities = Facilies;
                HotelUs.Features   = Featureus;
                HotelUs.Enabled    = true;
                HotelUs.LinkUrl    = LinkUrl;
                HotelUs.Game       = Game;
                //HotelUs.UserId = UserId;
                HotelUs.Tel      = Tel;
                HotelUs.ParentId = zhHotel.ID;

                // USdb.Hotel.Add(HotelUs);

                USdb.SaveChanges();

                ZHdb.SaveChanges();

                var ReferIdUS = HotelUs.ID;
                var Session   = HttpContext.Current.Session;

                if (Session[ImgKey] != null)
                {
                    var Basedb   = new WGHotelBaseEntities();
                    var Now      = DateTime.Now;
                    var images   = (List <ImageViewModel>)Session[ImgKey];
                    var dbImg    = Basedb.ImageStore.Where(o => o.ReferIdZH == zhHotel.ID);
                    var ImgNames = dbImg.Select(o => o.Name).ToList();
                    images = images.Where(o => !ImgNames.Contains(o.Name)).ToList();
                    foreach (var img in images)
                    {
                        var fileName = Guid.NewGuid().GetHashCode().ToString("x");
                        Basedb.ImageStore.Add(new ImageStore
                        {
                            Created   = Now,
                            Extension = img.Extension,
                            Deleted   = false,
                            ReferIdUS = ReferIdUS,
                            ReferIdZH = ReferIdZH,
                            Type      = "Hotel",
                            Name      = fileName,
                            Image     = img.Image
                        });
                    }
                    Basedb.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #9
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)
            {
            }
        }
Beispiel #10
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();
                    }
                }
            }
        }