Message Validation
The first option is declaring validation statement in Entry model class.
For example, we want user not to fill the notes section longer than 200 characters.
[MaxLength(200, ErrorMessage = "Notes cannot be longer than 200")]
public string Notes { get; set; }
The second option is declaring validation statement in Controller class above Add function.
For example, we want user to set the duration with value more than 0.
if(ModelState.IsValidField("Duration") && entry.Duration <= 0 )
{
ModelState.AddModelError("Duration", "The duration field must be greater than 0");
}
Finaly, to call the error validation message, type the code below on the top of Add view page.
@Html.ValidationSummary("The following errors were found: ", new { @class = "alert alert-danger" })