我有一个项目。我需要自定义验证才能找到最低价格。现在首先我的所有模型都在这里;
public class ReservationModel
{
[Required]
public DateTime BeginDate { get; set; }
[Required]
public DateTime EndDate { get; set; }
[Required]
public double Price { get; set; }
[Required]
public string EmailAddress { get; set; }
public Guid ApartId { get; set; }
[Required]
public int Guest { get; set; }
public string ApartName { get; set; }
public string City { get; set; }
public string Country { get; set; }
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
public string ApartDesc { get; set; }
[Required]
public string FirstName { get; set; }
[Required]
public string LastName { get; set; }
public string CategoryName { get; set; }
public double MinAmount { get; set; }
public string ApartImage { get; set; }
public string CheckInTime { get; set; }
public string CheckOutTime { get; set; }
public int DayOfReservation { get; set; }
public int ReservationGuestNumber { get; set; }
}
我想在MinAmount中使用此验证。我有动态价格。例如,单价300美元。我想MinAmount值必须是300 X 25/100 = 75 USD。验证错误消息是如果客户写入50美元或低于75美元。那么如何创建我的自定义MinPriceAttribute ???谢谢你的回复。