public decimal Calculate(ProjectCalculatorInputModel model) { decimal result = 0m; switch (model.Property) { case TypeOfProperty.Apartment: result = this.CalculatePropertyArea(model) * (model.NumberOfBathrooms + model.NumberOfBedrooms); break; case TypeOfProperty.Studio: result = this.CalculatePropertyArea(model); break; case TypeOfProperty.House: result = this.CalculatePropertyArea(model) * (model.NumberOfBathrooms + model.NumberOfBedrooms) * House; break; case TypeOfProperty.Office: result = this.CalculatePropertyArea(model) * (model.NumberOfBathrooms + model.NumberOfBedrooms) * Office; break; case TypeOfProperty.RetailProperty: result = this.CalculatePropertyArea(model) * RetailProperty; break; default: break; } return(Math.Round(result, 2)); }
public ActionResult ProjectCalculatorCalculate(ProjectCalculatorInputModel model) { if (this.ModelState.IsValid) { model.Result = this.service.Calculate(model); } return(this.RedirectToAction("ProjectCalculator", model)); }
public async Task Calculate_ShouldReturnCorrectResultsForRetail() { this.projectCalculatorService = new ProjectCalculatorService(); var projectCalculatorInput = new ProjectCalculatorInputModel { HousingArea = 200m, NumberOfBathrooms = 2, NumberOfBedrooms = 2, Project = TypeOfProject.Consultation, Property = TypeOfProperty.RetailProperty, }; var estimate = this.projectCalculatorService.Calculate(projectCalculatorInput); Assert.Equal(1890m, estimate); }
public async Task Calculate_ShouldReturnCorrectResultsForHouse() { this.projectCalculatorService = new ProjectCalculatorService(); var projectCalculatorInput = new ProjectCalculatorInputModel { HousingArea = 200m, NumberOfBathrooms = 2, NumberOfBedrooms = 2, Project = TypeOfProject.Full, Property = TypeOfProperty.House, }; var estimate = this.projectCalculatorService.Calculate(projectCalculatorInput); Assert.Equal(7339.2m, estimate); }
public async Task Calculate_ShouldReturnCorrectResultsForStudio() { this.projectCalculatorService = new ProjectCalculatorService(); var projectCalculatorInput = new ProjectCalculatorInputModel { HousingArea = 50m, NumberOfBathrooms = 1, NumberOfBedrooms = 1, Project = TypeOfProject.Basic, Property = TypeOfProperty.Studio, }; var estimate = this.projectCalculatorService.Calculate(projectCalculatorInput); Assert.Equal(244m, estimate); }
internal decimal CalculatePropertyArea(ProjectCalculatorInputModel model) { decimal result = 0m; switch (model.Project) { case TypeOfProject.Basic: result = model.HousingArea * BaseProjectRate; break; case TypeOfProject.Full: result = model.HousingArea * FullProjectRate; break; case TypeOfProject.Consultation: result = model.HousingArea * ConsultationRate; break; default: break; } return(result); }
public ActionResult ProjectCalculator(ProjectCalculatorInputModel model) { return(this.View(model)); }