private void LoadData()
 {
     int id = int.Parse(Page.RouteData.Values["hotelId"].ToString());
     _hotel = _db.Hotels.Find(id);
     imgStar.ImageUrl = "/Images/Hotel/Star/b-star-" + _hotel.Star + ".png";
     litName.Text = _hotel.Name;
     litAdress.Text = _hotel.Adress;
 }
        private void LoadData()
        {
            int id = int.Parse(Page.RouteData.Values["hotelId"].ToString());
            _hotel = _db.Hotels.Find(id);
            imgHotelImage.ImageUrl =UrlHelper.BackEndUrl+ _hotel.Images[0].Url;

            rptImage.DataSource = _hotel.Images.ToList();
            rptImage.DataBind();
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Hotel hotel;
                int id = 0;
                if (int.TryParse(Request["hotelId"], out id))
                {
                    hotel = _db.Hotels.Find(id);
                }
                else
                {
                    hotel = new Hotel();
                }
                hotel.Adress = txtAdress.Text;
                if (fileAvatar.PostedFile != null && fileAvatar.PostedFile.ContentLength > 0)
                {
                    fileAvatar.PostedFile.SaveAs(Server.MapPath("/Images/HotelImages/" + fileAvatar.PostedFile.FileName));
                    HotelImage hi = new HotelImage { Url = "/Images/HotelImages/" + fileAvatar.PostedFile.FileName };
                    _db.HotelImages.Add(hi);
                    _db.SaveChanges();
                    hotel.Avatar = hi;

                }
                hotel.Description = txtDescription.Text;
                hotel.Email = txtEmail.Text;
                hotel.Name = txtHotelName.Text;
                hotel.Phone = txtPhone.Text;
                hotel.Star = int.Parse(ddlStar.SelectedValue);
                hotel.City = _db.Cities.Find(int.Parse(ddlCity.SelectedValue));
                if (id == 0)
                    _db.Hotels.Add(hotel);
                _db.SaveChanges();
                Notify.ShowMessageSuccessFromAnotherPage("Đã lưu thông tin khách sạn thành công !");
                Response.Redirect("ManagerHotel.aspx");
            }
            catch
            {
                Notify.ShowMessageError("đã xảy ra lỗi !", Page);
            }
        }
 private void LoadData()
 {
     int id = int.Parse(Page.RouteData.Values["hotelId"].ToString());
     _hotel = _db.Hotels.Find(id);
     imgStar.ImageUrl = "/Images/Hotel/Star/b-star-" + _hotel.Star + ".png";
     litName.Text = _hotel.Name;
     litAdress.Text = _hotel.Adress;
     litNumOfRoom.Text = _hotel.HotelRoomTypes.Sum(x => x.HotelRooms.Count()).ToString();
     int sId;
     if (int.TryParse(Request["sId"], out sId))
     {
         SearchInput input = _db.SearchInputs.Find(sId);
         litPrice.Text = FormatHelper.FormatPrice(_hotel.getMinPrice(input.DateCheckIn, input.DateCheckOut).ToString());
     }
     else
     {
         litPrice.Text =FormatHelper.FormatPrice( _hotel.getMinPrice().ToString());
     }
     rptFeature.DataSource = _db.HotelFeatures.Where(x => x.HotelRoomTypes.Where(y => y.Hotel.Id == id).Count() > 0).ToList();
     rptFeature.DataBind();
 }
예제 #5
0
 public bool IsManagerOfHotel(Hotel hotel)
 {
     if (ManagerPermission.Permission == Permission.Admin)
         return true;
     if (hotel.Manager == this)
         return true;
     return false;
 }
 private void LoadData()
 {
     int id = int.Parse(Page.RouteData.Values["hotelId"].ToString());
     _hotel = _db.Hotels.Find(id);
     int sId = 0;
     if (int.TryParse(Request["sId"], out sId))
     {
         _input = _db.SearchInputs.Find(sId);
         ngay_den.Text = _input.DateCheckIn.ToString("dd/MM/yyyy");
         ngay_di.Text = _input.DateCheckOut.ToString("dd/MM/yyyy");
         lvRoomDetail.DataSource = _hotel.getListHotelRoomType(_input.DateCheckIn, _input.DateCheckOut);
         lvRoomDetail.DataBind();
     }
     else
     {
         btnOrder.Visible = false;
     }
 }