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)); }
public ActionResult Terms(long id) { var status = this.propertyAdapter.GetProperty(id, User.Identity.Name); if (status.StatusCode != 200) { return(HttpNotFound()); } Building building = status.Result; PropertyTermsModel model = new PropertyTermsModel(); model.StepsAvailable = GetStepsAvailable(status.Result); model.Input = new PropertyTermsInputModel() { BuildingId = building.BuildingId, IsBackgroundCheckRequired = building.IsBackgroundCheckRequired, IsCreditCheckRequired = building.IsCreditCheckRequired, Price = building.Price, Deposit = building.Deposit, RefundableDeposit = building.RefundableDeposit, DateAvailableUtc = building.DateAvailableUtc, LeaseLengthCode = building.LeaseLengthCode, IsSmokingAllowed = building.IsSmokingAllowed, ArePetsAllowed = building.ArePetsAllowed, PetFee = building.PetFee }; return(View(model)); }
public async Task PropertyService_AddPropertyTermsAsync_Test() { try { using (db = new DatabaseContext(dbContextOpt.Options)) { Guid PropertyId = Guid.Parse("D95FF806-C50A-4A54-A476-02D350B2C6FA"); var propertyTerms = new PropertyTermsModel { PropertyId = PropertyId, MonthDeposit = 2, MonthAdvance = 1 }; var settings = new PropertySettings { Id = Guid.NewGuid(), MonthDeposit = propertyTerms.MonthDeposit, MonthAdvance = propertyTerms.MonthAdvance, PropertyId = propertyTerms.PropertyId }; db.Settings.Add(settings); var result = await db.SaveChangesAsync(); Assert.IsTrue(result == 1); } } catch (Exception ex) { logService.Log("Add Property Terms", ex.InnerException.Message, ex.Message, ex.StackTrace); Assert.Fail(); } }
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)); }
public ActionResult Terms(long id) { var status = this.propertyAdapter.GetProperty(id, User.Identity.Name); if (status.StatusCode != 200) { return(this.NotFoundException()); } PropertyTermsModel model = new PropertyTermsModel(); model.Input = new PropertyTermsInputModel(status.Result); model.StepsAvailable = GetStepsAvailable(status.Result); return(View(model)); }
public void PropertyService_AddPropertyTermsADO_Test() { try { using (SqlConnection con = new SqlConnection(connectionString)) { Guid PropertyId = Guid.Parse("1897C7A7-EB70-4A11-9EF1-C6714DF34D5A"); var propertyTerms = new PropertyTermsModel { PropertyId = PropertyId, MonthDeposit = 2, MonthAdvance = 1 }; var settings = new PropertySettings { Id = Guid.NewGuid(), MonthDeposit = propertyTerms.MonthDeposit, MonthAdvance = propertyTerms.MonthAdvance, PropertyId = propertyTerms.PropertyId }; SqlCommand cmd = new SqlCommand("sp_AddPropertyTerms", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", settings.Id); cmd.Parameters.AddWithValue("@PropertyId", settings.PropertyId); cmd.Parameters.AddWithValue("@MonthAdv", settings.MonthAdvance); cmd.Parameters.AddWithValue("@MonthDep", settings.MonthDeposit); con.Open(); cmd.ExecuteNonQuery(); con.Close(); //Assert.IsTrue(rows > 1); } } catch (Exception ex) { logService.Log("Add Property Terms", ex.InnerException.Message, ex.Message, ex.StackTrace); Assert.Fail(); } }
public async Task <IActionResult> PostAddPropertyTermsAsync([FromBody] PropertyTermsModel obj) { if (!ModelState.IsValid) { return(BadRequest()); } var request = await _propertyService.AddPropertyTermsAsync(obj); _responseModel.Status = request.Status; _responseModel.Message = request.Message; if (_responseModel.Status) { return(Ok(_responseModel)); } else { return(BadRequest(_responseModel)); } }
public async Task PropertyApi_AddPropertyTermsAsync_IntegrationTest() { var propertyId = Guid.Parse("BCEDAB95-5E70-4A0B-83DC-0053D28A7D8F"); var token = await GenerateTokenAsync(); client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}"); var terms = new PropertyTermsModel { MonthDeposit = 1, MonthAdvance = 1, PropertyId = propertyId }; var payload = new StringContent( JsonConvert.SerializeObject(terms), Encoding.UTF8, "application/json" ); try { var request = await client.PostAsync("api/v1/Property/terms/add", payload); var response = await request.Content.ReadAsStringAsync(); var content = JsonConvert.DeserializeObject <ResponseModel>(response); Assert.IsTrue(content.Status, "Error occurred while adding property terms"); } catch (Exception ex) { logService.Log("API Endpoint: Add Property Terms", ex.InnerException.Message, ex.Message, ex.StackTrace); Assert.Fail(ex.Message); } }