I would like to write a custom attribute that I can decorate a ViewModel property with such that, when the ViewModel is posted I can check to see which of the posted properties has this attribute and run some logic. I am trying to set conditions, and this should not affect validation in any way.
[SetsCondition(SomeEnumerationValue)]
public Fund SelectedFund {get;set;}
...
other properties
then in the controller.
[HttpPost]
public IActionResult SelectFund(SelectFundViewModel model){
if(ModelState.IsValid){
//check which properties have the SetsCondition Attribute
//read the SomeEnumerationValue for them
..
//profit
}
}
just not quite sure what sort of attribute I should be inheriting from, or for that matter, how to check if a particular ViewModel property is decorated with one.
any help much appreciated