Beispiel #1
0
        private bool Handle(ExpireReservationCommand command)
        {
            var provider = DependencyInjectorStub.Get((s, c) =>
            {
                BootStrapper.RegisterServices(s, c);
                s.AddScoped(x => MockRepository.GetContext());
                s.AddScoped <IBusPublisher>(x => Bus);
            });

            var handler = provider.GetRequiredService <IRequestHandler <ExpireReservationCommand, bool> >();

            return(handler.Handle(command, CancellationToken.None).GetAwaiter().GetResult());
        }
Beispiel #2
0
        public async Task <bool> Handle(CheckDueCommand request, CancellationToken cancellationToken)
        {
            var date = _dateTimeService.Now().Date.AddDays(1).AddSeconds(-1);

            var expiredList = await _db.Reservations
                              .Where(x => x.Loans.Any(l => l.DueDate.Date <= date))
                              .ToListAsync(cancellationToken);

            foreach (var item in expiredList)
            {
                var message = new ExpireReservationCommand
                {
                    ReservationId = item.Id
                };

                await _bus.SendAsync(ContextNames.Queue.Library, message);
            }

            return(true);
        }