Example #1
0
        public async Task <IReadOnlyCollection <ValidationException> > Validate(CancelOrderCommand cmd, CancellationToken cancellationToken)
        {
            var activeEvent = await _coffeeRoastingEventRepository.GetActiveEvent(cancellationToken);

            if (_currentTimeProvider.Today > activeEvent.OrderByDate)
            {
                IReadOnlyCollection <ValidationException> errors = new List <ValidationException>
                {
                    new("It's too late to place an order for this event.")
                };
                return(errors);
            }

            IReadOnlyCollection <ValidationException> emptyErrors = Array.Empty <ValidationException>();

            return(emptyErrors);
        }
    }