public async Task <IReadOnlyCollection <ValidationException> > Validate( SendTextBlastCommand cmd, CancellationToken cancellationToken) { var roastingEvent = await _coffeeRoastingEventRepository.Get(cmd.Event, cancellationToken); var errors = new List <ValidationException>(); if (!roastingEvent.IsActive) { errors.Add(new ValidationException("You can't send a text blast for a roasting event that's not active.")); } if (roastingEvent.RoastDate < _currentTimeProvider.Today) { errors.Add(new ValidationException("You can't send a text blast for a roasting event that already happened.")); } return(errors); }
public async Task <IReadOnlyCollection <ValidationException> > Validate(SendFollowUpTextBlastCommand cmd, CancellationToken cancellationToken) { var @event = await _coffeeRoastingEventRepository.Get(cmd.Event, cancellationToken); var errors = new List <ValidationException>(); if ([email protected]) { errors.Add(new ValidationException("This event is not active. You can't send a text blast reminder out for it.")); } if (_currentTimeProvider.Today > @event.OrderByDate) { errors.Add(new ValidationException("The order-by date on this event has already passed. You can't send a text blast reminder out for it.")); } IReadOnlyCollection <ValidationException> validationErrors = errors.AsReadOnly(); return(validationErrors); }