public ActionResult CreateRoom(IEnumerable <HttpPostedFileBase> files, [Bind(Include = "ChambreId,Titre,Prix,TypeDeLit,Disponibilité,NbChambres,ShortDescription,LongDescription")] Room room)
 {
     if (files == null)
     {
         return(View());
     }
     else
     {
         RoomImage roomImage;
         db.Rooms.Add(room);
         db.SaveChanges();
         idR = db.Rooms.ToList().Last().ChambreId;
         foreach (var img in files)
         {
             roomImage          = new RoomImage();
             roomImage.RoomId   = idR;
             roomImage.Name     = Path.GetFileName(img.FileName);
             roomImage.FullPath = Server.MapPath("/pic/rooms_pic/" + img.FileName);
             img.SaveAs(roomImage.FullPath);
             db.RoomImages.Add(roomImage);
             db.SaveChanges();
         }
     }
     return(RedirectToAction("roomList"));
 }
示例#2
0
        /// <summary>
        /// 根据房间图片id获取房间图片
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public RoomImage GetRoomImageByKey(Guid roomId, Guid id)
        {
            JXHotelDbContext dbContext = this.EFContext.dbContext as JXHotelDbContext;
            RoomImage        roomImage = dbContext.Rooms.Find(roomId).RoomImages.Where(Image => Image.Id.Equals(id)).FirstOrDefault();

            return(roomImage);
        }
示例#3
0
        public void Create(RoomImageDTO roomImageDto)
        {
            RoomImage roomImage = Mapper.Map <RoomImageDTO, RoomImage>(roomImageDto);

            _unitOfWork.RoomImages.Create(roomImage);
            _unitOfWork.Save();
        }
示例#4
0
        public Room AddRoom(RoomAddViewModel roomAddModel)
        {
            var findHouse = _adressProvider.GetHouses(roomAddModel.SelectStreetId)
                            .Where(x => x.Number == roomAddModel.NumberHouse)
                            .FirstOrDefault();

            if (findHouse == null)
            {
                NumberHouse numberHouse = new NumberHouse
                {
                    Number   = roomAddModel.NumberHouse,
                    StreetId = roomAddModel.SelectStreetId
                };

                _numberHomeRepository.Add(numberHouse);
                _numberHomeRepository.SaveChanges();

                findHouse = numberHouse;
            }

            roomAddModel.NumberHouseID = findHouse.Id;
            Room room;

            using (TransactionScope scope = new TransactionScope())
            {
                room = new Room
                {
                    HouseId    = roomAddModel.NumberHouseID,
                    Floor      = roomAddModel.Floor,
                    CountRooms = roomAddModel.CountRoom,
                    NumberRoom = roomAddModel.NumberRoom,
                    Price      = Convert.ToDecimal(roomAddModel.price),
                    Square     = Convert.ToDecimal(roomAddModel.Square),
                    Reserved   = roomAddModel.Reserved,
                    Sales      = roomAddModel.Sales
                };
                _roomsRepository.Add(room);
                _roomsRepository.SaveChanges();

                foreach (var item in roomAddModel.Images)
                {
                    var p = ImageToDataBase.ToBinaryArray(item);

                    RoomImage roomImages = new RoomImage
                    {
                        Name   = Guid.NewGuid().ToString() + ".jpg",
                        RoomId = room.Id,
                        Photo  = p
                    };

                    _roomImagesRepository.Add(roomImages);
                }
                _roomImagesRepository.SaveChanges();

                scope.Complete();
            }


            return(room);
        }
示例#5
0
        public async Task <RoomResponse> CreateFromContact(CreateRoomFromContactRequest request)
        {
            var    room   = new Room();
            string userId = _authHelper.GetUserId();

            room.Name        = request.Contact.ContactData.DisplayName;
            room.Type        = RoomType.Contact;
            room.PrivacyType = RoomPrivacyType.Private;
            room.CreatorId   = userId;

            var userRoom = new UserRoom();

            userRoom.ContactId = request.Contact.Id;
            room.UserRooms     = new List <UserRoom>();
            room.UserRooms.Add(userRoom);

            var contactDataImage = request.Contact.ContactData.Images.FirstOrDefault(x => x.Image.IsMain);

            if (!(contactDataImage is null))
            {
                room.RoomImages = new List <RoomImage>();
                var roomImage = new RoomImage();
                roomImage.ImageId = contactDataImage is null ? null : contactDataImage.ImageId;
                room.RoomImages.Add(roomImage);
            }
            await _roomRepository.Add(room);

            RoomResponse response = _mapper.Map <RoomResponse>(room);

            return(response);
        }
示例#6
0
        public RoomImage WriteImage(IFormFile imageRequest, Guid roomId)
        {
            var imageId      = Guid.NewGuid();
            var imageName    = imageId.ToString() + ".jpeg";
            var imageSetPath = Path.Combine(_hostingEnvironment.ContentRootPath, @"files/");
            var imagePath    = imageSetPath + imageName;

            var directory = new DirectoryInfo(imageSetPath);

            if (!directory.Exists)
            {
                directory.Create();
            }

            using var image        = Image.Load(imageRequest.OpenReadStream());
            using var outputStream = new FileStream(imagePath, FileMode.Create);
            //image.Mutate(t => t.Resize(new ResizeOptions { Mode = ResizeMode.Max, Size = new Size(280, 280) }));
            image.Mutate(t => t.Resize(320, 240));
            image.SaveAsJpeg(outputStream);
            int length = (int)outputStream.Length;

            byte[] bytes = new byte[length];
            outputStream.Read(bytes, 0, length);

            var newImage = new RoomImage()
            {
                Id        = imageId,
                ImagePath = imagePath,
                RoomId    = roomId,
            };

            return(newImage);
        }
        public ActionResult DetailsRoom(Room UpdatedRoom, IEnumerable <HttpPostedFileBase> files, int id)
        {
            var currentRoom = db.Rooms.Find(id);

            currentRoom.Disponibilité    = UpdatedRoom.Disponibilité;
            currentRoom.Prix             = UpdatedRoom.Prix;
            currentRoom.NbChambres       = UpdatedRoom.NbChambres;
            currentRoom.ShortDescription = UpdatedRoom.ShortDescription;
            currentRoom.LongDescription  = UpdatedRoom.LongDescription;
            currentRoom.TypeDeLit        = UpdatedRoom.TypeDeLit;
            currentRoom.Titre            = UpdatedRoom.Titre;
            db.SaveChanges();
            foreach (var img in files)
            {
                if (img != null)
                {
                    RoomImage roomImage = new RoomImage();
                    roomImage.RoomId   = id;
                    roomImage.Name     = Path.GetFileName(img.FileName);
                    roomImage.FullPath = Server.MapPath("/pic/rooms_pic/" + img.FileName);
                    img.SaveAs(roomImage.FullPath);
                    db.RoomImages.Add(roomImage);
                    db.SaveChanges();
                }
            }
            ViewBag.imagesCurrentRoom = db.RoomImages.ToList().Where(c => c.RoomId == id);
            return(View(currentRoom));
        }
示例#8
0
        private void createRoomImageObjectAndAddToList(string pathToImage, Room room)
        {
            roomImage = new RoomImage();

            roomImage.ImageRoomID = Guid.NewGuid();
            roomImage.Path        = pathToImage;
            roomImage.Room        = room;
            roomImagesList.Add(roomImage);
        }
        public bool SaveNewImages(IList <RoomImageDTO> images)
        {
            bool succeed = false;
            IList <RoomImage> savedImages = new List <RoomImage>();

            if (images.Count != 0)
            {
                IList <RoomImage> allImages = imagesRepo.GetAll().ToList();
                if (allImages.Count > 0)
                {
                    allImages = allImages.Where(x => x.HotelCode == images[0].HotelCode && x.RoomCode == images[0].RoomCode).ToList();
                }
                foreach (RoomImageDTO imageDto in images)
                {
                    RoomImage image;
                    bool      update = false;
                    if (allImages.Any(x => x.FileName == imageDto.FileName))
                    {
                        image  = allImages.Where(x => x.FileName == imageDto.FileName).Single();
                        update = true;
                    }
                    else
                    {
                        image            = new RoomImage();
                        image.InsertDate = DateTime.Now;
                    }
                    image.HotelCode    = imageDto.HotelCode;
                    image.RoomCode     = imageDto.RoomCode;
                    image.FileName     = imageDto.FileName;
                    image.ImageCaption = imageDto.ImageCaption;
                    image.ImageUrl     = imageDto.ImageUrl;
                    image.LanguageID   = imageDto.LanguageID;
                    image.UpdateDate   = DateTime.Now;
                    if (update == true)
                    {
                        imagesRepo.Update(image);
                    }
                    else
                    {
                        savedImages.Add(image);
                    }
                }
            }
            try
            {
                imagesRepo.Add(savedImages);
                unitOfWork.Commit();
                succeed = true;
            }
            catch (Exception e)
            {
                logger.Error("Exception: " + e.ToString());
                throw;
            }
            return(succeed);
        }
示例#10
0
        public RoomImage AddRoomImage(int roomId, string path)
        {
            RoomImage roomImage = new RoomImage();

            roomImage.RoomId    = roomId;
            roomImage.ImagePath = path;
            _db.RoomImages.Add(roomImage);
            _db.SaveChanges();
            return(roomImage);
        }
        public IActionResult Post([FromBody] RoomImage image)
        {
            var    imageFromDb = _repository.GetRoomImage(image.Id);
            string webRootPath = _hostingEnvironment.WebRootPath;
            var    imagePath   = imageFromDb.ImagePath.Replace('/', '\\');
            var    fullPath    = Path.Combine(webRootPath, "uploads", imagePath);

            _repository.DeleteRoomImage(imageFromDb, fullPath);
            return(StatusCode(202));
        }
示例#12
0
        //Add Room Image
        public RoomImage AddRoomImage(int roomId, string path)
        {
            //New instance of RoomImage Created to add to DB
            RoomImage roomImage = new RoomImage();

            roomImage.RoomId    = roomId;
            roomImage.ImagePath = path;
            _db.RoomImages.Add(roomImage);
            _db.SaveChanges();
            return(roomImage);
        }
示例#13
0
        public string DeleteRoomImage(RoomImage image, string fileName)
        {
            if (System.IO.File.Exists(fileName))
            {
                System.IO.File.Delete(fileName);
            }

            _db.RoomImages.Remove(image);
            _db.SaveChanges();
            return("File Deleted");
        }
        private async Task Json_Paring_Img(string json)
        {
            try
            {
                JObject obj = JObject.Parse(json);

                if (total_number == 0)
                {
                    //Console.WriteLine(obj["total"].ToString());
                    total_number = int.Parse(obj["total"].ToString());
                }

                JArray hotel_hotels = JArray.Parse(obj["hotels"].ToString());
                foreach (JObject itemObj in hotel_hotels)
                {
                    if (itemObj.ContainsKey("images") == true)
                    {
                        JArray hotel_images = JArray.Parse(itemObj["images"].ToString());
                        foreach (JObject itemObj2 in hotel_images)
                        {
                            if (itemObj2["imageTypeCode"].ToString().Equals("HAB"))
                            {
                                if (itemObj2.ContainsKey("roomCode") == true)
                                {
                                    RoomImage contents = new RoomImage();

                                    contents.hotel_code            = Convert.ToInt64(itemObj["code"].ToString());
                                    contents.hotel_name            = itemObj["name"]["content"].ToString();
                                    contents.hotel_countryCode     = itemObj["countryCode"].ToString();
                                    contents.hotel_destinationCode = itemObj["destinationCode"].ToString();
                                    contents.imageOrder            = Convert.ToInt64(itemObj2["order"].ToString());
                                    contents.imageTypeCode         = itemObj2["imageTypeCode"].ToString();

                                    string imageroomCode_tmp = itemObj2["roomCode"].ToString();
                                    contents.imageroomCode = imageroomCode_tmp;
                                    var linq = (from r in RoomDescMomoryDB where r.room_code == imageroomCode_tmp select new { r.room_description }).First();
                                    contents.room_typeDescription = linq.room_description.ToString();

                                    contents.imagePath = itemObj2["path"].ToString();

                                    HBRoomImageList.Add(contents);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#15
0
        public async Task <ActionResult> UploadRoomImage(int roomId, string hotelId, HttpPostedFileBase img)
        {
            string fullPath  = Utility.SaveImage(img, HttpContext);
            string imgName   = Path.GetFileName(fullPath);
            var    roomImage = new RoomImage
            {
                RoomId = roomId,
                Title  = imgName
            };
            await roomRepository.CreateRoomImage(roomImage);

            return(Redirect(Constants.Constants.RoomsIndexUrl + "?roomId=" + roomId + "&hotelId=" + hotelId));
        }
示例#16
0
        public bool UpdateRoomTypeImages(List <ImageUpdateItemDTO> Images)
        {
            bool succeed = false;
            IList <ImageUpdateItemDTO> updateImages = new List <ImageUpdateItemDTO>();
            IList <RoomImage>          deleteImages = new List <RoomImage>();
            IList <RoomImage>          allImages    = imagesRepo.GetAll().ToList();

            if (Images.Count != 0)
            {
                if (allImages.Count > 0)
                {
                    allImages = allImages.Where(x => x.HotelCode == Images[0].HotelCode && x.RoomCode == Images[0].RoomCode).ToList();
                }
                deleteImages = allImages.Where(i1 => !Images.Any(i2 => i2.FileName == i1.FileName)).ToList();
                updateImages = Images.Where(i1 => allImages.Any(i2 => i2.FileName == i1.FileName)).ToList();
                foreach (ImageUpdateItemDTO imageDto in updateImages)
                {
                    RoomImage image = allImages.Where(x => x.FileName == imageDto.FileName).First();
                    image.ImageCaption = imageDto.ImageCaption;
                    if (imageDto.FileName != imageDto.ChangedFileName)
                    {
                        image.ImageUrl = image.ImageUrl.Substring(0, image.ImageUrl.LastIndexOf('/')) + "/" + imageDto.ChangedFileName;
                        image.FileName = imageDto.ChangedFileName;
                    }
                    image.LanguageID = imageDto.LanguageID;
                    image.UpdateDate = DateTime.Now;
                    image.SortOrder  = imageDto.SortOrder;
                    imagesRepo.Update(image);
                }
                foreach (RoomImage deleteimage in deleteImages)
                {
                    imagesRepo.Delete(deleteimage);
                }
            }
            try
            {
                unitOfWork.Commit();
                succeed = true;
            }
            catch (Exception e)
            {
                logger.Error("Exception: " + e.ToString());
                throw;
            }
            return(succeed);
        }
示例#17
0
        public async Task <ActionResult> CreateRoom(string hotelId, Room room, HttpPostedFileBase img)
        {
            room.HotelId = hotelId;
            if (ModelState.IsValid)
            {
                var createdRoom = await roomRepository.CreateRoom(room);

                string    fullPath = Utility.SaveImage(img, HttpContext);
                string    imgName  = Path.GetFileName(fullPath);
                RoomImage roomImg  = new RoomImage
                {
                    RoomId = createdRoom.Id,
                    Title  = imgName
                };
                await roomRepository.CreateRoomImage(roomImg);
            }
            return(Redirect(Constants.Constants.RoomsIndexUrl + "?hotelId=" + hotelId));
        }
        public JsonResult Edit(RoomImage model)
        {
            try
            {
                if (model.RoomImageId > 0)
                {
                    var entity = _RoomImageService.GetById(model.RoomImageId);

                    //修改
                    entity.BaseImageId = model.BaseImageId;
                    entity.Type        = model.Type;

                    model.EditPersonId = Loginer.AccountId;
                    model.EditTime     = DateTime.Now;
                    _RoomImageService.Update(model);
                    return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    //if (_RoomImageService.CheckBusinessName(model.Name) > 0)
                    //    return Json(new { Status = Successed.Repeat }, JsonRequestBehavior.AllowGet);
                    //添加
                    model.Status         = (int)EnabledEnum.效;
                    model.IsDelete       = (int)IsDeleteEnum.效;
                    model.CreatePersonId = Loginer.AccountId;
                    model.CreateTime     = DateTime.Now;
                    model.EditPersonId   = Loginer.AccountId;
                    model.EditTime       = DateTime.Now;
                    model = _RoomImageService.Insert(model);
                    if (model.RoomImageId > 0)
                    {
                        return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet));
            }
        }
示例#19
0
        void ReleaseDesignerOutlets()
        {
            if (BottomButton != null)
            {
                BottomButton.Dispose();
                BottomButton = null;
            }

            if (LeftButton != null)
            {
                LeftButton.Dispose();
                LeftButton = null;
            }

            if (OkLootButton != null)
            {
                OkLootButton.Dispose();
                OkLootButton = null;
            }

            if (RightButton != null)
            {
                RightButton.Dispose();
                RightButton = null;
            }

            if (RoomImage != null)
            {
                RoomImage.Dispose();
                RoomImage = null;
            }

            if (TopButton != null)
            {
                TopButton.Dispose();
                TopButton = null;
            }

            if (TreasureFoundLabel != null)
            {
                TreasureFoundLabel.Dispose();
                TreasureFoundLabel = null;
            }
        }
示例#20
0
        public JsonResult SaveRoomFiles(string description, string roomNumber)
        {
            string Message, fileName, actualFileName;

            Message = fileName = actualFileName = string.Empty;
            bool flag = false;

            if (Request.Files != null)
            {
                var file = Request.Files[0];
                actualFileName = file.FileName;
                fileName       = Guid.NewGuid() + Path.GetExtension(file.FileName);
                int size = file.ContentLength;

                try
                {
                    file.SaveAs(Path.Combine(Server.MapPath("~/UploadedFiles"), fileName));

                    RoomImage f = new RoomImage
                    {
                        FileName    = actualFileName,
                        FilePath    = fileName,
                        Description = description,
                        FileSize    = size,
                        RoomNumber  = roomNumber
                    };
                    using (BootCampEntities dc = new BootCampEntities())
                    {
                        dc.RoomImages.Add(f);
                        dc.SaveChanges();
                        Message = "File uploaded successfully";
                        flag    = true;
                    }
                }
                catch (Exception)
                {
                    Message = "File upload failed! Please try again";
                }
            }
            return(new JsonResult {
                Data = new { Message = Message, Status = flag }
            });
        }
示例#21
0
        /// <summary>
        /// Validates and saves all of the uploaded images to the database.
        /// </summary>
        /// <param name="images"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task UploadImagesAsync(List <IFormFile> images, int id)
        {
            var theMain = true;

            foreach (IFormFile image in images)
            {
                IFormFile a = image;
                var       formFileContent =
                    await FileHelper.ProcessFormFile <RoomViewModel>(
                        image, ModelState, _permittedExtensions,
                        _fileSizeLimit);

                var file = new RoomImage()
                {
                    Content       = formFileContent,
                    UntrustedName = image.FileName,
                    RoomId        = id,
                    IsMain        = theMain
                };
                await _portalService.CreateRoomImage(file);

                theMain = false;
            }
        }
 /// <summary>
 /// 删除实体
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public void Delete(RoomImage model)
 {
     this._repoRoomImage.Delete(model);
 }
 /// <summary>
 /// 修改实体
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public void Update(RoomImage model)
 {
     this._repoRoomImage.Update(model);
 }
        private async Task Json_Paring(string target_parsing_Data, string json)
        {
            try
            {
                JObject obj = JObject.Parse(json);


                if (total_number == 0)
                {
                    //Console.WriteLine(obj["total"].ToString());
                    total_number = int.Parse(obj["total"].ToString());
                }

                JArray hotel_hotels = JArray.Parse(obj["hotels"].ToString());

                switch (target_parsing_Data)
                {
                case "HT":

                    foreach (JObject itemObj in hotel_hotels)
                    {
                        HotelInformation contents = new HotelInformation();

                        contents.code = Convert.ToInt64(itemObj["code"].ToString());
                        contents.name = itemObj["name"]["content"].ToString();


                        if (itemObj.ContainsKey("exclusiveDeal") == true)
                        {
                            if (Convert.ToInt64(itemObj["exclusiveDeal"].ToString()) == 1)
                            {
                                contents.isGnD = "Y";
                            }
                        }

                        if (itemObj.ContainsKey("countryCode") == true)
                        {
                            string countryCode_tmp = itemObj["countryCode"].ToString();
                            contents.countryCode = countryCode_tmp;
                            var linq = (from c in CountryDescMomoryDB where c.country_code == countryCode_tmp select new { c.country_description }).FirstOrDefault();
                            if (linq != null)
                            {
                                contents.countryName = linq.country_description.ToString();
                            }
                        }

                        if (itemObj.ContainsKey("destinationCode") == true)
                        {
                            string destinationCode_tmp = itemObj["destinationCode"].ToString();
                            contents.destinationCode = destinationCode_tmp;
                            var linq = (from d in DestinationDescMomoryDB where d.destinatin_code == destinationCode_tmp select new { d.destinatin_name }).FirstOrDefault();
                            if (linq != null)
                            {
                                contents.destinationName = linq.destinatin_name.ToString();
                            }
                        }

                        if (itemObj.ContainsKey("zoneCode") == true)
                        {
                            contents.zoneCode = itemObj["zoneCode"].ToString();
                        }

                        if (itemObj.ContainsKey("coordinates") == true)
                        {
                            contents.longitude = itemObj["coordinates"]["longitude"].ToString();
                            contents.latitude  = itemObj["coordinates"]["latitude"].ToString();
                        }

                        if (itemObj.ContainsKey("chainCode") == true)
                        {
                            contents.chainCode = itemObj["chainCode"].ToString();
                        }

                        if (itemObj.ContainsKey("accommodationTypeCode") == true)
                        {
                            contents.accommodationTypeCode = itemObj["accommodationTypeCode"].ToString();
                        }

                        if (itemObj.ContainsKey("address") == true)
                        {
                            contents.address = itemObj["address"]["content"].ToString();
                        }

                        if (itemObj.ContainsKey("postalCode") == true)
                        {
                            contents.postalCode = itemObj["postalCode"].ToString();
                        }

                        if (itemObj.ContainsKey("city") == true)
                        {
                            contents.city = itemObj["city"]["content"].ToString();
                        }

                        if (itemObj.ContainsKey("S2C") == true)
                        {
                            contents.S2C = itemObj["S2C"].ToString();
                        }

                        if (itemObj.ContainsKey("phones") == true)
                        {
                            JArray hotel_phones = JArray.Parse(itemObj["phones"].ToString());
                            foreach (JObject itemObj2 in hotel_phones)
                            {
                                if (itemObj2["phoneType"].ToString().Equals("PHONEBOOKING"))
                                {
                                    //Console.WriteLine("phones");
                                    contents.phoneNumber = itemObj2["phoneNumber"].ToString();
                                    //Console.WriteLine(itemObj2["phoneNumber"].ToString());
                                }
                                //        //else if(itemObj2["phoneType"].ToString() == "PHONEHOTEL")
                                //        //{
                                //        //    contents.phoneNumber = itemObj2["phoneNumber"].ToString();
                                //        //}
                            }
                        }
                        hotelContentsList.Add(contents);
                    }
                    break;

                case "IMG":
                    foreach (JObject itemObj in hotel_hotels)
                    {
                        if (itemObj.ContainsKey("images") == true)
                        {
                            JArray hotel_images = JArray.Parse(itemObj["images"].ToString());
                            foreach (JObject itemObj2 in hotel_images)
                            {
                                string room_only_yn = "";

                                for (int i = 0; i < option_wrapPanel.Children.Count; i++)
                                {
                                    CheckBox option_chbx = (CheckBox)option_wrapPanel.Children[i];
                                    if ((bool)option_chbx.IsChecked)
                                    {
                                        room_only_yn = option_chbx.Name;
                                    }
                                    Console.WriteLine(room_only_yn);
                                }

                                if (room_only_yn == "")
                                {
                                    RoomImage contents = new RoomImage();

                                    contents.hotel_code = Convert.ToInt64(itemObj["code"].ToString());
                                    contents.hotel_name = itemObj["name"]["content"].ToString();


                                    if (itemObj.ContainsKey("countryCode") == true)
                                    {
                                        string countryCode_tmp = itemObj["countryCode"].ToString();
                                        contents.hotel_countryCode = countryCode_tmp;
                                        var linq = (from c in CountryDescMomoryDB where c.country_code == countryCode_tmp select new { c.country_description }).FirstOrDefault();
                                        if (linq != null)
                                        {
                                            contents.hotel_countryName = linq.country_description.ToString();
                                        }
                                    }


                                    if (itemObj.ContainsKey("destinationCode") == true)
                                    {
                                        string destinationCode_tmp = itemObj["destinationCode"].ToString();
                                        contents.hotel_destinationCode = destinationCode_tmp;
                                        var linq = (from d in DestinationDescMomoryDB where d.destinatin_code == destinationCode_tmp select new { d.destinatin_name }).FirstOrDefault();
                                        if (linq != null)
                                        {
                                            contents.hotel_destinationName = linq.destinatin_name.ToString();
                                        }
                                    }

                                    contents.imageOrder    = Convert.ToInt64(itemObj2["order"].ToString());
                                    contents.imageTypeCode = itemObj2["imageTypeCode"].ToString();
                                    if (itemObj2.ContainsKey("roomCode") == true)
                                    {
                                        string imageroomCode_tmp = itemObj2["roomCode"].ToString();
                                        contents.imageroomCode = imageroomCode_tmp;
                                        var linq = (from r in RoomDescMomoryDB where r.room_code == imageroomCode_tmp select new { r.room_description }).FirstOrDefault();
                                        if (linq != null)
                                        {
                                            contents.room_typeDescription = linq.room_description.ToString();
                                        }
                                    }
                                    contents.imagePath = itemObj2["path"].ToString();

                                    HBRoomImageList.Add(contents);
                                }
                                else
                                {
                                    if (itemObj2["imageTypeCode"].ToString().Equals("HAB"))
                                    {
                                        if (itemObj2.ContainsKey("roomCode") == true)
                                        {
                                            RoomImage contents = new RoomImage();

                                            contents.hotel_code = Convert.ToInt64(itemObj["code"].ToString());
                                            contents.hotel_name = itemObj["name"]["content"].ToString();
                                            if (itemObj.ContainsKey("countryCode") == true)
                                            {
                                                string countryCode_tmp = itemObj["countryCode"].ToString();
                                                contents.hotel_countryCode = countryCode_tmp;
                                                var roonm_only_linq = (from c in CountryDescMomoryDB where c.country_code == countryCode_tmp select new { c.country_description }).FirstOrDefault();
                                                if (roonm_only_linq != null)
                                                {
                                                    contents.hotel_countryName = roonm_only_linq.country_description.ToString();
                                                }
                                            }


                                            if (itemObj.ContainsKey("destinationCode") == true)
                                            {
                                                string destinationCode_tmp = itemObj["destinationCode"].ToString();
                                                contents.hotel_destinationCode = destinationCode_tmp;
                                                var roonm_only_linq = (from d in DestinationDescMomoryDB where d.destinatin_code == destinationCode_tmp select new { d.destinatin_name }).FirstOrDefault();
                                                if (roonm_only_linq != null)
                                                {
                                                    contents.hotel_destinationName = roonm_only_linq.destinatin_name.ToString();
                                                }
                                            }
                                            contents.imageOrder    = Convert.ToInt64(itemObj2["order"].ToString());
                                            contents.imageTypeCode = itemObj2["imageTypeCode"].ToString();

                                            string imageroomCode_tmp = itemObj2["roomCode"].ToString();
                                            contents.imageroomCode = imageroomCode_tmp;
                                            var linq = (from r in RoomDescMomoryDB where r.room_code == imageroomCode_tmp select new { r.room_description }).FirstOrDefault();
                                            if (linq != null)
                                            {
                                                contents.room_typeDescription = linq.room_description.ToString();
                                            }


                                            contents.imagePath = itemObj2["path"].ToString();

                                            HBRoomImageList.Add(contents);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;

                case "WILD":
                    foreach (JObject itemObj in hotel_hotels)
                    {
                        Console.WriteLine("123");
                        if (itemObj.ContainsKey("wildcards") == true)
                        {
                            Console.WriteLine("1234");
                            JArray hotel_wildcards = JArray.Parse(itemObj["wildcards"].ToString());
                            foreach (JObject itemObj2 in hotel_wildcards)
                            {
                                HotelWildCards contents = new HotelWildCards();

                                contents.hotel_code = Convert.ToInt64(itemObj["code"].ToString());
                                contents.hotel_name = itemObj["name"]["content"].ToString();


                                if (itemObj.ContainsKey("countryCode") == true)
                                {
                                    string countryCode_tmp = itemObj["countryCode"].ToString();
                                    contents.hotel_countryCode = countryCode_tmp;
                                    var linq = (from c in CountryDescMomoryDB where c.country_code == countryCode_tmp select new { c.country_description }).FirstOrDefault();
                                    if (linq != null)
                                    {
                                        contents.hotel_countryName = linq.country_description.ToString();
                                    }
                                }


                                if (itemObj.ContainsKey("destinationCode") == true)
                                {
                                    string destinationCode_tmp = itemObj["destinationCode"].ToString();
                                    contents.hotel_destinationCode = destinationCode_tmp;
                                    var linq = (from d in DestinationDescMomoryDB where d.destinatin_code == destinationCode_tmp select new { d.destinatin_name }).FirstOrDefault();
                                    if (linq != null)
                                    {
                                        contents.hotel_destinationName = linq.destinatin_name.ToString();
                                    }
                                }


                                if (itemObj2.ContainsKey("roomType") == true)
                                {
                                    string wildcard_roomType_tmp = itemObj2["roomType"].ToString();
                                    contents.wildcard_roomType = wildcard_roomType_tmp;
                                    var linq = (from r in RoomDescMomoryDB where r.room_code == wildcard_roomType_tmp select new { r.room_description }).FirstOrDefault();
                                    if (linq != null)
                                    {
                                        contents.wildcard_roomTypeDescription = linq.room_description.ToString();
                                    }
                                }



                                if (itemObj2.ContainsKey("roomCode") == true)
                                {
                                    contents.wildcard_roomCode = itemObj2["roomCode"].ToString();
                                }
                                if (itemObj2.ContainsKey("characteristicCode") == true)
                                {
                                    contents.wildcard_characteristicCode = itemObj2["characteristicCode"].ToString();
                                }
                                if (itemObj2.ContainsKey("hotelRoomDescription") == true)
                                {
                                    contents.wildcard_hotelRoomDescription = itemObj2["hotelRoomDescription"]["content"].ToString();
                                }

                                HBWildCardsList.Add(contents);
                            }
                        }
                    }
                    break;

                case "HTROOM":
                    foreach (JObject itemObj in hotel_hotels)
                    {
                        //Console.WriteLine("123");
                        if (itemObj.ContainsKey("rooms") == true)
                        {
                            //Console.WriteLine("1234");
                            JArray hotel_roomtypes = JArray.Parse(itemObj["rooms"].ToString());
                            foreach (JObject itemObj2 in hotel_roomtypes)
                            {
                                HotelRoomTypeInfo contents = new HotelRoomTypeInfo();

                                contents.hotel_code = Convert.ToInt64(itemObj["code"].ToString());
                                contents.hotel_name = itemObj["name"]["content"].ToString();


                                if (itemObj.ContainsKey("countryCode") == true)
                                {
                                    string countryCode_tmp = itemObj["countryCode"].ToString();
                                    contents.hotel_countryCode = countryCode_tmp;
                                    var linq = (from c in CountryDescMomoryDB where c.country_code == countryCode_tmp select new { c.country_description }).FirstOrDefault();
                                    if (linq != null)
                                    {
                                        contents.hotel_countryName = linq.country_description.ToString();
                                    }
                                }


                                if (itemObj.ContainsKey("destinationCode") == true)
                                {
                                    string destinationCode_tmp = itemObj["destinationCode"].ToString();
                                    contents.hotel_destinationCode = destinationCode_tmp;
                                    var linq = (from d in DestinationDescMomoryDB where d.destinatin_code == destinationCode_tmp select new { d.destinatin_name }).FirstOrDefault();
                                    if (linq != null)
                                    {
                                        contents.hotel_destinationName = linq.destinatin_name.ToString();
                                    }
                                }


                                if (itemObj2.ContainsKey("roomCode") == true)
                                {
                                    string ht_roomCode_tmp = itemObj2["roomCode"].ToString();
                                    contents.roomCode = ht_roomCode_tmp;
                                    var linq = (from r in RoomDescMomoryDB where r.room_code == ht_roomCode_tmp select new { r.room_description }).FirstOrDefault();
                                    if (linq != null)
                                    {
                                        contents.roomCodeDescription = linq.room_description.ToString();
                                    }
                                }



                                if (itemObj2.ContainsKey("roomType") == true)
                                {
                                    contents.roomType = itemObj2["roomType"].ToString();
                                }
                                if (itemObj2.ContainsKey("characteristicCode") == true)
                                {
                                    contents.characteristicCode = itemObj2["characteristicCode"].ToString();
                                }

                                HBHTRoomTypeList.Add(contents);
                            }
                        }
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#25
0
        public override void SetAndRefreshData(Structures.BlockBase blockBase)
        {
            base.SetAndRefreshData(blockBase);

            if (ReferenceEquals(_diskBlock, blockBase))
            {
                return;
            }

            _loading = true;

            _diskBlock = (DiskBlock)blockBase;

            var roomBlock = (RoomBlock)_diskBlock.Childrens.Single(r => r.GetType() == typeof(RoomBlock));

            //Configurando as palettas Padrão
            PalettesData       pals         = roomBlock.GetPALS();
            List <PaletteData> paletteDatas = null;

            if (pals != null)
            {
                paletteDatas = pals.GetWRAP().GetAPALs();
            }
            Palettes.Items.Clear();
            if (paletteDatas != null)
            {
                for (int i = 0; i < paletteDatas.Count; i++)
                {
                    Palettes.Items.Add("Palette #" + i);
                }
            }
            else
            {
                Palettes.Items.Add("Palette #0");
            }
            if (Palettes.SelectedIndex < 0)
            {
                Palettes.SelectedIndex = 0;
            }
            Palettes.Visible = Palettes.Items.Count != 1;
            //Termino de configuração das palettas padrão

            TreeImages.Nodes.Clear();
            _roomImages = new Dictionary <string, RoomBlockImageControl>();
            CreateInfos = new Dictionary <string, ClassCreateInfo>();

            TreeNode backgroundNode = null;

            RoomImage RMIM = roomBlock.GetRMIM();

            if (RMIM.GetIM00().GetSMAP().Strips.Count > 0)
            {
                var createInfo = new ClassCreateInfo();
                createInfo.ImageType = ImageType.Background;
                createInfo.ControlId = "Background";
                CreateInfos.Add("Background", createInfo);

                backgroundNode = TreeImages.Nodes.Add("Background", "Room Background");
            }

            List <ZPlane> zPlanes = RMIM.GetIM00().GetZPlanes();

            for (int i = 0; i < zPlanes.Count; i++)
            {
                string planeKey = "Background ZPlane " + (i + 1);

                var createInfo = new ClassCreateInfo();
                createInfo.ImageType   = ImageType.ZPlane;
                createInfo.ControlId   = planeKey;
                createInfo.ZPlaneIndex = i;
                CreateInfos.Add(planeKey, createInfo);

                if (backgroundNode == null)
                {
                    TreeImages.Nodes.Add(planeKey, "Background Z-Plane " + (i + 1));
                }
                else
                {
                    backgroundNode.Nodes.Add(planeKey, "Z-Plane " + (i + 1));
                }
            }

            //Objetos
            List <ObjectImage> OBIMs = roomBlock.GetOBIMs();

            for (int i = 0; i < OBIMs.Count; i++)
            {
                TreeNode nodeObject = TreeImages.Nodes.Add("_object" + i, "Object " + i);

                ObjectImage      item = OBIMs[i];
                List <ImageData> IMXX = item.GetIMxx();

                for (int j = 0; j < IMXX.Count; j++)
                {
                    ImageData image = IMXX[j];

                    string   objectImageKey = string.Format("Object #{0}-{1}", i, j);
                    TreeNode nodeImage      = nodeObject.Nodes.Add(objectImageKey, "Image " + j);

                    var createInfo = new ClassCreateInfo();
                    createInfo.ImageType   = ImageType.Object;
                    createInfo.ControlId   = objectImageKey;
                    createInfo.ObjectIndex = i;
                    createInfo.ImageIndex  = j;
                    CreateInfos.Add(objectImageKey, createInfo);

                    List <ZPlane> objectZPlanes = image.GetZPlanes();
                    for (int k = 0; k < objectZPlanes.Count; k++)
                    {
                        string objectZPlaneKey = string.Format("Object #{0}-{1} ZPlane {2}", i, j, (k + 1));

                        nodeImage.Nodes.Add(objectZPlaneKey, "Z-Plane " + k);

                        createInfo             = new ClassCreateInfo();
                        createInfo.ImageType   = ImageType.ObjectsZPlane;
                        createInfo.ControlId   = objectZPlaneKey;
                        createInfo.ObjectIndex = i;
                        createInfo.ImageIndex  = j;
                        createInfo.ZPlaneIndex = k;
                        CreateInfos.Add(objectZPlaneKey, createInfo);
                    }
                }

                //Remove os itens se não tiver nenhuma imagem neles, só serve para poluir a tela.
                if (nodeObject.Nodes.Count == 0)
                {
                    TreeImages.Nodes.Remove(nodeObject);
                }
            }

            //Costumes
            List <Costume> costumesList = _diskBlock.Childrens.OfType <Costume>().ToList();

            for (int i = 0; i < costumesList.Count; i++)
            {
                TreeNode costume = TreeImages.Nodes.Add("_costume" + i, string.Format("Costume {0}", i.ToString().PadLeft(3, '0')));

                Costume currentCostume = costumesList[i];
                for (int j = 0; j < currentCostume.Pictures.Count; j++)
                {
                    //Vamos filtras apenas os frames que tem imagem para decodificar.
                    if (currentCostume.Pictures[j].ImageData.Length == 0 ||
                        currentCostume.Pictures[j].ImageData.Length == 1 && currentCostume.Pictures[j].ImageData[0] == 0)
                    {
                        continue;
                    }

                    string costumeKey = string.Format("Costume #{0}-{1}", i, j);

                    var createInfo = new ClassCreateInfo();
                    createInfo.ImageType  = ImageType.Costume;
                    createInfo.Costume    = currentCostume;
                    createInfo.ControlId  = costumeKey;
                    createInfo.ImageIndex = j;
                    CreateInfos.Add(costumeKey, createInfo);

                    costume.Nodes.Add(costumeKey, string.Format("Frame {0}", j.ToString().PadLeft(2, '0')));
                }
            }

            TreeImages.ExpandAll();
            TreeImages.SelectedNode = TreeImages.Nodes[0];

            _loading = false;
        }
 public RoomImage Insert(RoomImage model)
 {
     return(this._repoRoomImage.Insert(model));
 }
示例#27
0
 public RoomImage Add(RoomImage roomImages)
 {
     _context.RoomsImages.Add(roomImages);
     return(roomImages);
 }
示例#28
0
        /// <summary>
        /// 根据房间图片id获取房间图片
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public RoomImageDataObject GetRoomImageByKey(Guid roomId, Guid id)
        {
            RoomImage roomImage = roomRepository.GetRoomImageByKey(roomId, id);

            return(AutoMapper.Mapper.Map <RoomImage, RoomImageDataObject>(roomImage));
        }
示例#29
0
 public async Task CreateRoomImage(RoomImage img)
 {
     db.RoomImages.Add(img);
     await db.SaveChangesAsync();
 }
示例#30
0
 public void Remove(RoomImage roomImages)
 {
     _context.RoomsImages.Remove(roomImages);
 }