Ejemplo n.º 1
0
        public void Create()
        {
            var Today = DateTime.Now;

            using (var scope = new TransactionScope())
            {
                var _db = new WGHotelsEntities();

                var CodeFileZH = new CodeFileZH();
                CodeFileZH.ItemCode        = "Bed";
                CodeFileZH.ItemType        = "Bed";
                CodeFileZH.ItemDescription = NameZH;
                CodeFileZH.Created         = Today;
                CodeFileZH.Creator         = Creator;
                CodeFileZH.Modified        = Today;
                CodeFileZH.Modify          = Creator;
                CodeFileZH.Remark          = "Bed Type";
                _db.CodeFileZH.Add(CodeFileZH);
                _db.SaveChanges();

                var CodeFileEN = new CodeFileEN();
                CodeFileEN.ItemCode        = "Bed";
                CodeFileEN.ItemType        = "Bed";
                CodeFileEN.ItemDescription = NameEN;
                CodeFileEN.Created         = Today;
                CodeFileEN.Creator         = Creator;
                CodeFileEN.Modified        = Today;
                CodeFileEN.Modify          = Creator;
                CodeFileEN.ParentId        = CodeFileZH.ID;
                CodeFileEN.Remark          = "Bed Type";
                _db.CodeFileEN.Add(CodeFileEN);
                _db.SaveChanges();
                scope.Complete();
            }
        }
Ejemplo n.º 2
0
        public object HotelImageDelete(ImageViewModel data)
        {
            if (HttpContext.Current.Session[data.SessionKey] != null)
            {
                var images = (List <ImageViewModel>)HttpContext.Current.Session[data.SessionKey];
                var img    = new ImageViewModel();
                if (images.Count > 0)
                {
                    img = images.Where(o => o.Name == data.Name).FirstOrDefault();
                    if (img != null)
                    {
                        images.Remove(images.Where(o => o.Name == img.Name).FirstOrDefault());
                        new ImageDAO().Delete(img.Name);

                        using (var db = new WGHotelsEntities())
                        {
                            var dbimg = db.ImageStore.Where(o => o.Name == img.Name).FirstOrDefault();
                            if (dbimg != null)
                            {
                                db.ImageStore.Remove(dbimg);
                                db.SaveChanges();
                            }
                        }
                    }
                }



                HttpContext.Current.Session[data.SessionKey] = images;
            }

            return(Json(new { success = true }));
        }
Ejemplo n.º 3
0
        public void Create()
        {
            using (var scope = new TransactionScope())
            {
                using (var _db = new WGHotelsEntities())
                {
                    var Venue_ZH = new VenueZH();

                    Venue_ZH.Sport   = SportZH;
                    Venue_ZH.Type    = TypeZH;
                    Venue_ZH.Venue   = VenueZH;
                    Venue_ZH.Deleted = Deleted;
                    _db.VenueZH.Add(Venue_ZH);
                    //_db.SaveChanges();

                    var Venue_EN = new VenueEN();
                    Venue_EN.Sport   = SportEN;
                    Venue_EN.Type    = VenueViewModel.GetTypeEN(TypeZH);
                    Venue_EN.Venue   = VenueEN;
                    Venue_ZH.Deleted = Deleted;
                    _db.VenueEN.Add(Venue_EN);
                    _db.SaveChanges();
                    scope.Complete();
                }
            }
        }
Ejemplo n.º 4
0
 public void Edit()
 {
     using (var _db = new WGHotelsEntities())
     {
         var zh = _db.GameSiteZH.Find(IDZH);
         var us = _db.GameSiteEN.Where(o => o.ParentId == zh.ID).FirstOrDefault();
         zh.Remark = RemarkZH;
         zh.Sports = SportZH;
         zh.Type   = TypeZH;
         zh.Venue  = VenueZH;
         _db.SaveChanges();
         us.Venue  = VenueUS;
         us.Remark = RemarkUS;
         us.Sports = SportUS;
         us.Type   = TypeUS;
         _db.SaveChanges();
     }
 }
Ejemplo n.º 5
0
        public HttpResponseMessage RoomPriceSave(List <CalendarPost> data)
        {
            HttpResponseMessage response = new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonConvert.SerializeObject(new { message = "ok" }))
            };

            if (data.Count <= 0)
            {
                return(response);
            }

            try
            {
                foreach (var item in data)
                {
                    if (_db.RoomPrice.Any(o => o.Date == item.date && o.ROOMID == item.roomid))
                    {
                        var obj = _db.RoomPrice.Where(o => o.Date == item.date && o.ROOMID == item.roomid).FirstOrDefault();
                        obj.ROOMID   = item.roomid;
                        obj.Date     = item.date;
                        obj.Price    = item.price;
                        obj.Quantity = item.quantity;
                        obj.SaleOff  = item.off;
                    }
                    else
                    {
                        _db.RoomPrice.Add(new RoomPrice
                        {
                            SaleOff  = item.off,
                            Quantity = item.quantity,
                            Price    = item.price,
                            Date     = item.date,
                            ROOMID   = item.roomid
                        });
                    }
                    _db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.NotFound,
                    Content    = new StringContent(JsonConvert.SerializeObject(new { message = ex.Message.ToString() }))
                };

                return(response);
            }


            return(response);
        }
Ejemplo n.º 6
0
 public void Edit()
 {
     using (var db = new WGHotelsEntities())
     {
         if (ID > 0)
         {
             var model = db.Language.Find(ID);
             model.LanguZH = LanguZH;
             model.LanguEN = LanguEN;
             db.SaveChanges();
         }
         else
         {
             db.Language.Add(new Language {
                 LanguZH = LanguZH, LanguEN = LanguEN, Deleted = false
             });
             db.SaveChanges();
         }
     }
 }
Ejemplo n.º 7
0
        public void Edit()
        {
            using (var db = new WGHotelsEntities())
            {
                var data      = db.SysSetting.Where(o => o.Code.Equals("RoomCanEditDate")).ToList();
                var BeginId   = data.Where(o => o.Name == "Begin").FirstOrDefault().ID;
                var EndId     = data.Where(o => o.Name == "End").FirstOrDefault().ID;
                var BeginDate = db.SysSetting.Where(o => o.ID == BeginId).FirstOrDefault();
                BeginDate.Value = Begin;

                var EndDate = db.SysSetting.Where(o => o.ID == EndId).FirstOrDefault();
                EndDate.Value = End;
                db.SaveChanges();
            }
        }
Ejemplo n.º 8
0
 public void Create()
 {
     using (var scope = new TransactionScope())
     {
         using (var _db = new WGHotelsEntities())
         {
             var GameZH = new GameSiteZH();
             GameZH.Remark = RemarkZH;
             GameZH.Sports = SportZH;
             GameZH.Type   = TypeZH;
             GameZH.Venue  = VenueZH;
             _db.GameSiteZH.Add(GameZH);
             _db.SaveChanges();
             var GameUS = new GameSiteEN();
             GameUS.ParentId = GameZH.ID;
             GameUS.Remark   = RemarkUS;
             GameUS.Sports   = SportUS;
             GameUS.Type     = TypeUS;
             GameUS.Venue    = VenueUS;
             _db.GameSiteEN.Add(GameUS);
             _db.SaveChanges();
         }
     }
 }
Ejemplo n.º 9
0
        public void Edit()
        {
            var FactitlyZH = new FacilityZH();
            var FactitlyEN = new FacilityEN();

            using (var scope = new TransactionScope())
            {
                using (var _db = new WGHotelsEntities())
                {
                    FactitlyZH         = _db.FacilityZH.Find(ID);
                    FactitlyZH.Name    = NameZH;
                    FactitlyZH.Enabled = Enabled;
                    FactitlyEN         = _db.FacilityEN.Where(o => o.ParentId == FactitlyZH.ID).First();
                    FactitlyEN.Name    = NameUS;
                    FactitlyEN.Enabled = Enabled;
                    _db.SaveChanges();
                    scope.Complete();
                }
            }
        }
Ejemplo n.º 10
0
        public void Create()
        {
            using (var _db = new WGHotelsEntities())
            {
                var Model = new Report();
                Model.Created = Created;
                Model.Creator = Creator;
                //Model.CountryID = CountryID;
                var country_id = int.Parse(Country);
                var country    = _db.Country.Find(country_id);
                Model.CountryID   = country.ID;
                Model.Country     = country.Name;
                Model.CheckInDate = CheckInDate;
                Model.HotelID     = HotelID;
                Model.NumOfPeople = NumOfPeople;
                Model.Price       = Price;
                Model.RoomID      = RoomID;
                Model.Modified    = Modified;
                Model.Modify      = Modify;
                Model.Room        = Room;
                Model.Food        = Food;
                Model.FoodCost    = FoodCost;
                Model.Other       = Other;
                Model.OtherCost   = OtherCost;
                Model.UserType    = UserType;

                var ReportRooms = new List <ReportRooms>();

                for (var i = 0; i < RoomIds.Count; i++)
                {
                    ReportRooms.Add(new ReportRooms {
                        Amount = Amount[i], Quantity = Quantity[i], RoomID = RoomIds[i], RoomName = RoomName[i], Deleted = false
                    });
                }

                Model.ReportRooms = ReportRooms;

                _db.Report.Add(Model);
                _db.SaveChanges();
            }
        }
Ejemplo n.º 11
0
        public void Edit()
        {
            using (var scope = new TransactionScope())
            {
                using (var _db = new WGHotelsEntities())
                {
                    var Today = DateTime.Now;

                    var ZH = _db.CodeFileZH.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);


                    var ParentId = ZH.ID;

                    var EN = _db.CodeFileEN.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;


                    _db.SaveChanges();
                    scope.Complete();
                }
            }
        }
Ejemplo n.º 12
0
        public void Create()
        {
            var FactitlyZH = new FacilityZH();
            var FacilityEN = new FacilityEN();

            FactitlyZH.Name    = NameZH;
            FactitlyZH.Enabled = true;

            using (var scope = new TransactionScope())
            {
                using (var _db = new WGHotelsEntities())
                {
                    _db.FacilityZH.Add(FactitlyZH);

                    FacilityEN.Name     = NameUS;
                    FacilityEN.Enabled  = true;
                    FacilityEN.ParentId = FactitlyZH.ID;

                    _db.SaveChanges();

                    scope.Complete();
                }
            }
        }
Ejemplo n.º 13
0
        public void Edit()
        {
            using (var db = new WGHotelsEntities())
            {
                var Model = db.Report.Find(ID);
                Model.Modified = Modified;
                Model.Modify   = Modify;

                var country_id = int.Parse(Country);
                var country    = db.Country.Find(country_id);
                Model.CountryID   = country.ID;
                Model.Country     = country.Name;
                Model.CheckInDate = CheckInDate;
                Model.HotelID     = HotelID;
                Model.NumOfPeople = NumOfPeople;
                Model.Price       = Price;
                Model.RoomID      = RoomID;
                Model.Room        = Room;
                Model.Food        = Food;
                Model.FoodCost    = FoodCost;
                Model.Other       = Other;
                Model.OtherCost   = OtherCost;
                Model.UserType    = UserType;

                //var ExistReprtRooms = db.ReportRooms.Where(o => o.ReportID == ID).ToList();
                var ExistReprtRooms = (from o in db.ReportRooms
                                       where o.ReportID == Model.ID && o.Deleted != true
                                       select o).ToList();
                var count                  = ExistReprtRooms.Count;
                var NewReportRooms         = new List <ReportRooms>();
                var ExistExceptReportRooms = new List <ReportRooms>();
                for (var i = 0; i < RoomIds.Count; i++)
                {
                    if (!ExistReprtRooms.Any(o => o.ID == ReportOfRoomIds[i]))
                    {
                        NewReportRooms.Add(new ReportRooms {
                            ReportID = Model.ID, Amount = Amount[i], Quantity = Quantity[i], RoomID = RoomIds[i], RoomName = RoomName[i], Deleted = false
                        });
                    }
                    else
                    {
                        ExistExceptReportRooms.Add(new ReportRooms {
                            ReportID = Model.ID, ID = ReportOfRoomIds[i], Amount = Amount[i], Quantity = Quantity[i], RoomID = RoomIds[i], RoomName = RoomName[i], Deleted = false
                        });
                    }
                }

                var RemoveReportRooms = new List <ReportRooms>();
                foreach (var item in ExistReprtRooms)
                {
                    if (!ExistExceptReportRooms.Any(o => o.ID == item.ID))
                    {
                        item.Deleted = true;
                    }
                }

                //NewReportRooms 有  ExistReprtRooms 沒有 要新增
                //var NewExceptReportRooms = NewReportRooms;

                //ExistReprtRooms 有 NewReportRooms 沒有要 移除
                //var RemoveReportRooms = ExistExceptReportRooms.Except(ExistReprtRooms).ToList();

                //foreach (var item in RemoveReportRooms)
                //{
                //    var Rroom = db.ReportRooms.Find(item.ID);
                //    if (Rroom != null)
                //    {
                //        Rroom.Deleted = true;
                //    }
                //}

                //db.ReportRooms.AddRange(NewExceptReportRooms);

                //if (!string.IsNullOrEmpty(Room))
                //{
                //    var RoomString = Room;
                //    var RoomSpilt = RoomString.Split(',');
                //    foreach (var ro in RoomSpilt)
                //    {
                //        var room = ro.Split('^');
                //        var id = int.Parse(room[0]);
                //        var amt = int.Parse(room[1]);
                //        var name = room[2];
                //        ReportRoomsOf.Add(new ReportRooms { ID = ID, RoomID = id, Amount = amt, RoomName = name });

                //        ReportRooms.Add(new ReportRooms { RoomID = id, Amount = amt, RoomName = name });

                //    }

                //    var rrIDs = ReportRoomsOf.Select(o => o.RoomID).ToList();

                //    var removemodel = db.ReportRooms.Where(o => o.ReportID == ID).ToList();
                //    db.ReportRooms.RemoveRange(removemodel);
                //Model.ReportRooms = NewExceptReportRooms.ToList();
                //}
                db.ReportRooms.AddRange(NewReportRooms);
                db.Log.Add(new Log {
                    TargetId = ID, Created = DateTime.Now, Creator = UserName, Remark = "ReportViewModel Edit", TargetType = "修改飯店回報資料"
                });

                db.SaveChanges();
            }
        }
Ejemplo n.º 14
0
        public void Edit()
        {
            var Session = HttpContext.Current.Session;

            using (var scope = new TransactionScope())
            {
                using (var _db = new WGHotelsEntities())
                {
                    var zhHotel = _db.HotelZH.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.Language    = Languages;
                    zhHotel.Certificate = Certificate;

                    var HotelEN = _db.HotelEN.Where(o => o.ParentId == zhHotel.ID).FirstOrDefault();
                    HotelEN.Name        = Nameus;
                    HotelEN.Address     = Addressus;
                    HotelEN.Area        = Area;
                    HotelEN.City        = City;
                    HotelEN.Facilities  = Facilies;
                    HotelEN.Features    = Featureus;
                    HotelEN.Enabled     = true;
                    HotelEN.LinkUrl     = LinkUrl;
                    HotelEN.Game        = Game;
                    HotelEN.Tel         = Tel;
                    HotelEN.ParentId    = zhHotel.ID;
                    HotelEN.Language    = Languages;
                    HotelEN.Certificate = Certificate;
                    #region # Images
                    if (Session[ImgKey] != null)
                    {
                        var Now      = DateTime.Now;
                        var images   = (List <ImageViewModel>)Session[ImgKey];
                        var dbImg    = _db.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");
                            _db.ImageStore.Add(new ImageStore
                            {
                                Created   = Now,
                                Extension = img.Extension,
                                Deleted   = false,
                                ReferIdUS = HotelEN.ID,
                                ReferIdZH = zhHotel.ID,
                                Type      = "Hotel",
                                Name      = fileName,
                                Image     = img.Image
                            });
                        }

                        _db.SaveChanges();
                        scope.Complete();
                    }
                    #endregion
                }
            }
        }
Ejemplo n.º 15
0
        public void Create()
        {
            using (var scope = new TransactionScope())
            {
                using (var _db = new WGHotelsEntities())
                {
                    var zhHotel = new HotelZH();
                    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;
                    zhHotel.Language    = Languages;
                    zhHotel.Certificate = Certificate;

                    _db.HotelZH.Add(zhHotel);
                    _db.SaveChanges();
                    // ZHdb.SaveChanges();
                    var ReferIdZH = zhHotel.ID;
                    var ReferIdUS = 0;


                    var HotelEN = new HotelEN
                    {
                        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,
                        Language    = Languages,
                        Certificate = Certificate
                    };

                    _db.HotelEN.Add(HotelEN);

                    _db.SaveChanges();
                    ReferIdUS = HotelEN.ID;
                    #region
                    var Session = HttpContext.Current.Session;

                    if (Session[ImgKey] != null)
                    {
                        var Now    = DateTime.Now;
                        var images = (List <ImageViewModel>)Session[ImgKey];
                        foreach (var img in images)
                        {
                            var fileName = Guid.NewGuid().GetHashCode().ToString("x");
                            _db.ImageStore.Add(new ImageStore
                            {
                                Created   = Now,
                                Extension = img.Extension,
                                Deleted   = false,
                                ReferIdUS = ReferIdUS,
                                ReferIdZH = ReferIdZH,
                                Type      = "Hotel",
                                Name      = fileName,
                                Image     = img.Image
                            });
                        }
                        _db.SaveChanges();
                    }
                    #endregion


                    scope.Complete();
                }
            }
        }