public List <HotelDetail> Detail(int id) { List <Hotel> hotels = hoteldbContext.Hotel.ToList(); HotelDetail hd = new HotelDetail(); var hotelImage = hoteldbContext.HotelImage.Where(c => c.HotelId == id).Select(a => a.ImagePath).FirstOrDefault(); var hotelComment = hoteldbContext.HotelComment.Where(c => c.HotelId == id).Select(a => a.Comment).FirstOrDefault(); var hotelScore = hoteldbContext.HotelScore.Where(c => c.HotelId == id).Select(a => a.ScoreValue).FirstOrDefault(); var hoteldetail = (from h in hoteldbContext.Hotel join hA in hoteldbContext.HotelAddress on h.Id equals hA.HotelId into list1 from l1 in list1.DefaultIfEmpty() join hC in hoteldbContext.HotelContact on h.Id equals hC.HotelId into list2 from l2 in list2.DefaultIfEmpty() where h.Id == id select new HotelDetail { Id = h.Id, Name = h.Name, Address = l1.AddressText, Contact = l2.ContactValue, ImagePath = hotelImage, Comment = hotelComment, Score = (int)hotelScore }).ToList(); return(hoteldetail); }
public IHttpActionResult PutHotelDetail(int id, HotelDetail hotelDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != hotelDetail.HotelId) { return(BadRequest()); } db.Entry(hotelDetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!HotelDetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create(HotelDetail hotelDetail) { if (Session["UserRole"] != null && Session["UserRole"].ToString() == "1") { if (ModelState.IsValid) { string fileName = Path.GetFileName(hotelDetail.ImageFile.FileName); hotelDetail.HotelImage = "~/Image/" + fileName; fileName = Path.Combine(Server.MapPath("~/Image"), fileName); hotelDetail.ImageFile.SaveAs(fileName); db.HotelDetails.Add(hotelDetail); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.HotelCategories, "CategoryId", "CategoryName", hotelDetail.CategoryId); return(View(hotelDetail)); } else { Response.Write("<script>alert('Session logged out. Sign in again');</script>"); FormsAuthentication.SignOut(); Session.Clear(); return(RedirectToAction("SignIn", "Auth")); } }
public IHttpActionResult GetHotelDetail(int id) { HotelDetail hotelDetail = db.HotelDetails.Find(id); if (hotelDetail == null) { return(NotFound()); } return(Ok(hotelDetail)); }
public IHttpActionResult PostHotelDetail(HotelDetail hotelDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.HotelDetails.Add(hotelDetail); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = hotelDetail.HotelId }, hotelDetail)); }
public ActionResult UpdateHotel(int HotelId, HotelDetail hotel) { try { repository.UpdateHotel(HotelId, hotel); return(Ok("Hotel Successfully Updated")); } catch (Exception e) { return(BadRequest(e)); } }
public ActionResult InsertHotel(HotelDetail hotel) { try { repository.InsertHotel(hotel); return(Ok("Hotel successfully Inserted")); } catch (Exception e) { return(BadRequest(e)); } }
public IHttpActionResult DeleteHotelDetail(int id) { HotelDetail hotelDetail = db.HotelDetails.Find(id); if (hotelDetail == null) { return(NotFound()); } db.HotelDetails.Remove(hotelDetail); db.SaveChanges(); return(Ok(hotelDetail)); }
public void MyAction(String s) { Hotel h = DataSource.GetHotelById(s); if (h != null) { HotelDetail win = new HotelDetail(); win.DataContext = h; win.Show(); } else { MessageBox.Show("Selected not found"); } }
public void UpdateHotel(int hotelId, HotelDetail hotel) { var data = context.HotelDetails.SingleOrDefault(s => s.HotelId == hotelId); data.HotelName = hotel.HotelName; data.HotelCity = hotel.HotelCity; data.HotelState = hotel.HotelState; data.HotelAddress = hotel.HotelAddress; data.PinNumber = hotel.PinNumber; data.Rating = hotel.Rating; data.NumberOfRoomAvailable = hotel.NumberOfRoomAvailable; data.HotelContectNumber = hotel.HotelContectNumber; data.HotelEmailAddress = hotel.HotelEmailAddress; context.SaveChanges(); }
/// <summary> /// Displaying hotel details /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Details(int?id) { if (Session["UserRole"] != null && Session["UserRole"].ToString() == "2") { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } HotelDetail hotelDetail = db.HotelDetails.Find(id); if (hotelDetail == null) { return(HttpNotFound()); } return(View(hotelDetail)); } else { Response.Write("<script>alert('Session logged out. Sign in again');</script>"); FormsAuthentication.SignOut(); Session.Clear(); return(RedirectToAction("SignIn", "Auth")); } }
public static HotelDetail ConvertWebeleToHotel(IWebDriver HtmlDoc) { var hotel = new HotelDetail(); hotel.HotelName = HtmlDoc.FindElement(By.XPath("//*[@id='J_htl_info']/div[@class='name']/h2[1]")).Text; //*[@id="J_htl_info"]/div[4] var addrs = HtmlDoc.FindElements(By.XPath("//*[@id='J_htl_info']/div[@class='adress']/span[position()<4]")); foreach (var addr in addrs) { hotel.Address += addr.Text + " "; } //*[@id="div_minprice"]/p[2]/span[2] hotel.Price = HtmlDoc.FindElement(By.XPath("//*[@id='div_minprice']/p[@class='staring_price']/span[@class='price']")).Text; hotel.Score = HtmlDoc.FindElement(By.XPath("//*[@id='base_bd']/div[4]/div[2]/div[1]/div/a/p[@class='s_row']/span[@class='score']")).Text; //*[@id="base_bd"]/div[4]/div[2]/div[1]/div/a/span[2] hotel.Sumary = HtmlDoc.FindElement(By.XPath("//*[@id='base_bd']/div[4]/div[2]/div[1]/div/a/span[@class='commnet_num']")).Text; var commentList = HtmlDoc.FindElement(By.Id("commentList")); hotel.Comments = ConvertWebeleToCmt(commentList); hotel.Pager = ConvertWebeleToPager(commentList); hotel.Pager.Count = hotel.Comments.Count; return(hotel); }
private void HotelCrawler(OnCompletedEventArgs e) { hd = ConvertHelper.ConvertWebeleToHotel(e.driver); loadHotelInfo(); CheckBtnStatus(); }
public void InsertHotel(HotelDetail hotel) { context.HotelDetails.Add(hotel); context.SaveChanges(); }
private HotelDetail TransformHotelPropertyDetails(TWS_HotelDetailsV3 response) { var hotelDetail = new HotelDetail(); //Basic Property Information var basicPropertyInfo = response.Location.FirstOrDefault(); hotelDetail.Latitude = basicPropertyInfo.latitude; hotelDetail.Longitude = basicPropertyInfo.longitude; //Total No-of floors / Rooms - in Tourico - msanka ? hotelDetail.NumberOfFloors = basicPropertyInfo.HotelRow.rooms; //Hotel Address Information hotelDetail.HotelFullAddress.Add(basicPropertyInfo.address); hotelDetail.HotelFullAddress.Add(basicPropertyInfo.zip); //Hotel Award Providers //None for Tourico //Hotel Contact Information hotelDetail.HotelFaxNumber = basicPropertyInfo.HotelRow.hotelFax; //Hotel Property Option -- Aminities from Tourico foreach (var aminity in basicPropertyInfo.HotelRow.GetAmenitiesRows()) { hotelDetail.HotelOptions = Helper.GetAvailablePropertyOptions(aminity.GetAmenityRows()); } //Hotel Property Types //var propertyType = basicPropertyInfo.HotelRow.GetHomeRows(); //Hotel Attractions //Cancellation Info //Location/Facilities/Food/Payment info foreach (var descRow in basicPropertyInfo.HotelRow.GetDescriptionsRows()) { foreach (var longdescRow in descRow.GetLongDescriptionRows()) { hotelDetail.Description.Add(longdescRow.FreeTextLongDescription); //description row foreach (var dRow in longdescRow.GetDescriptionRows()) { switch (dRow.category) { case "Location": hotelDetail.LocationDetails.Add(dRow.value); break; case "Facilities": hotelDetail.HotelFacilities.Add(dRow.value); //Hotel Facilities break; case "Rooms": hotelDetail.HotelRoomServices.Add(dRow.value); //Available Room Service break; case "Sports/Entertainment": hotelDetail.HotelRecreationServices.Add(dRow.value); break; case "Meals": hotelDetail.DiningDetails.Add(dRow.value); //Dining Info break; case "Payment": hotelDetail.DepositPolicies.Add(dRow.value); //Deposit policy break; } } } } //Direction Details var directionInfo = response.RefPoints[0]; hotelDetail.Directions.Add(directionInfo.type); hotelDetail.Directions.Add(directionInfo.name); hotelDetail.Directions.Add(directionInfo.direction); hotelDetail.Directions.Add(directionInfo.distance.ToString()); hotelDetail.Directions.Add(directionInfo.unit); //Hotel Guarantee Details //Marketing Info //Miscellaneous Services //HotelPolicies //Available Safety Services //Hotel Services //Available Transportation details return(hotelDetail); }
public ActionResult Detail(int id) { var currentdb = new WGHotelZHEntities(); var lang = Request.Cookies["lang"].Value; if (CurrentLanguage.Equals("us")) { currentdb = new WGHotelZHEntities("WGHotelUSEntities"); } var model = currentdb.Hotel.Find(id); if (model == null && CurrentLanguage.Equals("us")) { model = _dbus.Hotel.Where(o => o.ID == id).FirstOrDefault(); } else if (model == null && CurrentLanguage.Equals("zh")) { model = _dbzh.Hotel.Where(o => o.ID == id).FirstOrDefault(); } if (model == null) { model = _dbus.Hotel.Where(o => o.ParentId == id).FirstOrDefault(); } if (model == null) { return(RedirectToAction("Index", "Home")); } var detail = new HotelDetail(); detail.ID = model.ID; detail.Images = _basedb.ImageStore.Where(o => o.ReferIdZH == model.ID && o.Type == "Hotel").ToList(); detail.LinkUrl = model.LinkUrl; detail.Name = model.Name; detail.Tel = model.Tel; detail.Address = model.Address; detail.Feature = model.Features; var Facilities = model.Facilities.Split(',').Select(Int32.Parse).ToList(); detail.Facilities = _db.Facility.Where(o => Facilities.Contains(o.ID)).Select(p => p.Name).ToList(); detail.City = _db.City.Where(o => o.ID == model.City).FirstOrDefault().Name; var rooms = model.Room.Select(o => o.ID).ToList(); detail.Rooms = (from r in _db.Room where rooms.Contains(r.ID) select new RoomViewList { Feature = r.Feature, Notice = r.Notice, ID = r.ID, BedType = r.BedType, LinkUrl = model.LinkUrl, //Images = _basedb.ImageStore.Where(o => o.ID == r.ID && o.Type == "Room").ToList(), Name = r.Name, Quantiy = r.Quantiy, RoomType = r.RoomType, Sell = r.Sell, HasBreakfast = r.HasBreakfast.Value }).ToList(); foreach (var r in detail.Rooms) { if (CurrentLanguage.Equals("us")) { r.Images = _basedb.ImageStore.Where(o => o.ReferIdUS == r.ID && o.Type == "Room").ToList(); } else { r.Images = _basedb.ImageStore.Where(o => o.ReferIdZH == r.ID && o.Type == "Room").ToList(); } } var gamesites = model.Game.Split(',').ToList(); var NearHotels = _db.Hotel.Where(o => gamesites.Contains(o.Game) && o.ID != model.ID) .Select(o => new HotelDetail { ID = o.ID, Address = o.Address, Name = o.Name, ParentId = o.ParentId == null ? 0 : o.ParentId.Value }).OrderBy(x => Guid.NewGuid()).Take(5).ToList(); foreach (var item in NearHotels) { var ReferIdZH = item.ID; if (CurrentLanguage.Equals("us")) { ReferIdZH = item.ParentId; } item.Images = _basedb.ImageStore.Where(o => o.ReferIdZH == ReferIdZH).ToList(); } ViewBag.NearHotels = NearHotels; return(View(detail)); }
public ActionResult Detail(int id) { object obj = null; if (CurrentLanguage.Equals("us")) { obj = _db.HotelEN.Find(id); } else { obj = _db.HotelZH.Find(id); } var model = new AutoMapped.AutoMapped().Mapper <HotelZH>(obj); if (model == null) { return(RedirectToAction("Index", "Home")); } var detail = new HotelDetail(); detail.ID = model.ID; object objImgs = null; if (CurrentLanguage.Equals("us")) { objImgs = _db.ImageStore.Where(o => o.ReferIdUS == model.ID && o.Type == "Hotel").ToList(); } else { objImgs = _db.ImageStore.Where(o => o.ReferIdZH == model.ID && o.Type == "Hotel").ToList(); } detail.Images = (List <ImageStore>)objImgs; detail.LinkUrl = model.LinkUrl; detail.Name = model.Name; detail.Tel = model.Tel; detail.Address = model.Address; detail.Feature = model.Features; var Facilities = string.IsNullOrEmpty(model.Facilities) ? new List <int>() : model.Facilities.Split(',').Select(Int32.Parse).ToList(); object ObjFacility = null; if (CurrentLanguage.Equals("us")) { ObjFacility = _db.FacilityEN.Where(o => Facilities.Contains(o.ID)).Select(p => p.Name).ToList(); } else { ObjFacility = _db.FacilityZH.Where(o => Facilities.Contains(o.ID)).Select(p => p.Name).ToList(); } detail.Facilities = (List <string>)ObjFacility; string StrCity = string.Empty; if (CurrentLanguage.Equals("us")) { StrCity = _db.CityEN.Where(o => o.ID == model.City).FirstOrDefault().Name; } else { StrCity = _db.CityEN.Where(o => o.ID == model.City).FirstOrDefault().Name; } detail.City = StrCity; var RoomsOfHotel = _db.RoomZH.Where(o => o.HOTELID == model.ID).ToList(); var rooms = RoomsOfHotel.Select(o => o.ID).ToList(); List <RoomViewList> Rooms = new List <RoomViewList>(); if (CurrentLanguage.Equals("us")) { Rooms = (from r in _db.RoomEN where rooms.Contains(r.ParentId.Value) select new RoomViewList { Feature = r.Feature, Notice = r.Notice, ID = r.ID, BedType = r.BedType, LinkUrl = model.LinkUrl, //Images = _basedb.ImageStore.Where(o => o.ID == r.ID && o.Type == "Room").ToList(), Name = r.Name, Quantiy = r.Quantiy, RoomType = r.RoomType, Sell = r.Sell, HasBreakfast = r.HasBreakfast.Value }).ToList(); } else { Rooms = (from r in _db.RoomZH where rooms.Contains(r.ID) select new RoomViewList { Feature = r.Feature, Notice = r.Notice, ID = r.ID, BedType = r.BedType, LinkUrl = model.LinkUrl, //Images = _basedb.ImageStore.Where(o => o.ID == r.ID && o.Type == "Room").ToList(), Name = r.Name, Quantiy = r.Quantiy, RoomType = r.RoomType, Sell = r.Sell, HasBreakfast = r.HasBreakfast.Value }).ToList(); } detail.Rooms = Rooms; foreach (var r in detail.Rooms) { if (CurrentLanguage.Equals("us")) { r.Images = _db.ImageStore.Where(o => o.ReferIdUS == r.ID && o.Type == "Room").ToList(); } else { r.Images = _db.ImageStore.Where(o => o.ReferIdZH == r.ID && o.Type == "Room").ToList(); } } var gamesites = model.Game.Split(',').ToList(); var NearHotels = new List <HotelDetail>(); if (CurrentLanguage.Equals("us")) { NearHotels = _db.HotelEN.Where(o => gamesites.Contains(o.Game) && o.ID != model.ID) .Select(o => new HotelDetail { ID = o.ID, Address = o.Address, Name = o.Name, ParentId = o.ParentId == null ? 0 : o.ParentId.Value }).OrderBy(x => Guid.NewGuid()).Take(5).ToList(); } else { NearHotels = _db.HotelZH.Where(o => gamesites.Contains(o.Game) && o.ID != model.ID) .Select(o => new HotelDetail { ID = o.ID, Address = o.Address, Name = o.Name, ParentId = o.ParentId == null ? 0 : o.ParentId.Value }).OrderBy(x => Guid.NewGuid()).Take(5).ToList(); } foreach (var item in NearHotels) { var ReferIdZH = item.ID; if (CurrentLanguage.Equals("us")) { item.Images = _db.ImageStore.Where(o => o.ReferIdUS == ReferIdZH && o.Type.Equals("Hotel")).ToList(); } else { item.Images = _db.ImageStore.Where(o => o.ReferIdZH == ReferIdZH && o.Type.Equals("Hotel")).ToList(); } } ViewBag.NearHotels = NearHotels; return(View(detail)); }