Beispiel #1
0
        public override async Task <IEvent <Domains.Queue> > Push(IEvent <Domains.Queue> @event)
        {
            return(await ExceptionHandler.TryAsync(async() =>
            {
                if ([email protected])
                {
                    throw new EventException(@event, "Save unsuccessful", @event.Exception);
                }

                var queue = await queueService.SaveQueue(@event.Result);

                return DefaultEvent.Create(queue);
            }, ex => { }));
        }
Beispiel #2
0
        private async Task <IEvent <Domains.Queue> > GetQueue(ICommand command)
        {
            if (!command.Parameters.TryGetValue(Constants.QueueUniqueId, out var queueIdentifier))
            {
                throw new MethodAccessException();
            }

            if (queueIdentifier is Guid queueIdentifierGuid)
            {
                return(DefaultEvent.Create(await queueService.GetQueue(queueIdentifierGuid)));
            }

            if (queueIdentifier is int queueIdentifierInt)
            {
                return(DefaultEvent.Create(await queueService.GetQueue(queueIdentifierInt)));
            }

            throw new NotSupportedException();
        }
Beispiel #3
0
        private async Task <IEvent <QueueItem> > SendQueueItems(ICommand command)
        {
            if (!command.Parameters.TryGetValue(Constants.QueueId, out var queueIdValue))
            {
                throw new ArgumentNullException(nameof(queueIdValue));
            }

            if (!queueIdValue.TryParse <int>(out var queueId))
            {
                throw new ArgumentException(nameof(queueIdValue));
            }

            QueueItemStatusType?queueItemStatusType = null;

            if (command.Parameters.TryGetValue(Constants.QueueItemStatusType, out var queueItemStatus) &&
                !queueItemStatus.TryParse(out queueItemStatusType))
            {
                throw new ArgumentException(nameof(queueItemStatusType));
            }

            return(DefaultEvent.Create(results: await queueItemService.GetQueueItems(queueId.Value, queueItemStatusType)));
        }
Beispiel #4
0
 public static async Task <IEvent <TEntity> > Push <TEntity>(this IMediator mediator, TEntity entity)
     where TEntity : class
 {
     return(await mediator
            .Push(DefaultEvent.Create(entity)).ConfigureAwait(false));;
 }
Beispiel #5
0
 public static async Task NotifyAsync <TEntity>(this IMediator mediator, TEntity @event)
     where TEntity : class
 {
     await mediator.NotifyAsync(DefaultEvent.Create(@event)).ConfigureAwait(false);
 }
Beispiel #6
0
        public override async Task <IEvent <QueueItem> > Push(IEvent <QueueItem> @event)
        {
            var queueItems = await queueItemService.SaveQueueItem(@event.Result);

            return(DefaultEvent.Create(queueItems));
        }