Additional Model Annotations
In order to better control the Model container behaviour within the Magentrix MVC framework, you can use the below ancillations below to customize property labels, mark them as required, and much more.
Required
This attribute allows you to make a Model property as a required field. The user has to enter a value for such field when filling out input forms.
[Required]
public string LastName { get; set; }
Display Label
This attribute allows you to control the label of the property within the ViewSections.
[Display(Name="Active User")]
public string IsActive { get; set; }
Field Level Security
This attribute allows you to control the field/ property level security for your custom models.
// field should be hidden to the users other than administrators
[FieldAccess(Roles = new string[] { "Administrator" }, Unauthorized = FieldAccessibility.Hidden)]
public string IsManagerUser { get; set; }
// field should be read only to users other than administrators and technicians
[FieldAccess(Roles = new string[] {"Technician","Administrator"}, Unauthorized = FieldAccessibility.ReadOnly)]
public string InternalNotes { get; set; }
File Size Formating
If you have a numeric field that is supposed to show data sizes, this attribute makes displaying the values of such a field extremely easy.
// displays 20332 as 20.3KB
[FileSizeFormat]
public decimal ContentSize { get; set; }