rus tan

rus tan

  • NA
  • 52
  • 11.1k

start date end date validation

Oct 24 2019 4:22 AM
start date and end date model validation
 
public class CreateLeaveModel
{
public int LeavesTaken { get; set; }
public string Reason { get; set; }
public int Days { get; set; }
[Compare DateTime("StartDate < EndDate",ErrorMessage ="Start Date must be earlier than End Date")]
public DateTime StartDate { get; set; }
[Compare DateTime("StartDate < EndDate", ErrorMessage = "End Date must be later than Start Date")]
public DateTime EndDate { get; set; }
public int Status { get; set; } = 0;
}
what is the correct way? 

Answers (3)