Exemplo n.º 1
0
        public ActionResult Promote(long?id)
        {
            if (!id.HasValue)
            {
                return(this.NotFoundException());
            }

            var status = this.propertyAdapter.GetPropertyPromoteInfo(id.Value, User.Identity.Name);

            var featured = this.featuredAdapter.GetFeaturedDates();

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

            Building building = status.Result;

            PropertyPromoteModel model = new PropertyPromoteModel();

            model.StepsAvailable = GetStepsAvailable(status.Result);
            model.Input          = new PropertyPromoteInputModel(building, featured.Result);

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Promote(PropertyPromoteInputModel input)
        {
            if (ModelState.IsValid)
            {
                // rebuild building
                Building building = input.ToBuilding();

                if (input.SelectedRibbonId.ToLower() == "none")
                {
                    input.SelectedRibbonId = null;
                }

                var status = this.propertyAdapter.UpdatePropertyPromotions(
                    User.Identity.Name, building, input.SelectedRibbonId, input.FeaturedDates);

                if (status.StatusCode == 200)
                {
                    // see if user selected a ribbon or requested to feature their property (coming soon)
                    if (status.Result.TemporaryOrder == null)
                    {
                        return(Redirect("/listing/index/" + input.BuildingId));
                    }
                    else
                    {
                        return(Redirect("/dashboard/order/checkout/" + status.Result.TemporaryOrderId));
                    }
                }

                HandleErrors(status);
            }

            var buildingVal = this.propertyAdapter.GetProperty(input.BuildingId, User.Identity.Name);

            if (buildingVal.StatusCode != 200)
            {
                return(HttpNotFound());
            }

            // reset model properties not persisted
            input.PrimaryPhotoId        = buildingVal.Result.PrimaryPhotoId;
            input.PrimaryPhotoExtension = buildingVal.Result.PrimaryPhotoExtension;

            input.CalendarDates = new CalendarDatesModel();
            // TODO: also need to restore blackout and featured dates too
            input.CalendarDates.ReservedDates =
                input.FeaturedDates.Select(d => d.ToString("G")).ToArray();

            PropertyPromoteModel model = new PropertyPromoteModel()
            {
                Input          = input,
                StepsAvailable = GetStepsAvailable(buildingVal.Result)
            };

            // return the model back with model state errors
            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult Promote(long id)
        {
            var status = this.propertyAdapter.GetPropertyPromoteInfo(id, User.Identity.Name);

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

            Building building = status.Result;

            PropertyPromoteModel model = new PropertyPromoteModel();

            model.StepsAvailable = GetStepsAvailable(status.Result);
            model.Input          = new PropertyPromoteInputModel(building);

            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult Promote(PropertyPromoteInputModel input)
        {
            if (ModelState.IsValid)
            {
                // rebuild building
                Building building = input.ToBuilding();

                if (string.IsNullOrWhiteSpace(input.SelectedRibbonId) || input.SelectedRibbonId.ToLower() == "none")
                {
                    input.SelectedRibbonId = null;
                }

                var status = this.propertyAdapter.UpdatePropertyPromotions(
                    User.Identity.Name,
                    building,
                    input.SelectedRibbonId,
                    input.FeaturedDates,
                    input.ListingHasPriority ? "prioritylisting" : string.Empty
                    );

                if (status.StatusCode == 200)
                {
                    // see if user selected a ribbon or requested to feature their property (coming soon)
                    if (status.Result.TemporaryOrder == null)
                    {
                        this.propertyAdapter.ActivateBuilding(building.BuildingId, User.Identity.Name);

                        return(RedirectToAction("complete", new { id = input.BuildingId }));
                    }
                    else
                    {
                        return(Redirect("/order/checkout/" + status.Result.TemporaryOrderId));
                    }
                }

                HandleErrors(status);
            }

            var buildingVal = this.propertyAdapter.GetProperty(input.BuildingId, User.Identity.Name);

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

            // reset model properties not persisted
            input.PrimaryPhotoId        = buildingVal.Result.PrimaryPhotoId;
            input.PrimaryPhotoExtension = buildingVal.Result.PrimaryPhotoExtension;

            input.CalendarDates = new CalendarDatesModel();
            // TODO: also need to restore blackout and featured dates too

            if (input.CalendarDates.ReservedDates.Any())
            {
                input.CalendarDates.ReservedDates =
                    input.FeaturedDates.Select(d => d.ToString("G")).ToArray();
            }
            else
            {
                input.CalendarDates.ReservedDates = new string[] { }
            };

            PropertyPromoteModel model = new PropertyPromoteModel()
            {
                Input          = input,
                StepsAvailable = GetStepsAvailable(buildingVal.Result)
            };

            // return the model back with model state errors
            return(View(model));
        }