예제 #1
0
        public ActionResult Terms(PropertyTermsInputModel input)
        {
            if (ModelState.IsValid)
            {
                var status = this.propertyAdapter.UpdatePropertyTerms(User.Identity.Name, input.ToBuilding());

                if (status.StatusCode == 200)
                {
                    return(RedirectToAction("promote", new { id = input.BuildingId }));
                }

                HandleErrors(status);
            }

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

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

            // return the model back with model state errors
            PropertyTermsModel model = new PropertyTermsModel()
            {
                Input          = input,
                StepsAvailable = GetStepsAvailable(buildingVal.Result)
            };

            return(View(model));
        }
예제 #2
0
        public ActionResult Terms(PropertyTermsInputModel input)
        {
            if (ModelState.IsValid)
            {
                // rebuild building
                Building building = new Building()
                {
                    BuildingId = input.BuildingId,
                    IsBackgroundCheckRequired = input.IsBackgroundCheckRequired,
                    IsCreditCheckRequired     = input.IsCreditCheckRequired,
                    Price             = input.Price,
                    Deposit           = (input.Deposit.HasValue) ? input.Deposit.Value : decimal.Zero,
                    RefundableDeposit = (input.RefundableDeposit.HasValue) ? input.RefundableDeposit.Value : decimal.Zero,
                    DateAvailableUtc  = input.DateAvailableUtc,
                    LeaseLengthCode   = input.LeaseLengthCode,
                    IsSmokingAllowed  = input.IsSmokingAllowed,
                    ArePetsAllowed    = input.ArePetsAllowed
                };

                // pets are not allowed so no fee can be charged
                if (!input.ArePetsAllowed)
                {
                    building.PetFee = decimal.Zero;
                }
                else
                {
                    building.PetFee = (input.PetFee.HasValue) ? input.PetFee.Value : decimal.Zero;
                }

                var status = this.propertyAdapter.UpdatePropertyTerms(User.Identity.Name, building);

                if (status.StatusCode == 200)
                {
                    return(RedirectToAction("promote", new { id = input.BuildingId }));
                }

                HandleErrors(status);
            }

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

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

            // return the model back with model state errors
            PropertyTermsModel model = new PropertyTermsModel()
            {
                Input          = input,
                StepsAvailable = GetStepsAvailable(buildingVal.Result)
            };

            return(View(model));
        }