/// <summary> /// Gets the exceptions. /// </summary> /// <param name="filter">Exception filter object</param> /// <returns></returns> /// <exception cref="ArgumentNullException">filter - Filter must be supplied /// or /// Direction - Direction cannot be null</exception> /// <exception cref="Eu.EDelivery.AS4.Fe.BusinessException">Could not get any exceptions, something went wrong.</exception> public async Task <MessageResult <ExceptionMessage> > GetExceptions(ExceptionFilter filter) { if (filter == null) { throw new ArgumentNullException(nameof(filter), @"Filter must be supplied"); } if (filter.Direction == null) { throw new ArgumentNullException(nameof(filter.Direction), @"Direction cannot be null"); } var inExceptions = filter.Direction.Contains(Direction.Inbound) ? filter.ApplyFilter(context.InExceptions).ProjectTo <ExceptionMessage>(mapperConfig) : null; var outExceptions = filter.Direction.Contains(Direction.Outbound) ? filter.ApplyFilter(context.OutExceptions).ProjectTo <ExceptionMessage>(mapperConfig) : null; IQueryable <ExceptionMessage> result = null; if (inExceptions != null && outExceptions != null) { result = inExceptions.Concat(outExceptions); } else if (inExceptions != null) { result = inExceptions; } else if (outExceptions != null) { result = outExceptions; } if (result == null) { throw new BusinessException("Could not get any exceptions, something went wrong."); } return(await filter.ToResult(result.OrderByDescending(msg => msg.InsertionTime))); }