/
UserListing.aspx.cs
69 lines (68 loc) · 2.4 KB
/
UserListing.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using HousingApp.ClassFiles;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
namespace HousingApp
{
public partial class UserListing : System.Web.UI.Page
{
public bool showFav = true;
protected void Page_Load(object sender, EventArgs e)
{
if (!Utilities.IsUserLoggedIn())
{
Response.Redirect("/login.aspx?returnurl=/UserListing.aspx");
}
else
{
Int32 userId = 0;
if (Session["currentUserId"] != null)
{
Int32.TryParse(Session["currentUserId"].ToString(), out userId);
hdnUserId.Value = userId.ToString();
}
}
String storedProc = "dbo.sp_GetAllHome";
List<SqlParameter> sqlparameters = new List<SqlParameter>();
ltrName.Text = "All Homes";
if (Request.QueryString["type"] != null)
{
String homeTypeProc = Request.QueryString["type"];
if(homeTypeProc.Equals("apt"))
{
ltrName.Text = "Apartments";
storedProc = "dbo.sp_GetApartments";
}
else if (homeTypeProc.Equals("home"))
{
storedProc = "dbo.sp_GetHome";
ltrName.Text = "Individual Homes";
}
else if (homeTypeProc.Equals("fav"))
{
ltrName.Text = "User Favorite Homes";
showFav = false;
storedProc = "dbo.sp_GetFavorites";
Int32 userId = 0;
if (Session["currentUserId"] != null)
{
Int32.TryParse(Session["currentUserId"].ToString(), out userId);
}
sqlparameters.Add(new SqlParameter("@user_id", userId));
}
}
DataSet ds = BO.CallSQLProcwithReturnValue(storedProc, sqlparameters.ToArray());
if (ds.Tables.Count > 0)
{
rptHome.DataSource = ds;
rptHome.DataBind();
}
}
}
}