Пример #1
0
 protected override ValidationResult IsValid(object value, ValidationContext validationContext)
 {
     if (value != null)
     {
         ReservationData rsd = (ReservationData)validationContext.ObjectInstance;
         if (rsd.Date == null)
         {
             // if date is empty, we do not check whether it is working day
             return(ValidationResult.Success);
         }
         bool workday = (WorkCalendar.IsCalWorkDay(DateTime.ParseExact(rsd.Date + " 00:00:00", "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)) == 1);
         if (workday)
         {
             return(ValidationResult.Success);
         }
         else
         {
             var errorMessage = FormatErrorMessage(validationContext.DisplayName);
             return(new ValidationResult(errorMessage));
         }
     }
     else
     {
         return(ValidationResult.Success);
     }
 }
Пример #2
0
 public ReservationModel(IHtmlLocalizerFactory htmlLocalizerFactory, IEmailService emailService, IHostingEnvironment env)
 {
     _loc                  = htmlLocalizerFactory.Create(Includes.AppShortName + ".Pages.Reservation", Includes.AppShortName);
     _emailService         = emailService;
     _hostingEnviroment    = env;
     _htmlLocalizerFactory = htmlLocalizerFactory;
     ResData               = new ReservationData();
 }