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 => { })); }
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(); }
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))); }
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));; }
public static async Task NotifyAsync <TEntity>(this IMediator mediator, TEntity @event) where TEntity : class { await mediator.NotifyAsync(DefaultEvent.Create(@event)).ConfigureAwait(false); }
public override async Task <IEvent <QueueItem> > Push(IEvent <QueueItem> @event) { var queueItems = await queueItemService.SaveQueueItem(@event.Result); return(DefaultEvent.Create(queueItems)); }