private void AddDoorsCost(BlueprintCostReport report, IBlueprint aBlueprint) { int doorsCount = aBlueprint.GetOpenings().Count(o => o.GetComponentType().Equals(ComponentType.DOOR)); float doorsPrice = costsNPrices.GetCost((int)ComponentType.DOOR); report.SetTotalCost(ComponentType.DOOR, doorsCount * doorsPrice); }
private void AddWindowsCost(BlueprintCostReport report, IBlueprint aBlueprint) { int windowsCount = aBlueprint.GetOpenings().Count(o => o.GetComponentType().Equals(ComponentType.WINDOW)); float windowsPrice = costsNPrices.GetCost((int)ComponentType.WINDOW); report.SetTotalCost(ComponentType.WINDOW, windowsCount * windowsPrice); }
private void AddColumnsCost(BlueprintCostReport report, IBlueprint aBlueprint) { int columnsCount = aBlueprint.GetColumns().Count; float columnPrice = costsNPrices.GetCost((int)ComponentType.COLUMN); report.SetTotalCost(ComponentType.COLUMN, columnsCount * columnPrice); }
private void AddBeamsCost(BlueprintCostReport report, IBlueprint aBlueprint) { int beamsCount = aBlueprint.GetBeams().Count; float beamPrice = costsNPrices.GetCost((int)ComponentType.BEAM); report.SetTotalCost(ComponentType.BEAM, beamsCount * beamPrice); }
public void GetCostDoorsTest() { BlueprintCostReport report = reporter.GenerateCostReport(toReport); float expectedResult = 0; float actualResult = report.GetTotalCost(ComponentType.DOOR); Assert.AreEqual(expectedResult, actualResult); }
public void GetCostWindowsTest() { BlueprintCostReport report = reporter.GenerateCostReport(toReport); float expectedResult = 100; float actualResult = report.GetTotalCost(ComponentType.WINDOW); Assert.AreEqual(expectedResult, actualResult); }
public BlueprintCostReport GenerateCostReport(IBlueprint aBlueprint) { BlueprintCostReport report = new BlueprintCostReport(); AddWallsCost(report, aBlueprint); AddBeamsCost(report, aBlueprint); AddColumnsCost(report, aBlueprint); AddWindowsCost(report, aBlueprint); AddDoorsCost(report, aBlueprint); return(report); }
private void AddWallsCost(BlueprintCostReport report, IBlueprint aBlueprint) { float wallMetersCount = 0; foreach (Wall existent in aBlueprint.GetWalls()) { wallMetersCount += existent.Length(); } float wallPrice = costsNPrices.GetCost((int)ComponentType.WALL); report.SetTotalCost(ComponentType.WALL, wallMetersCount * wallPrice); }
//Auxiliar private void calulateCostsAndPrices() { IPriceCostRepository pricesNcosts = new PriceCostRepository(); BlueprintReportGenerator reportGenerator = new BlueprintReportGenerator(pricesNcosts); BlueprintCostReport costReport = reportGenerator.GenerateCostReport(selectedBluePrint); BlueprintPriceReport priceReport = reportGenerator.GeneratePriceReport(selectedBluePrint); if (CurrentSession.UserLogged.HasPermission(Permission.VIEW_COSTS)) { lblWallsTotalCost.Text = costReport.GetTotalCost(ComponentType.WALL) + ""; lblBeamsTotalCost.Text = costReport.GetTotalCost(ComponentType.BEAM) + ""; lblDoorsTotalCost.Text = costReport.GetTotalCost(ComponentType.DOOR) + ""; lblWindowsTotalCost.Text = costReport.GetTotalCost(ComponentType.WINDOW) + ""; lblColumnsTotalCost.Text = costReport.GetTotalCost(ComponentType.COLUMN) + ""; lblTotalCostSum.Text = (costReport.GetTotalCost(ComponentType.WALL) + costReport.GetTotalCost(ComponentType.BEAM) + costReport.GetTotalCost(ComponentType.DOOR) + costReport.GetTotalCost(ComponentType.WINDOW)) + costReport.GetTotalCost(ComponentType.COLUMN) + ""; } lblWallsPrice.Text = priceReport.GetTotalPrice(ComponentType.WALL) + ""; lblBeamsPrice.Text = priceReport.GetTotalPrice(ComponentType.BEAM) + ""; lblDoorsPrice.Text = priceReport.GetTotalPrice(ComponentType.DOOR) + ""; lblWindowsPrice.Text = priceReport.GetTotalPrice(ComponentType.WINDOW) + ""; lblColumnsTotalPrice.Text = priceReport.GetTotalPrice(ComponentType.COLUMN) + ""; lblTotalPriceSum.Text = (priceReport.GetTotalPrice(ComponentType.WALL) + priceReport.GetTotalPrice(ComponentType.BEAM) + priceReport.GetTotalPrice(ComponentType.DOOR) + priceReport.GetTotalPrice(ComponentType.WINDOW)) + priceReport.GetTotalPrice(ComponentType.COLUMN) + ""; }