Exemplo n.º 1
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("/dashboard/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);
        }
Exemplo n.º 2
0
        public ActionResult Promote(long id)
        {
            var status = this.propertyAdapter.GetPropertyPromoteInfo(id, 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);
        }