I have a model with three properties. I want to add validation logic to the TotalSalary where TotalSalary must be equal to the Sum of BasicSalary And AllowanceSalary.
public class Employee
{
[Required]
public decimal BasicSalary{get;set;}
[Required]
public decimal AllowanceSalary{get;set;}
[MyCompareAttribute]
public decimal TotalSalary{get;set;}
}
public class MyCompareAttribute: ValidationAttribute
{
// I have no idea how to do this
}