示例#1
0
        public async Task <CronId> Handle(UpdateCronHandlerRequest request, CancellationToken cancellationToken)
        {
            CronAggregate cron = await _cronRepository.FindByIdAsync(new CronId(request.CronId)) ??
                                 throw new InvalidOperationException($"Could not update cron with Id {request.CronId}");

            cron.FinishCron(new CronStatus(request.NewStatus), _timeService.Now());
            return(await _cronRepository.SetAsync(cron));
        }
示例#2
0
        public async Task <Guid> Handle(CronRegisteredRequest request, CancellationToken cancellationToken)
        {
            var cronId = await _cronRepository.NextIdAsync();

            var cron = CronAggregate.CreateNew(cronId, request.CronName, _timeService.Now(),
                                               new CronStatus(CronStatusEnum.Executing), null);
            await _cronRepository.SetAsync(cron);

            return(cronId.Value);
        }