public ActionResult Index(long ad, Guid? token) { if(!User.Identity.IsAuthenticated && token.HasValue) { var user = authAdapter.ValidateAuthToken(token.Value); if(user.StatusCode == 200) FormsAuthentication.SetAuthCookie(user.Result.Username, true); } var status = this.listingAdapter.GetListing(ad); // this is ok because the adapter will return 0 if count cannot // be retrieved var viewCount = this.listingAdapter.GetListingViews(ad).Result; var userHasSaved = this.listingAdapter.ListingWasSavedBy(ad, User.Identity.Name).Result; var model = new ListingIndexModel(); model.Listing = status.Result; model.ListingViews = viewCount; model.UserHasSaved = userHasSaved; return View(model); }
public ActionResult Index(long id) { var status = this.listingAdapter.GetListing(id); if(status.StatusCode != 200) return HttpNotFound(); // this is ok because the adapter will return 0 if count cannot // be retrieved var viewCount = this.listingAdapter.GetListingViews(id).Result; var userHasSaved = this.listingAdapter.ListingWasSavedBy(id, User.Identity.Name).Result; var model = new ListingIndexModel(); model.Listing = status.Result; model.ListingViews = viewCount; model.UserHasSaved = userHasSaved; return View(model); }
/// <summary> /// View a listing by its id. /// </summary> /// <param name="id">The id of the listing to view.</param> /// <returns>The listing page</returns> //disabled until we can separately cache ajax/straight listings //[UnAuthenticatedCache(Duration = 3600)] public ActionResult Index(long? id) { if (!id.HasValue) return this.NotFoundException(); var status = this.listingAdapter.GetListing(id.Value); if (status.StatusCode != 200) return this.NotFoundException(); this.listingAdapter.IncrementListingViews(id.Value); // this is ok because the adapter will return 0 if count cannot // be retrieved var viewCount = this.listingAdapter.GetListingViews(id.Value).Result; var userHasSaved = this.listingAdapter.ListingWasSavedBy(id.Value, User.Identity.Name).Result; var model = new ListingIndexModel(); model.Listing = status.Result; model.ListingViews = viewCount; model.UserHasSaved = userHasSaved; //set the login url to Rentler model.LoginUrl = "/account/login?ReturnUrl=/listing/" + status.Result.BuildingId; if (Request.IsAjaxRequest()) return PartialView("ListingDetails", model); return View(model); }
public ActionResult Index(long? ad, Guid? token) { if (!ad.HasValue) return this.NotFoundException(); RedisPublisher.Publish("token", "Listing page " + ad.Value + " token: " + token.HasValue.ToString()); if (!User.Identity.IsAuthenticated && token.HasValue) { var user = authAdapter.ValidateAuthToken(token.Value); if (user.StatusCode == 200) CustomAuthentication.SetAuthCookie(user.Result.Username, user.Result.UserId, true); return Redirect("/ksl/listing/index?ad=" + ad.Value); } var status = this.listingAdapter.GetListing(ad.Value); // this is ok because the adapter will return 0 if count cannot // be retrieved var viewCount = this.listingAdapter.GetListingViews(ad.Value).Result; var userHasSaved = this.listingAdapter.ListingWasSavedBy(ad.Value, User.Identity.Name).Result; if (status.StatusCode != 200) return this.NotFoundException(); this.listingAdapter.IncrementListingViews(ad.Value); var model = new ListingIndexModel(); model.Listing = status.Result; model.ListingViews = viewCount; model.UserHasSaved = userHasSaved; //set the login url to Ksl model.LoginUrl = string.Format("{0}{1}?login_forward=", Rentler.Web.Config.KslDomain, Rentler.Web.Config.KslLoginPath); model.LoginUrl += Url.Encode(string.Format("{0}{1}{2}", Rentler.Web.Config.KslDomain, Rentler.Web.Config.KslListingPath, status.Result.BuildingId)); return View(model); }