Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sessionUser;
            int    userID;

            try
            {
                DataAccessLayer dao = new DataAccessLayer();
                if (Session["userEmail"] != null)
                {
                    sessionUser     = Session["userEmail"].ToString();
                    hiddenUser.Text = sessionUser;
                    userID          = dao.getUserID(sessionUser);
                    SqlDataReader reader = dao.GetUserProperties(userID, Constants.propertyEnabled);
                    Repeater1.DataSource = reader;
                    Repeater1.DataBind();
                }
                else
                {
                    Response.Redirect("Login.aspx");
                }
            }
            catch (Exception)
            {
                Console.Write("error");
            }
        }
Example #2
0
 protected void markFav_Click(object sender, EventArgs e)
 {
     if (Session["userEmail"] != null)
     {
         DataAccessLayer dao = new DataAccessLayer();
         sessionUser = Session["userEmail"].ToString();
         int propertyID   = int.Parse(hiddenPropertyID.Value);
         int loggedUserID = dao.getUserID(sessionUser);
         dao.AddtoFavourites(propertyID, loggedUserID);
     }
 }
Example #3
0
        protected void removeFavourites_Click(object sender, EventArgs e)
        {
            int             propertyID = int.Parse(propID.Value);
            string          userEmail  = hiddenUser.Value;
            DataAccessLayer dao        = new DataAccessLayer();
            int             emailID    = dao.getUserID(userEmail);



            dao.DeleteFavourites(propertyID, emailID);
            Response.Redirect("Favourites.aspx");
        }
Example #4
0
        protected void confirmMarkAsFav_Click(object sender, EventArgs e)
        {
            string sessionUser;

            if (Session["userEmail"] != null)
            {
                DataAccessLayer dao = new DataAccessLayer();
                sessionUser = Session["userEmail"].ToString();
                int propertyID   = int.Parse(propID.Value);
                int loggedUserID = dao.getUserID(sessionUser);
                dao.AddtoFavourites(propertyID, loggedUserID);
                Response.Redirect("Favourites.aspx");
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sessionUser;
            int    userID;

            try
            {
                DataAccessLayer dao = new DataAccessLayer();
                if (Session["userEmail"] != null)
                {
                    sessionUser      = Session["userEmail"].ToString();
                    hiddenUser.Value = sessionUser;
                    userID           = dao.getUserID(sessionUser);
                    SqlDataReader reader       = dao.GetFavouritePropertiesID(userID);
                    DataTable     favList      = new DataTable();
                    string        _propertyIds = string.Empty;
                    while (reader.Read())
                    {
                        int propertyID = reader.GetInt32(0);
                        _propertyIds += string.Concat(propertyID, ",");
                    }
                    _propertyIds         = _propertyIds.TrimEnd(',');
                    favList              = dao.GetUserFavouriteProperties(userID, _propertyIds, Constants.propertyEnabled);
                    Repeater1.DataSource = favList;
                    Repeater1.DataBind();
                }
                else
                {
                    Response.Redirect("Login.aspx");
                }
            }
            catch (Exception)
            {
                Console.Write("error");
            }
        }
Example #6
0
        protected void btnSubmitProperty_Click(object sender, EventArgs e)
        {
            DataAccessLayer dao = new DataAccessLayer();

            sessionUser = Session["userEmail"].ToString();

            string propertyName;
            string propertyLocation;
            string propertyDescription;
            string propertyAddress;
            string responseMessage;
            int    propertyType;
            int    propertyPrice;
            int    propertyBedroom;
            int    propertyBathroom;
            int    propertySquarefeet;
            int    isFeatured;
            int    userID;
            int    lastInsertedPropertyID;

            propertyName        = txtPropertyName.Text;
            propertyLocation    = txtPropertyLocation.Text;
            propertyDescription = txtPropertyDescription.InnerText;
            propertyAddress     = txtPropertyAddress.Text;
            propertyType        = int.Parse(ddlPropertyType.SelectedItem.Value);
            propertyPrice       = int.Parse(txtPropertyPrice.Text);
            propertyBedroom     = int.Parse(txtBedRoom.Text);
            propertyBathroom    = int.Parse(txtBathRoom.Text);
            propertySquarefeet  = int.Parse(txtSquareFeet.Text);

            if (cbFeatured.Checked == true)
            {
                isFeatured = Constants.isFeatured;
            }
            else
            {
                isFeatured = Constants.isNotFeatured;
            }

            userID = dao.getUserID(sessionUser);

            if (dao.InsertProperty(propertyType, propertyName, propertyLocation, propertyAddress, propertySquarefeet, propertyBedroom, propertyBathroom, propertyDescription, isFeatured, Constants.isNotApproved, Constants.propertyEnabled, propertyPrice, userID) == true)
            {
                List <string> imageFiles = new List <string>();

                lastInsertedPropertyID = dao.getLastInsertedPropertyID();
                string applicationPath = Constants.path;

                foreach (var postedFile in uploadwidget.PostedFiles)
                {
                    string imageName = System.IO.Path.GetFileName(postedFile.FileName);
                    string location  = applicationPath + "userassets" + @"\" + sessionUser + @"\propertyImages\" + lastInsertedPropertyID;
                    imageFiles.Add((string)imageName);

                    if (!Directory.Exists(location))
                    {
                        Directory.CreateDirectory(location);
                    }

                    string SaveLocation = location + "\\" + imageName;
                    try
                    {
                        postedFile.SaveAs(SaveLocation);
                        dao.InsertPropertyImages(lastInsertedPropertyID, userID, imageName);
                    }
                    catch (Exception ex)
                    {
                        Response.Write(ex.Message);
                    }
                }

                dao.UpdateImagetoPropertyTable(lastInsertedPropertyID, imageFiles[0]);

                responseMessage  = "Property Submitted";
                respMessage.Text = responseMessage;
            }
            else
            {
                Console.WriteLine("Error");
            }
        }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string        properType;
            List <string> imageFiles = new List <string>();

            try
            {
                if (!String.IsNullOrEmpty(Request.QueryString["propID"]))
                {
                    DataAccessLayer dao = new DataAccessLayer();
                    SqlDataReader   reader;
                    int             loggedinUser;
                    // Query string value is there so now use it
                    param = Convert.ToInt32(Request.QueryString["propID"]);

                    if (Session["userEmail"] != null)
                    {
                        sessionUser  = Session["userEmail"].ToString();
                        loggedinUser = dao.getUserID(sessionUser);

                        //if session and propID match
                        if (dao.checkSessionandLoggedinUser(param, loggedinUser) == true)
                        {
                            reader = dao.SelectPropertyByID(param);
                        }
                        else
                        {
                            reader = dao.NotSessionSelectPropertyByID(param, Constants.isApproved);
                        }
                    }
                    else
                    {
                        reader = dao.NotSessionSelectPropertyByID(param, Constants.isApproved);
                    }

                    if (!reader.HasRows)
                    {
                        Response.Redirect("Error-404.aspx");
                    }

                    while (reader.Read())
                    {
                        int    propertyID          = reader.GetInt32(0);
                        int    propertyType        = reader.GetByte(1);
                        string propertyName        = reader.GetString(2);
                        string propertyLocation    = reader.GetString(3);
                        string propertyAddress     = reader.GetString(4);
                        int    propertySquareFeet  = reader.GetInt32(5);
                        int    propertyBedroom     = reader.GetByte(6);
                        int    propertyBathroom    = reader.GetByte(7);
                        string propertyDescription = reader.GetString(8);
                        int    propertyFeatured    = reader.GetByte(9);
                        int    propertyApproved    = reader.GetByte(10);
                        int    propertyStatus      = reader.GetByte(12);
                        int    propertyPrice       = reader.GetInt32(13);
                        int    propertyUser        = reader.GetInt32(14);

                        string agentID = dao.GetUserEmail(propertyUser);
                        hiddenAgent.Value = agentID;

                        hiddenPropertyID.Value = "" + reader.GetInt32(0);
                        hiddenUserID.Value     = "" + reader.GetInt32(14);


                        SqlDataReader reader1 = dao.GetImagesByID(reader.GetInt32(0));

                        while (reader1.Read())
                        {
                            imageFiles.Add((string)reader1.GetString(0));
                        }

                        Repeater1.DataSource = imageFiles;
                        Repeater1.DataBind();

                        if (reader.GetByte(1) == 1)
                        {
                            properType = "For Sale";
                        }
                        else
                        {
                            properType = "For Rent";
                        }

                        SqlDataReader reader2 = dao.FetchUser(agentID);

                        while (reader2.Read())
                        {
                            string userName     = reader2.GetString(2);
                            string userPhone    = reader2.GetString(3);
                            string userEmail    = reader2.GetString(5);
                            string userFB       = reader2.GetString(6);
                            string userLinkedin = reader2.GetString(7);
                            string userTwitter  = reader2.GetString(8);
                            string userDesc     = reader2.GetString(9);
                            string userSkype    = reader2.GetString(11);
                            string userImage    = reader2.GetString(12);

                            if (!IsPostBack)
                            {
                                propName.InnerText      = propertyName;
                                propAddress.InnerText   = propertyAddress;
                                propDesc.InnerText      = propertyDescription;
                                propSQFT.InnerText      = propertySquareFeet + " Sq Ft";
                                propBeds.InnerText      = propertyBedroom + " Bedrooms";
                                propBaths.InnerText     = propertyBathroom + " Bathrooms";
                                propUniqueID.InnerText  = "" + propertyID;
                                propPrice.InnerText     = "$" + propertyPrice;
                                propSize.InnerText      = propertySquareFeet + " Sq Ft";
                                propBedrooms.InnerText  = propertyBedroom + " Bedrooms";
                                propBathrooms.InnerText = propertyBathroom + " Bathrooms";
                                houseName.InnerText     = propertyName;
                                houseAddress.InnerText  = propertyAddress;
                                houseLocation.InnerText = propertyLocation;
                                houseStatus.InnerText   = properType;
                                houseAgent.InnerText    = agentID;
                                agentName.InnerText     = userName;
                                agentDesc.InnerText     = userDesc;
                                angentPhone.InnerText   = userPhone;
                                agentEmail.InnerText    = userEmail;
                                agentSkype.InnerText    = userSkype;
                                agentFBUrl.HRef         = userFB;
                                agentLinkedinUrl.HRef   = userLinkedin;
                                agentTwitterUrl.HRef    = userTwitter;
                                agentProfile.ImageUrl   = "userassets/" + userEmail + "/" + userImage;
                            }
                        }
                    }
                }
                else
                {
                    Response.Redirect("Error-404.aspx");
                }
            }
            catch (System.NullReferenceException r)
            {
                //exception handling
            }
        }