private void ConfigureRedistributeMessages(int associationExpenseId) { string redistributeValue = RedistributionManager.CalculateRedistributeValueAsString(associationExpenseId); invoiceRedistributeMessage.Text = "<br>Cheltuială de redistribuit:" + redistributeValue + "<br>"; decimal redistributeVal; if (decimal.TryParse(redistributeValue, out redistributeVal)) { IEnumerable <Apartments> apartmentsForRedistribute = AssociationExpensesManager.GetApartmentsNrThatShouldRedistributeTo(associationExpenseId); txtInvoiceRedistributeEqualApartment.Text = apartmentsForRedistribute.Count() + " apartamente, alocă <b>" + Math.Round(redistributeVal / apartmentsForRedistribute.Count(), 2) + "</b> la fiecare apartament"; var allApartmentDependents = apartmentsForRedistribute.Sum(t => t.Dependents); var valuePerApartment = "0"; if (allApartmentDependents != 0) { valuePerApartment = Math.Round(redistributeVal / allApartmentDependents, 2).ToString(); } txtInvoiceRedistributeEqualTenants.Text = allApartmentDependents + " persoane în bloc, alocă <b>" + valuePerApartment + "</b> per fiecare locatar"; invoiceRedistributeEqualApartment.CommandArgument = associationExpenseId.ToString(); invoiceRedistributeEqualTenants.CommandArgument = associationExpenseId.ToString(); invoiceRedistributeConsumption.CommandArgument = associationExpenseId.ToString(); } }