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));
        }
Exemple #2
0
        public ActionResult Checkout(int id, Guid?token)
        {
            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(RedirectToAction("checkout"));
                }
            }

            var status = this.orderAdapter.GetOrderForCheckout(User.Identity.Name, id);

            if (status.StatusCode != 200)
            {
                return(this.NotFoundException());
            }

            Rentler.Web.Models.OrderCheckoutModel model = new Rentler.Web.Models.OrderCheckoutModel()
            {
                Order = status.Result,
                Input = new Rentler.Web.Models.OrderCheckoutInputModel()
            };

            // auto-select the first payment method
            if (status.Result.User.UserCreditCards.Count > 0)
            {
                model.Input.SelectedPaymentMethod = status.Result.User.UserCreditCards.First();
            }

            return(View(model));
        }
        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 Create(Guid?token, int?PropertyTypeCode)
        {
            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(RedirectToAction("create"));
                }
            }

            Rentler.Web.Models.PropertyCreateModel model = new Models.PropertyCreateModel();
            model.IsKsl = true;

            // set property type from ksl from user selection
            model.Input.PropertyTypeCode = PropertyTypeCode.HasValue ? PropertyTypeCode.Value : 0;
            return(View(model));
        }
        public ActionResult Search(PropertySearch search, Guid?token)
        {
            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("/property/search"));
            }

            var result = this.propertyFacade.SearchForUserProperty(search);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("SearchResults", result.Result));
            }
            return(View(result.Result));
        }
        public ActionResult Index(Search search, Guid?token)
        {
            if (!User.Identity.IsAuthenticated && token.HasValue)
            {
                var user = authAdapter.ValidateAuthToken(token.Value);

                if (user.StatusCode == 200)
                {
                    FormsAuthentication.SetAuthCookie(user.Result.Username, true);
                }
            }

            return(View());
        }
        public ActionResult Index(Search search, Guid?token)
        {
            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);
                }
            }


            // Fix for php sending goofy data to us.
            if (Request["Amenities[]"] != null)
            {
                if (search.Amenities == null)
                {
                    List <string> strings = new List <string>(
                        Request["Amenities[]"].Split(",".ToCharArray()));
                    search.Amenities = strings.ToArray();
                }
            }

            // Fix for php sending goofy data to us.
            if (Request["Terms[]"] != null)
            {
                if (search.Terms == null)
                {
                    List <string> strings = new List <string>(
                        Request["Terms[]"].Split(",".ToCharArray()));
                    search.Terms = strings.ToArray();
                }
            }

            var result = this.searchAdapter.Search(search);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("SearchResults", result.Result));
            }

            return(View(result.Result));
        }