Hi, my application has the following structure:
public class Transaction
{
public int TransactionID { get; set; }
public TransactionTypes Type { get; set; } // Enum for the type of transaction
public decimal Amount { get; set; }
public virtual decimal GrandTotal { get; set; } // In this case this would simply be the Amount
}
public class MembershipTransaction : Transaction
{
public decimal ExtraAmount { get; set; }
public override decimal GrandTotal { get { return base.GrandTotal + ExtraAmount; } }
}
I was wondering whether the GrandTotal against the transaction should include the ExtraAmount automatically. The benefits of this is that if i get all the transactions the GrandTotal figure will be correct regardless of the type of transaction. With the above logic i currently have to switch over each transaction type and return the GrandTotal for the derived type.
I'd appreciate it if someone could clear this up for me. Thanks