Skip to content

Commit

Permalink
User can see their own listings. Closes #46
Browse files Browse the repository at this point in the history
  • Loading branch information
bduong committed Apr 24, 2013
1 parent 8421c0f commit 4f1cab1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
15 changes: 13 additions & 2 deletions Views/Layout.master.cs
Expand Up @@ -6,6 +6,7 @@
using System.Web.UI.WebControls;
using System.Web.Security;


public partial class Views_MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
Expand All @@ -30,8 +31,18 @@ protected void go_post(object sender, EventArgs e)
Response.Redirect("~/Views/Private/Post.aspx");
}
protected void go_profile(object sender, EventArgs e)
{
Response.Redirect("~/Views/Private/Profile.aspx");
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
MembershipUser userInfo = Membership.GetUser();
Guid userId = (Guid)userInfo.ProviderUserKey;
Response.Redirect("~/Views/Search.aspx?user=" + userId.ToString());
}
else
{
Response.Redirect("~/Views/Login.aspx");
}

}
protected void go_notifications(object sender, EventArgs e)
{
Expand Down
25 changes: 24 additions & 1 deletion Views/Search.aspx.cs
Expand Up @@ -12,7 +12,8 @@ protected void Page_Load(object sender, EventArgs e)
{
string parameter = Request["__EVENTARGUMENT"];
string page = Request["__EVENTTARGET"];
string query = Request.Params["query"];
string query = Request.Params["query"];
string user = Request.Params["user"];
if (parameter != null)
{
if (parameter == "")
Expand Down Expand Up @@ -41,6 +42,11 @@ protected void Page_Load(object sender, EventArgs e)
{
fr_view.ActiveViewIndex = 2;
doQuery(query);
}
else if (user != "" && user != null)
{
fr_view.ActiveViewIndex = 2;
doUserQuery(query);
}
else
{
Expand Down Expand Up @@ -230,6 +236,23 @@ protected void doQuery(String q)
string objectHTML = createSearchItemDiv(listing);
results.InnerHtml += objectHTML;
}
}

protected void doUserQuery(string q)
{
fr_view.ActiveViewIndex = 2;
results.InnerHtml = "";

/* get values from database table */
MembershipUser userInfo = Membership.GetUser();
Guid userId = (Guid) userInfo.ProviderUserKey;
List<Listing> all_results = ListingDataService.getListingsBy(ListingDataService.ColumnNames.UserId, userId.ToString());

foreach (Listing listing in all_results)
{
string objectHTML = createSearchItemDiv(listing);
results.InnerHtml += objectHTML;
}
}


Expand Down

0 comments on commit 4f1cab1

Please sign in to comment.