public IActionResult Details(int?Id) { if (HttpContext.Session.GetString("ID") == null) { return(RedirectToAction("Login", "Admin")); } else { //forward Convenient list ViewBag.listGetConvenient = hotelRepository.listGetConvenient(Id); return(View(hotelRepository.GetHotel(Id))); } }
public async Task <HotelWithDetails> GetHotel(string travelIdentity) { var hotel = await HotelRepository.GetHotel(travelIdentity); if (hotel == null) { return(null); } var transportCategories = await HotelRepository.GetTransportCategories(hotel.HotelId); var transports = new List <HotelTransport>(); foreach (var category in transportCategories) { var transport = await HotelRepository.GetTransport(hotel.HotelId, category.Category); var tr = new HotelTransport { Category = category.Category, TransportLocations = transport.Select(t => HotelConverter.ToDomainTransportLocation(t)).ToArray() }; transports.Add(tr); } return(new HotelWithDetails { Hotel = HotelConverter.ToDomainHotel(hotel), Transport = transports }); }
protected void Page_Init(object sender, EventArgs e) { try { Session["Active"] = "Revenue"; if (Request.Params["id"] != null) { int hotelId; int.TryParse(Request.Params["id"], out hotelId); _hotels = _hotelRepository.GetHotel(hotelId, PublicCustomerInfos != null ? PublicCustomerInfos.EmailAddress : string.Empty); Session["Hotel"] = _hotels.HotelId; } else { string sessionHotel = Session["Hotel"] != null ? Session["Hotel"].ToString() : string.Empty; _hotels = _hotelRepository.GetById(int.Parse(sessionHotel)); } if (_hotels == null) { Response.Redirect(Constant.HotelList); } DateFrom.Visible = false; DateTo.Visible = false; Search.Visible = false; CustomForm.Visible = false; if (!IsPostBack) { SelectedFilterBy.Text = SelectedFilterDdl.Text; ProductTypeLabel.Text = ProductTypeDdl.Text; var searchAllParam = new SearchAllBookingsParams { HotelId = _hotels.HotelId, IsForRevenue = true }; var bookings = _bookingRepository.GetAllBookingsOfHotel(searchAllParam); FilterBookingByProductType(ref bookings); BindRevenue(bookings); } } catch (Exception ex) { var logs = new Logs { LogKey = "Admin_RevenuesPage_Error", UpdatedBy = PublicCustomerInfos != null ? PublicCustomerInfos.CustomerId : 1, UpdatedDate = DateTime.UtcNow, UpdatedContent = string.Format("{0} - {1} - {2}", ex.Message, ex.StackTrace, ex.Source) }; _bookingRepository.AddLog(logs); } }
public async Task CanAddAndDropAHotel() { //Arrange var hotel = await CreateAndSaveTestHotel(); var repository = new HotelRepository(_db); //Act await repository.Create(hotel); //Assert var actualHotel = await repository.GetHotel(hotel.Id); Assert.NotNull(actualHotel); //Act await repository.DeleteHotel(hotel.Id); //Assert actualHotel = await repository.GetHotel(hotel.Id); Assert.Null(actualHotel); }
protected override void OnInit(EventArgs e) { if (!Request.IsLocal && !Request.IsSecureConnection) { string redirectUrl = Request.Url.ToString().Replace("http:", "https:"); Response.Redirect(redirectUrl, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } if (Context.Session != null) { string sessionUser = Session["CurrentUser"] != null ? Session["CurrentUser"].ToString() : string.Empty; string sessionHotel = Session["Hotel"] != null ? Session["Hotel"].ToString() : string.Empty; int hotelId; if (!string.IsNullOrEmpty(sessionUser)) { PublicCustomerInfos = JsonConvert.DeserializeObject <CustomerInfos>(sessionUser); } if (!string.IsNullOrEmpty(sessionHotel) && !Request.Url.AbsoluteUri.Contains(Constant.HotelList)) { hotelId = JsonConvert.DeserializeObject <int>(sessionHotel); PublicHotel = _hotelRepository.GetById(hotelId); } if (Request.Params["hotelId"] != null) { int.TryParse(Request.Params["hotelId"], out hotelId); PublicHotel = _hotelRepository.GetHotel(hotelId, PublicCustomerInfos != null ? PublicCustomerInfos.EmailAddress : string.Empty); if (PublicHotel != null) { Session["Hotel"] = PublicHotel.HotelId; } } } if (PublicCustomerInfos == null || !PublicCustomerInfos.IsActive) { Response.Redirect(string.Format(Constant.SignIpPageAdmin, HttpUtility.UrlEncode(Request.Url.PathAndQuery))); } if (PublicHotel == null || (PublicCustomerInfos != null && PublicCustomerInfos.IsCheckInOnly && !Request.Url.AbsoluteUri.Contains("BookingPage.aspx"))) { Response.Redirect(string.Format(Constant.HotelList)); } base.OnInit(e); }
protected void BtnAddUserHotel_OnClick(object sender, EventArgs e) { int hotelId; int.TryParse(DdlHotels.SelectedValue, out hotelId); if (hotelId != 0) { int userId = int.Parse(Request.Params["userId"]); _users = _userRepository.GetById(userId); var hotel = _hotelRepository.GetHotel(hotelId, _users.EmailAddress); if (hotel == null) { var userHotels = new CustomerInfosHotels { HotelId = hotelId, CustomerId = _users.CustomerId }; _userHotelRepository.Add(userHotels); _userHotelRepository.ResetCache(); } RebindHotelsByuser(true); } }
// GET: api/Hotel/5 public Hotel Get(int id) { return(repo.GetHotel(id)); }