Reputation: 393
I want to do some calculation in the Model class because I am using certain search input to return the whole result as a list. Therefore, it is not possible to change the grid view result.
public class TaxInvoiceEnquiryModel : ModelStatus
{
[DisplayField(Width = 200, TextAlignment = TextAlignment.Left, Text = "Tax Charges")]
[ValidProperty]
public double TaxCharges { get; set; }
[DisplayField(Width = 200, TextAlignment = TextAlignment.Left, Text = "Sales Charges")]
[ValidProperty]
public double SalesCharges { get; set; }
[DisplayField(Width = 200, TextAlignment = TextAlignment.Left, Text = "Total Charges")]
[ValidProperty]
public double TotalCharges { get; set; }
}
From the list, I only can retrieve the TaxCharges and TotalCharges. As told, I need to calculate the SalesCharges by TotalCharges deduct TaxCharges and display it UI.
Upvotes: 0
Views: 50
Reputation: 1654
I think this is what you need:
public class TaxInvoiceEnquiryModel : ModelStatus
{
[DisplayField(Width = 200, TextAlignment = TextAlignment.Left, Text = "Tax Charges")]
[ValidProperty]
public double TaxCharges { get; set; }
[DisplayField(Width = 200, TextAlignment = TextAlignment.Left, Text = "Sales Charges")]
[ValidProperty]
public double SalesCharges
{
get
{
return TotalCharges - TaxCharges;
}
}
[DisplayField(Width = 200, TextAlignment = TextAlignment.Left, Text = "Total Charges")]
[ValidProperty]
public double TotalCharges { get; set; }
}
Upvotes: 1