public HotelModel GetHotelById(int hotelID) { using (HotelDBContext _hotelEntities = new HotelDBContext()) { var data = _hotelEntities.Hotels.ToList(); List <HotelModel> hotelList = new List <HotelModel>(); for (var i = 0; i < data.Count; i++) { HotelModel model = new HotelModel(); model.Id = data[i].Id; model.HotelName = data[i].HotelName; model.Address = data[i].Address; model.CityId = data[i].CityId; model.CountryId = data[i].CountryId; model.PhoneNumber = data[i].PhoneNumber; model.CancellationPolicy = data[i].CancellationPolicy; model.Description = data[i].Description; model.DefaultCurrency = data[i].DefaultCurrency; model.PricePerNight = data[i].PricePerNight; hotelList.Add(model); } HotelModel getHotelData = hotelList.SingleOrDefault(x => x.Id == hotelID); return(getHotelData); } }
public async Task <ActionResult <HotelModel> > PostHotel(HotelModel hotel) { _context.Hotels.Add(hotel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetHotel", new { id = hotel.Id }, hotel)); }
public async Task <IActionResult> Edit(int id, [Bind("Hotelid,HotelName,Destination,Contact,MinPrice,MaxPrice")] HotelModel hotelModel) { if (id != hotelModel.Hotelid) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(hotelModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HotelModelExists(hotelModel.Hotelid)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(hotelModel)); }
public string AddHotel(HotelModel model) { string result = string.Empty; using (HotelDBContext _hotelEntities = new HotelDBContext()) { try { Hotel hotel = new Hotel(); hotel.HotelName = model.HotelName; hotel.Address = model.Address; hotel.CityId = model.CityId; hotel.CountryId = model.CountryId; hotel.PhoneNumber = model.PhoneNumber; hotel.Description = model.Description; hotel.CancellationPolicy = model.CancellationPolicy; hotel.DefaultCurrency = model.DefaultCurrency; hotel.PricePerNight = model.PricePerNight; hotel.CreatedOn = System.DateTime.Now.ToShortDateString(); _hotelEntities.Entry(hotel).State = System.Data.Entity.EntityState.Added; _hotelEntities.SaveChanges(); result = "Record Inserted"; } catch (Exception) { result = "Failed To Insert"; } return(result); } }
public ActionResult UpdateAboutUs(string aboutus) { HotelModel hotelModel = new HotelModel(connectionString); hotelModel.UpdateAboutUs(aboutus); return(View("ModifyPage", "ModifyPage")); }
public IActionResult ModifyHome() { HotelModel hotelModel = new HotelModel(connectionString); Hotel hotels = hotelModel.GetAllHotel(); HotelModel hotel = new HotelModel(); hotel.id = hotels.id; hotel.name = hotels.name; hotel.description = hotels.description; ContentPageModel contentpageModel = new ContentPageModel(connectionString); IList <ContentPage> content = contentpageModel.GetAllContentPage(); List <ContentPageModel> contentPage = new List <ContentPageModel>(); for (int i = 0; i < content.Count; i++) { if (content[i].referentpage.Equals("home")) { ContentPageModel contentNew = new ContentPageModel(); contentNew.urlimage = content[i].urlimage; contentPage.Add(contentNew); } } ViewBag.contentPage = contentPage; ViewBag.hotel = hotel; return(View()); }
public APIResponse PostHotelData(HotelModel addHotel) { if (_hotelList.Find(x => x.Id == addHotel.Id) == null) { _hotelList.Add(addHotel); return(new APIResponse { Status = new Status() { ApiStatus = ApiStatus.Success, ErrorMessage = "UPDATED DATA", ErrorCode = 200 } }); } else { return(new APIResponse { Status = new Status() { ApiStatus = ApiStatus.Success, ErrorMessage = "ERROR IN UPDATING DATA", ErrorCode = 200 } }); } }
private HotelModel GetHotelModel(IWebElement hotelControl) { var hotel = new HotelModel(); hotel.Name = hotelControl.TryFindElement(By.ClassName("sr-hotel__name"))?.Text; hotel.Description = hotelControl.TryFindElement(By.ClassName("hotel_desc"))?.Text; var imageContol = hotelControl.TryFindElement(By.ClassName("hotel_image")); var imageLink = imageContol?.GetAttribute("src"); hotel.ImageLink = CreateUri(imageLink); var bookingHotelRawLink = hotelControl.TryFindElement(By.ClassName("hotel_name_link"))?.GetAttribute("href"); hotel.HotelBookingUri = CreateUri(bookingHotelRawLink); hotel.RawPrice = hotelControl.TryFindElement(By.ClassName("site_price"))?.Text; // temporary hotel.Price = new Random().Next(300, 600); hotel.RawPrice = hotel.Price.ToString(); hotel.Score = GetNumericData(hotelControl, "average"); //hotel.MaxScore = GetNumericData(hotelControl, "bestRating", "content"); return(hotel); }
public clients GetClient(int id) { using (HotelModel context = new HotelModel()) { return(context.clients.Find(id)); } }
public List <clients> GetAllClients() { using (HotelModel context = new HotelModel()) { return(context.clients.ToList()); } }
public ApiResponse UpdateHotelDetailsByID(int id, HotelModel hotelModel) { ApiResponse AResponse = new ApiResponse(); try { HotelModel HotelDetailsByID = new HotelModel(); HotelDetailsByID = _HotelDetails.Find(Hotel => Hotel.Id.Equals(id)); if (HotelDetailsByID != null) { HotelDetailsByID.Id = hotelModel.Id; HotelDetailsByID.Name = hotelModel.Name; HotelDetailsByID.NumberOfAvailableRooms = hotelModel.NumberOfAvailableRooms; HotelDetailsByID.Address = hotelModel.Address; HotelDetailsByID.PinCode = hotelModel.PinCode; AResponse.ApiStatus = "Success"; AResponse.StatusCode = StatusCodeNumber.Success; AResponse.Message = "Successfully Updated"; } } catch (Exception ex) { AResponse.ApiStatus = "Failure"; AResponse.StatusCode = StatusCodeNumber.InternalServerError; AResponse.Message = ex.Message; } return(AResponse); }
internal void ChambreEstNettoyee(int numero) { using (HotelModel context = new HotelModel()) { context.Database.ExecuteSqlCommand("UPDATE chambres SET DateDernierMenage = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' WHERE chambres.Numero = " + numero); } }
public ActionResult Home() { RepositoryContentPage contentpageModel = new RepositoryContentPage(connectionString); IList <ContentPage> content = contentpageModel.GetAllContentPage(); List <ContentPageModel> contentPage = new List <ContentPageModel>(); for (int i = 0; i < content.Count; i++) { if (!content[i].referentpage.Equals("home")) { ContentPageModel contentNew = new ContentPageModel(); contentNew.referentpage = content[i].referentpage; contentNew.urlimage = content[i].urlimage; contentNew.typeimage = content[i].typeimage; contentNew.content = content[i].content; contentPage.Add(contentNew); } } RepositoryHotel hotelModel = new RepositoryHotel(connectionString); Hotel hotels = hotelModel.GetAllHotel(); HotelModel hotel = new HotelModel(); hotel.aboutus = hotels.aboutus; ViewBag.contentPage = contentPage; ViewBag.hotel = hotel; return(View()); }
public ReplyOfAPI UpdateHotelDetails(int id, HotelModel hotelModel) { ReplyOfAPI Reply = new ReplyOfAPI(); try { HotelModel findHotelDetails = new HotelModel(); findHotelDetails = _HotelDetails.Find(HotelName => HotelName.Id.Equals(id)); if (findHotelDetails != null) { findHotelDetails.Id = hotelModel.Id; findHotelDetails.CityCode = hotelModel.CityCode; findHotelDetails.Address = hotelModel.Address; findHotelDetails.NumberOfRoomsAvailable = hotelModel.NumberOfRoomsAvailable; findHotelDetails.Name = hotelModel.Name; } } catch (Exception ex) { Reply.ApiStatus = "Failed"; Reply.StatusCode = StatusNumber.Failed; Reply.Message = ex.Message; } return(Reply); }
/// <summary> /// Insert a new value in the list /// </summary> /// <param name=<em>"value"</em>>New value to be inserted</param> // POST: api/Country public IHttpActionResult Post(HotelModel country) { if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } using (var ctx = new HTMEntities3()) { ctx.Hotels.Add(new Hotel() { id = country.id, Hotel_Name = country.Hotel_Name, Hotel_Number = country.Hotel_Number, Description = country.Description, InsertedBy = country.InsertedBy, InsertedOn = country.InsertedOn, IsActive = country.IsActive, IsDelete = country.IsDelete }); ctx.SaveChanges(); } return(Ok()); }
public async Task <IActionResult> PutHotel(int id, HotelModel hotel) { if (id != hotel.Id) { return(BadRequest()); } _context.Entry(hotel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HotelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void AddNewHotel([FromBody] HotelModel newHotel) { var hotelName = newHotel.HotelName; var cityName = newHotel.CityName; _hotelsOnServer.Add(newHotel); }
public IActionResult Index() { /***********************UNO POR UNO****************/ RepositoryHotel hotelModel = new RepositoryHotel(connectionString); Hotel hotels = hotelModel.GetAllHotel(); HotelModel hotel = new HotelModel(); hotel.name = hotels.name; hotel.description = hotels.description; hotel.address = hotels.address; /***************************************************/ RepositoryContentPage contentpageModel = new RepositoryContentPage(connectionString); IList <ContentPage> content = contentpageModel.GetAllContentPage(); List <ContentPageModel> contentPage = new List <ContentPageModel>(); for (int i = 0; i < content.Count; i++) { if (content[i].referentpage.Equals("home")) { ContentPageModel contentNew = new ContentPageModel(); contentNew.referentpage = content[i].referentpage; contentNew.urlimage = content[i].urlimage; contentNew.typeimage = content[i].typeimage; contentNew.content = content[i].content; contentPage.Add(contentNew); } } ViewBag.contentPage = contentPage; ViewBag.allContentPage = contentpageModel.GetAllContentPage(); ViewBag.hotel = hotel; return(View()); }
//[OutputCache(Duration = 1000)] public ActionResult HotelType() { HotelModel hm = new HotelModel(); hm.LHotelType = HotelTypeRepository.GetAllHotelTypes(true); return(PartialView(hm)); }
public JsResultObject recommendHotel(HotelModel hotel, int priorityLevel, string remark) { JsResultObject re = new JsResultObject(); HotelRecommendModel recommend = new HotelRecommendModel(); recommend.priorityLevel = priorityLevel; recommend.remark = remark; recommend.hotelName = hotel.hotelName; recommend.hotelId = hotel.hotelId; try { this.OpenSession(); ITransaction itx = this.session.BeginTransaction(); SaveOrUpdate(recommend, ""); itx.Commit(); this.CloseSession(); re.title = "操作成功"; re.msg = string.Format("{0} 推荐成功", hotel.hotelName); } catch (Exception ex) { re.title = "操作失败"; re.code = JsResultObject.CODE_ERROR; re.msg = string.Format("失败原因:{0}", ex.Message); } return(re); }
public ActionResult Edit([Bind(Include = "Id,Name,Description,Stars,Address,AvalibleFrom,AvalibleTo,Rooms,PhotoId,PlaceId")] HotelModel hotelModel) { if (ModelState.IsValid && hotelModel.Rooms != null) { var rooms = unitOfWork.RoomRepository.Get(r => r.HotelId == hotelModel.Id); foreach (var item in rooms) { unitOfWork.RoomRepository.Delete(item); } var hotel = Mapper.Map <Hotel>(hotelModel); hotel.Rooms = null; hotel.PriceFromUSD = hotelModel.Rooms.Min(r => r.PriceUSD); hotel.PriceFromEGP = hotelModel.Rooms.Min(r => r.PriceEGP); unitOfWork.HotelRepository.Update(hotel); foreach (var item in hotelModel.Rooms.ToList()) { if (!item.Deleted) { var room = Mapper.Map <Room>(item); room.HotelId = hotel.Id; unitOfWork.RoomRepository.Insert(room); } } unitOfWork.Save(); return(RedirectToAction("Index")); } var places = unitOfWork.PlaceRepository.Get(); ViewBag.PlaceId = new SelectList(places, "Id", "Name"); return(View(hotelModel)); }
public ActionResult UpdateLocate(string address) { HotelModel hotelModel = new HotelModel(connectionString); hotelModel.UpdateLocate(address); return(View("ModifyPage", "ModifyPage")); }
public async Task <IActionResult> Index() { try { var tenantsModel = await _catalogRepository.GetAllTenantsAsync(); if (tenantsModel != null) { //get the venue name for each tenant foreach (var tenant in tenantsModel) { HotelModel venue = null; String tenantStatus = _utilities.GetTenantStatus(tenant.TenantId); if (tenantStatus == "Online") { try { venue = await _tenantRepository.GetHotelDetailsAsync(tenant.TenantId); } catch (ShardManagementException ex) { if (ex.ErrorCode == ShardManagementErrorCode.MappingDoesNotExist) { //Fix mapping irregularities - trust local shard map _utilities.ResolveMappingDifferences(tenant.TenantId); //Get venue details if tenant is online String updatedTenantStatus = _utilities.GetTenantStatus(tenant.TenantId); if (updatedTenantStatus == "Online") { venue = await _tenantRepository.GetHotelDetailsAsync(tenant.TenantId); } } } catch (Exception ex) { _logger.LogError(0, ex, "Error in getting all tenants in Bookings Hub"); return(View("Error", ex.Message)); } } if (venue != null) { tenant.HotelName = venue.HotelName; tenant.CityName = venue.CityCode; tenant.TenantName = venue.DatabaseName; } } return(View(tenantsModel)); } } catch (Exception ex) { _logger.LogError(0, ex, "Error in getting all tenants in Events Hub"); return(View("Error", ex.Message)); } return(View("Error")); }
private async void Resister() { try { if (!string.IsNullOrEmpty(uuidEntry.Text)) { var res = await RegisterDevice(uuidEntry.Text).ConfigureAwait(true); Console.WriteLine(res); if (!string.IsNullOrEmpty(res)) { if (res.Contains("Device Already Registered")) { deviceLabel.Text = "Device is already registered"; await DisplayAlert("Failed!", "Device already registered. \nPlease contact your IT department.", "OK"); } else if (res.Contains("Device not configured")) { deviceLabel.Text = "Device is not in the server"; await DisplayAlert("Failed!", "Device is not configured in server. \nPlease contact your IT department.", "OK"); } else { hotelList = JsonConvert.DeserializeObject <List <HotelModel> >(res); if (hotelList != null) { HotelModel hotelModel = hotelList[0]; Settings.HotelCode = hotelModel.TmsId; Settings.HotelIdentifier = hotelModel.HtlCode; Settings.HotelName = hotelModel.HtlName; Settings.IsUUIDregistered = "Device is registered"; Settings.DeviceUUID = uuidEntry.Text; hotelNameLabel.Text = Settings.HotelName; versionLabel.Text = Settings.AppVersion; regStatLabel.Text = Settings.IsUUIDregistered; deviceLabel.Text = "Device is registered"; hotelNameLabel.TextColor = Color.Blue; versionLabel.TextColor = Color.Blue; regStatLabel.TextColor = Color.Blue; deviceLabel.TextColor = Color.Blue; registerButton.IsVisible = false; uuidEntry.IsEnabled = false; await DisplayAlert("Success!", "Device registration success.", "OK"); } } } } } catch (Exception) { } }
public ActionResult DeleteConfirmed(int id) { HotelModel hotelModel = db.HotelModels.Find(id); db.HotelModels.Remove(hotelModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DoRecommend(string hotelId) { HotelModel hotel = BaseZdBiz.Load <HotelModel>(hotelId); DataBiz dataBiz = DataBiz.GetInstant(); JsResultObject result = dataBiz.recommendHotel(hotel, 0, ""); return(JsonText(result, JsonRequestBehavior.AllowGet)); }
public IHttpActionResult Put(HotelModel hotel) { try { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, HotelService.UpdateHotel(hotel)))); } catch (Exception e) { return(InternalServerError()); } }
public HotelModel CreateHotel(HotelModel hotel) { Hotel newHotel = SimpleMapper.Map <Hotel>(hotel); BookingoContext.DataBase().Hotels.Add(newHotel); BookingoContext.DataBase().SaveChanges(); return(SimpleMapper.Map <HotelModel>(newHotel)); }
public ActionResult Create([Bind(Include = "Id,Name,Description,Stars,Address,AvalibleFrom,AvalibleTo,Rooms,PhotoId,PlaceId")] HotelModel hotelModel, List <HttpPostedFileBase> files) { if (ModelState.IsValid && hotelModel.Rooms != null) { foreach (var item in hotelModel.Rooms.ToList()) { if (item.Deleted) { hotelModel.Rooms.Remove(item); } } hotelModel.PriceFromUSD = hotelModel.Rooms.Min(r => r.PriceUSD); hotelModel.PriceFromEGP = hotelModel.Rooms.Min(r => r.PriceEGP); var hotel = Mapper.Map <Hotel>(hotelModel); unitOfWork.HotelRepository.Insert(hotel); unitOfWork.Save(); var first = true; foreach (var file in files) { if (file != null && file.ContentLength > 0) { var extension = Path.GetExtension(file.FileName); var fileExtension = extension.ToLower(); if (allowedExtensions.Contains(fileExtension)) { var uniqe = Guid.NewGuid(); string path = Path.Combine(Server.MapPath("~/Uploads"), uniqe + extension); file.SaveAs(path); var photoModel = new PhotoModel(); photoModel.Name = uniqe + extension; photoModel.Type = PhotoType.Hotel; photoModel.ItemId = hotel.Id; var photo = Mapper.Map <Photo>(photoModel); unitOfWork.PhotoRepository.Insert(photo); if (first) { hotel.Photo = photo; unitOfWork.HotelRepository.Update(hotel); first = false; } } else { ModelState.AddModelError("Photo", "please select photos in these formats .jpg, .jpeg, .png"); var placess = unitOfWork.PlaceRepository.Get(); ViewBag.PlaceId = new SelectList(placess, "Id", "Name"); return(View(hotelModel)); } } } unitOfWork.Save(); return(RedirectToAction("Index")); } var places = unitOfWork.PlaceRepository.Get(); ViewBag.PlaceId = new SelectList(places, "Id", "Name"); return(View(hotelModel)); }
public IActionResult Create([FromBody] HotelModel model) { if (model == null) { return(BadRequest()); } _IHotelRepository.Add(model); return(new ObjectResult("Success")); }
private void PrepareCity(HotelModel model) { model.Cities = context.Cities.AsQueryable<HolidayPlanner.DAL.City>().Select(x => new SelectListItem() { Text = x.CityName, Value = x.CityId.ToString() }); }
private void PrepareHotelType(HotelModel model) { model.HotelTypes = context.HotelTypes.AsQueryable<HolidayPlanner.DAL.HotelType>().Select(x => new SelectListItem() { Text = x.HotelType1, Value = x.HTypeId.ToString() }); }
public ActionResult AddHotel() { HotelModel model = new HotelModel(); PrepareHotelType(model); PrepareCity(model); int Hno = context.Hotels.Max(x => x.HotelId); int Hno1 = Hno + 1; ViewData["Id"] = Hno1; return View(model); }
public ActionResult AddImage() { HotelModel model = new HotelModel(); PrepareHotel3(model); return View(model); }
private void PrepareHotel3(HotelModel model) { model.Hotels = context.Hotels.AsQueryable<HolidayPlanner.DAL.Hotel>().Select(x => new SelectListItem() { Text = x.HotelName, Value = x.HotelId.ToString() }); }
public ActionResult AddImage1(HotelModel model) { foreach (string file in Request.Files) { var postedFile = Request.Files[file]; var hname = new List<HolidayPlanner.Models.Hotel>(); InfoData dt = new InfoData(); hname = dt.Hotels.Where(x => x.HotelId == model.HotelId).ToList(); foreach (var st in hname) { string vat = st.HotelName; bool exists = System.IO.Directory.Exists(Server.MapPath("~/Images" + vat + "/")); var extension = Path.GetExtension(postedFile.FileName); var newName = "19001"; if (!exists) System.IO.Directory.CreateDirectory(Server.MapPath("~/Images" + vat + "/")); //Directory.CreateDirectory(path); postedFile.SaveAs(Server.MapPath("~/Images" + vat + "/") + newName + extension); } } return RedirectToAction("Index"); }