protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["PROPERTYMANAGER"] == null)
            {
                Response.Redirect("~/Web/Account/tempLogin.aspx?page=Users/Accommodation/landlord-my-rooms.aspx");
            }

            if (Request.QueryString["editId"] == null)
            {
                Response.Redirect("~/Web/Account/landlord-my-rooms.aspx");
            }
            //Get accommodation
            if (IsPostBack)
            {
                //nothing
            }
            else
            {
                if (Request.QueryString["editId"] != null)
                {
                    Qaelo.Models.AccommodationModel.Accommodation room = (new AccommodationConnection().getRoom(Convert.ToInt32(Request.QueryString["editId"].ToString())));

                    txtAddress.Text     = room.address;
                    txtDescription.Text = room.description;
                    txtDistance.Text    = room.distanceFromCampus.ToString();
                    txtPrice.Text       = room.price.ToString();
                    txtText.Text        = room.university;

                    string value = "";

                    if (room.accredited)
                    {
                        value = "true";
                    }
                    else
                    {
                        value = "false";
                    }

                    ddlAccreditation.SelectedIndex = ddlAccreditation.Items.IndexOf(ddlAccreditation.Items.FindByValue(value));
                    ddlArrangement.SelectedIndex   = ddlArrangement.Items.IndexOf(ddlArrangement.Items.FindByValue(room.arrangement));
                    ddlGender.SelectedIndex        = ddlGender.Items.IndexOf(ddlGender.Items.FindByValue(room.gender));

                    Session["IMAGES"] = room.images;
                }
                else
                {
                    lblErrorMessage.Text = "Invalid room Id";
                }
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Session
            //if (Session["STUDENT"] == null)
            //    Response.Redirect("~/Web/Account/tempLogin.aspx");

            if (Request.QueryString["id"] == null)
            {
                Response.Redirect("~/Web/Users/Student/student-accommodation.aspx");
            }

            int id = Convert.ToInt32(Request.QueryString["id"].ToString());

            reserveRoom.HRef = "students-book-a-room.aspx?id=" + id;

            if (Request.QueryString["reserve"] != null && Request.QueryString["id"] != null)
            {
                lblSuccess.Text = "Successfully Reserved this room, Please wait for email confirmation from the landlord";
            }

            Qaelo.Models.StudentModel.Student student = (Models.StudentModel.Student)(Session["STUDENT"]);

            AccommodationConnection connection = new AccommodationConnection();

            //Check if the user clicked the join button

            if (student != null)
            {
                if (Request.QueryString["joinId"] != null)
                {
                    Qaelo.Models.AccommodationModel.Accommodation myroom = connection.getRoom(Convert.ToInt32(Request.QueryString["joinId"].ToString()));

                    connection.joinPropery(myroom.managerId, myroom.id, student.Id);
                }
                else if (Request.QueryString["unjoinId"] != null)
                {
                    Qaelo.Models.AccommodationModel.Accommodation myroom = connection.getRoom(Convert.ToInt32(Request.QueryString["unjoinId"].ToString()));

                    connection.unjoinProperty(myroom.id, student.Id);
                }
            }
            else
            {
                if (Request.QueryString["joinId"] != null)
                {
                    Response.Redirect("~/Web/Account/tempLogin.aspx");
                }
            }

            string name = "";

            //Load the Room
            Qaelo.Models.AccommodationModel.Accommodation room = (new AccommodationConnection().getRoom(id));

            if (room == null)
            {
                return;
            }

            Manager manager = new ManagerConnection().getManager(room.managerId);

            //Confirm Veririfcation

            if (manager != null)
            {
                if (manager.verified)
                {
                    if (manager.propertyName != "")
                    {
                        name = manager.propertyName;
                    }
                    else
                    {
                        name = "Room Available";
                    }

                    if (student != null)
                    {
                        if (connection.propertyJoinedByUser(room.id, student.Id))
                        {
                            lblPanelTopic.Text = string.Format(@"{0} - {1}km away from {2}<a href='students-room.aspx?unjoinId={3} &id={3}' class='btn btn-danger btn-xs pull-right'>Joined</a>", name, room.distanceFromCampus, room.campus, room.id);
                        }
                        else
                        {
                            lblPanelTopic.Text = string.Format(@"{0} - {1}km away from {2}<a href='students-room.aspx?joinId={3} &id={3}' class='btn btn-primary btn-xs pull-right'>Join Property</a>", name, room.distanceFromCampus, room.campus, room.id);
                        }
                    }
                    else
                    {
                        lblPanelTopic.Text = string.Format(@"{0} - {1}km away from {2}<a href='students-room.aspx?joinId={3} &id={3}' class='btn btn-primary btn-xs pull-right'>Join Property</a>", name, room.distanceFromCampus, room.campus, room.id);
                    }

                    string[] listOfImages = room.images.Split(';');

                    if (listOfImages[0] != "")
                    {
                        imgImage1.Src = "../../../Images/Accommodation/" + listOfImages[0];
                    }
                    if (listOfImages[1] != "")
                    {
                        imgImage2.Src = "../../../Images/Accommodation/" + listOfImages[1];
                    }
                    if (listOfImages[2] != "")
                    {
                        imgImage3.Src = "../../../Images/Accommodation/" + listOfImages[2];
                    }
                    if (listOfImages[3] != "")
                    {
                        imgImage4.Src = "../../../Images/Accommodation/" + listOfImages[3];
                    }
                    if (listOfImages[4] != "")
                    {
                        imgImage5.Src = "../../../Images/Accommodation/" + listOfImages[4];
                    }

                    lblLocation.Text = room.address;
                    lblRoomType.Text = room.accomodationType;

                    lblEmail.Text       = manager.email;
                    lblName.Text        = manager.firstName + " " + manager.lastName;
                    lblNumber.Text      = manager.number;
                    lblDescription.Text = room.description.Replace(char.ConvertFromUtf32(13), "<br/>");
                }
                else
                {
                    Response.Redirect("~/Web/Users/Student/student-accommodation.aspx");
                }
            }
            else
            {
                Response.Redirect("~/Web/Users/Student/student-accommodation.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["search"] != null)
                {
                    txtText.Text = Request.QueryString["search"].ToString();

                    #region not loggedin
                    if (Session["STUDENT"] == null)
                    {
                        AccommodationConnection connection = new AccommodationConnection();

                        //Load all the accommodations
                        string html = "";
                        string accommodationName = "";
                        string address           = "";

                        //Check if the user clicked the join button
                        if (Request.QueryString["joinId"] != null)
                        {
                            //Login
                            Response.Redirect("~/Web/Account/tempLogin.aspx");
                        }
                        else if (Request.QueryString["unjoinId"] != null)
                        {
                            //Login
                            Response.Redirect("~/Web/Account/tempLogin.aspx");
                        }

                        string university = txtText.Text;

                        List <Qaelo.Models.AccommodationModel.Accommodation> rooms = connection.getAllMyRoomsByUniversity(university);

                        foreach (Qaelo.Models.AccommodationModel.Accommodation room in rooms)
                        {
                            //Get accommodation Name
                            int managerId = room.id;

                            Manager manager = new ManagerConnection().getManager(room.managerId);
                            //Confirm Veririfcation

                            if (manager != null)
                            {
                                if (manager.verified)
                                {
                                    if (manager.propertyName != "")
                                    {
                                        accommodationName = manager.propertyName;
                                    }
                                    else
                                    {
                                        accommodationName = "Room Available";
                                    }


                                    //Get Images
                                    string[] listOfImages = room.images.Split(';');

                                    string nfsas  = "";
                                    string gender = "";
                                    string campus = room.campus;

                                    if (accommodationName.Length > 21)
                                    {
                                        accommodationName = accommodationName.Substring(0, 21) + "...";
                                    }
                                    if (room.address.Length > 41)
                                    {
                                        address = room.address.Substring(0, 40) + "...";
                                    }
                                    else
                                    {
                                        address = room.address;
                                    }

                                    if (campus.Length > 18)
                                    {
                                        campus = room.campus.Substring(0, 15) + "...";
                                    }
                                    else
                                    {
                                        campus = room.campus;
                                    }

                                    if (room.gender == "All")
                                    {
                                        gender = "";
                                    }
                                    else
                                    {
                                        gender = room.gender;
                                    }

                                    if (room.accredited)
                                    {
                                        nfsas = "<i class='glyphicon glyphicon-check'></i> Student Loan Accredited";
                                    }
                                    else
                                    {
                                        nfsas = "<i class='glyphicon glyphicon-check'></i>Cash Only";
                                    }

                                    //check if available or not
                                    string available = "";

                                    if (room.status)
                                    {
                                        available = "<a class='btn btn-success'>Available</a>";
                                    }
                                    else
                                    {
                                        available = "<a class='btn btn-danger' >Not available</a>";
                                    }

                                    //Before Joined Property

                                    html += string.Format(@"<div class='col-xs-12 col-sm-12 col-md-12'>
                <div class='thumbnail'>
                    <div class='row'>
                        <div class='col-sm-6'>
                        <a data-toggle='modal' data-target='#myModal{0}' href='#myGallery{0}' data-slide-to='0'>
                           <img src = '../../../Images/Accommodation/{1}' class='img-rounded' height='250' width='100%'/>
                        </a>
                        </div>
                        <div class='col-sm-6 col-md-6'>
                            <i class='small pull-right' style='background-color:aliceblue'><small>{2}</small></i>
                            <h4>{3}</h4>
                           <a href='students-room.aspx?id={0}'> <small><cite title = 'Brxiton' ><i class='glyphicon glyphicon-map-marker'>
                            </i> {10}</cite></small>
                            <div class='list-group'>
                                <div class='list-group-item'>{4}</div>
                                <div class='list-group-item'><i class='fa fa-users' aria-hidden='true'></i>{5} <b> {6}</b></div>
                                <div class='list-group-item'><i class='fa fa-map-marker' aria-hidden='true'></i>{7} KM from {8}</div>
                            </div>
                                </a>
                            <div class='btn-group'>
                                <a type ='button' href='student-accommodation.aspx?joinId={0}' class='btn btn-success'>Join Property</a>
                            </div>
                            <p style = 'font-size:15px' class='pull-right'><b>R{9}</b>
                            </p>
                        </div>
                    </div>
                </div>
            </div> ", room.id, listOfImages[0], available, accommodationName, nfsas, room.arrangement, gender, room.distanceFromCampus, campus, room.price, room.address);

                                    //Modal
                                    html += string.Format(@"<div class='modal fade-scale' id='myModal{0}' style='margin-top:10%'>
                            <div class='modal-dialog'>
                            <div class='modal-content'>
                            <div class='modal-body'>

                            <div id = 'myGallery{0}' class='carousel slide' data-interval='false'>
                            <div class='carousel-inner'>
                            <div class='item active'> <img src = '../../../Images/Accommodation/{1}' alt='item0' width='100%'>
                            </div>
                            <div class='item'> <img src = '../../../Images/Accommodation/{2}' alt='item2' width='100%'>
                            </div>
                            <div class='item'> <img src = '../../../Images/Accommodation/{3}' alt='item3' width='100%'>
                            </div>
                            <div class='item'> <img src = '../../../Images/Accommodation/{4}' alt='item4' width='100%'>
                            </div>
                            <div class='item'> <img src = '../../../Images/Accommodation/{5}' alt='item5' width='100%'>
                            </div>
                            </div>

                            <a class='left carousel-control' href='#myGallery{0}' role='button' data-slide='prev'> <span class='glyphicon glyphicon-chevron-left'></span></a> <a class='right carousel-control' href='#myGallery{0}' role='button' data-slide='next'> <span class='glyphicon glyphicon-chevron-right'></span></a>
                            </div>
                            </div>

                            </div>
                            </div>
                            </div>", room.id, listOfImages[0], listOfImages[1], listOfImages[2], listOfImages[3], listOfImages[4]);
                                }//If verified
                            }
                        }
                        //if (html == "")
                        //    html = "<div class='alert alert-info'><h3>Unfortunately there are no rooms in this category</div></h3>";

                        lblListOfRooms.Text = html;
                    }

                    #endregion

                    #region Loggedin
                    else
                    {
                        AccommodationConnection           connection = new AccommodationConnection();
                        Qaelo.Models.StudentModel.Student student    = (Qaelo.Models.StudentModel.Student)(Session["STUDENT"]);

                        //Load all the accommodations
                        string html = "";
                        string accommodationName = "";
                        int    studentId         = student.Id;
                        string address           = "";

                        //Check if the user clicked the join button
                        if (Request.QueryString["joinId"] != null)
                        {
                            Qaelo.Models.AccommodationModel.Accommodation room = connection.getRoom(Convert.ToInt32(Request.QueryString["joinId"].ToString()));

                            connection.joinPropery(room.managerId, room.id, studentId);
                        }
                        else if (Request.QueryString["unjoinId"] != null)
                        {
                            Qaelo.Models.AccommodationModel.Accommodation room = connection.getRoom(Convert.ToInt32(Request.QueryString["unjoinId"].ToString()));

                            connection.unjoinProperty(room.id, studentId);
                        }

                        string university = txtText.Text;
                        List <Qaelo.Models.AccommodationModel.Accommodation> rooms = connection.getAllMyRoomsByUniversity(university);

                        foreach (Qaelo.Models.AccommodationModel.Accommodation room in rooms)
                        {
                            //Get accommodation Name
                            int managerId = room.id;

                            Manager manager = new ManagerConnection().getManager(room.managerId);
                            //Confirm Veririfcation

                            if (manager != null)
                            {
                                if (manager.verified)
                                {
                                    if (manager.propertyName != "")
                                    {
                                        accommodationName = manager.propertyName;
                                    }
                                    else
                                    {
                                        accommodationName = "Room Available";
                                    }


                                    //Get Images
                                    string[] listOfImages = room.images.Split(';');

                                    string nfsas  = "";
                                    string gender = "";
                                    string campus = room.campus;

                                    if (accommodationName.Length > 21)
                                    {
                                        accommodationName = accommodationName.Substring(0, 21) + "...";
                                    }
                                    if (room.address.Length > 41)
                                    {
                                        address = room.address.Substring(0, 40) + "...";
                                    }
                                    else
                                    {
                                        address = room.address;
                                    }

                                    if (campus.Length > 18)
                                    {
                                        campus = room.campus.Substring(0, 15) + "...";
                                    }
                                    else
                                    {
                                        campus = room.campus;
                                    }

                                    if (room.gender == "All")
                                    {
                                        gender = "";
                                    }
                                    else
                                    {
                                        gender = room.gender;
                                    }

                                    if (room.accredited)
                                    {
                                        nfsas = "<i class='glyphicon glyphicon-check'></i> Student Loan Accredited";
                                    }
                                    else
                                    {
                                        nfsas = "<i class='glyphicon glyphicon-check'></i>Cash Only";
                                    }

                                    //check if available or not
                                    string available = "";

                                    if (room.status)
                                    {
                                        available = "<a class='btn btn-success'>Available</a>";
                                    }
                                    else
                                    {
                                        available = "<a class='btn btn-danger' >Not available</a>";
                                    }


                                    if (connection.propertyJoinedByUser(room.id, studentId))
                                    {
                                        //When the property is joined
                                        html += string.Format(@"<div class='col-xs-12 col-sm-12 col-md-12'>
                    <div class='thumbnail'>
                    <div class='row'>
                        <div class='col-sm-6'>
                        <a data-toggle='modal' data-target='#myModal{0}' href='#myGallery{0}' data-slide-to='0'>
                           <img src = '../../../Images/Accommodation/{1}' class='img-rounded' height='250' width='100%'/>
                        </a>
                        </div>
                        <div class='col-sm-6 col-md-6'>
                            <i class='small pull-right' style='background-color:aliceblue'><small>{2}</small></i>
                            <h4>{3}</h4>
                           <a href='students-room.aspx?id={0}'> <small><cite title = 'Brxiton' ><i class='glyphicon glyphicon-map-marker'>
                            </i> {10}</cite></small>
                            <div class='list-group'>
                                <div class='list-group-item'>{4}</div>
                                <div class='list-group-item'><i class='fa fa-users' aria-hidden='true'></i>{5} <b> {6}</b></div>
                                <div class='list-group-item'><i class='fa fa-map-marker' aria-hidden='true'></i>{7} KM from {8}</div>
                            </div>
                                </a>
                            <div class='btn-group'>
                                <a type ='button' href='student-accommodation.aspx?unjoinId={0} &search={11}' class='btn btn-danger'>Joined</a>
                            </div>
                            <p style = 'font-size:15px' class='pull-right'><b>R{9}</b>
                            </p>
                        </div>
                    </div>
                </div>
            </div> ", room.id, listOfImages[0], available, accommodationName, nfsas, room.arrangement, gender, room.distanceFromCampus, campus, room.price, address, Request.QueryString["search"]);
                                    }
                                    else
                                    {
                                        //Before Joined Property
                                        html += string.Format(@"<div class='col-xs-12 col-sm-12 col-md-12'>
                <div class='thumbnail'>
                    <div class='row'>
                        <div class='col-sm-6 col-md-6'>
                        <a data-toggle='modal' data-target='#myModal{0}' href='#myGallery{0}' data-slide-to='0'>
                           <img src = '../../../Images/Accommodation/{1}' class='img-rounded' height='250' width='100%'/>
                        </a>
                        </div>
                        <div class='col-sm-6 col-md-6'>
                            <i class='small pull-right' style='background-color:aliceblue'><small>{2}</small></i>
                            <h4>{3}</h4>
                           <a href='students-room.aspx?id={0}'> <small><cite title = 'Brxiton' ><i class='glyphicon glyphicon-map-marker'>
                            </i> {10}</cite></small>
                            <div class='list-group'>
                                <div class='list-group-item'>{4}</div>
                                <div class='list-group-item'><i class='fa fa-users' aria-hidden='true'></i>{5} <b> {6}</b></div>
                                <div class='list-group-item'><i class='fa fa-map-marker' aria-hidden='true'></i>{7} KM from {8}</div>
                            </div>
                                </a>
                            <div class='btn-group'>
                                <a type ='button' href='student-accommodation.aspx?joinId={0} &search={11}' class='btn btn-success'>Join Property</a>
                            </div>
                            <p style = 'font-size:15px' class='pull-right'><b>R{9}</b>
                            </p>
                        </div>
                    </div>
                </div>
            </div> ", room.id, listOfImages[0], available, accommodationName, nfsas, room.arrangement, gender, room.distanceFromCampus, campus, room.price, room.address, Request.QueryString["search"]);
                                    }
                                    //Modal
                                    html += string.Format(@"<div class='modal fade-scale' id='myModal{0}' style='margin-top:10%'>
                <div class='modal-dialog'>
                <div class='modal-content'>
                <div class='modal-body'>

                <div id = 'myGallery{0}' class='carousel slide' data-interval='false'>
                <div class='carousel-inner'>
                <div class='item active'> <img src = '../../../Images/Accommodation/{1}' alt='item0' width='100%'>
                </div>
                <div class='item'> <img src = '../../../Images/Accommodation/{2}' alt='item2' width='100%'>
                </div>
                <div class='item'> <img src = '../../../Images/Accommodation/{3}' alt='item3' width='100%'>
                </div>
                <div class='item'> <img src = '../../../Images/Accommodation/{4}' alt='item4' width='100%'>
                </div>
                <div class='item'> <img src = '../../../Images/Accommodation/{5}' alt='item5' width='100%'>
                </div>
                </div>

                <a class='left carousel-control' href='#myGallery{0}' role='button' data-slide='prev'> <span class='glyphicon glyphicon-chevron-left'></span></a> <a class='right carousel-control' href='#myGallery{0}' role='button' data-slide='next'> <span class='glyphicon glyphicon-chevron-right'></span></a>
                </div>
                </div>

                </div>
                </div>
                </div>", room.id, listOfImages[0], listOfImages[1], listOfImages[2], listOfImages[3], listOfImages[4]);
                                }//If verified
                            }
                        }
                        #endregion

                        //if (html == "")
                        //    html = "<div class='alert alert-info'><h3>Unfortunately there are no rooms in this category</div></h3>";
                        lblListOfRooms.Text = html;
                    }//End of else
                }
            }
        }