public static T FindOrThrowFromRequest <T, TId>(this IEnumerable <T> col, IHaveId <TId> idBearer) where T : IHaveId <TId> { var item = col.FirstOrDefault(x => idBearer.Id.Equals(x.Id)); if (item == null) { throw new NotFoundException("Item with ID not found: " + idBearer.Id); } return(item); }
private async Task WithErrorHandling(IHaveId processingMessage, IMessageMetadata messageMetadata, JobKey key, Func <Task> act) { try { await act(); } catch (Exception e) { var businessError = e.UnwrapSingle(); _quartzLogger.Error(businessError, "job {key} failed", key.Name); var jobFailed = new JobFailed(key.Name, key.Group, businessError, processingMessage); var jobFailedMetadata = messageMetadata.CreateChild(processingMessage, _jobFailedProcessEntry); _publisher.Publish(jobFailed, jobFailedMetadata); throw new JobExecutionException(businessError, false); } }
public CreatedActionResult(HttpRequestMessage request, IHaveId idBearer) { _request = request; _idBearer = idBearer; }
public static Task <Game> FindGameFromRequestOrThrowAsync(this IGameContextReadOnly gc, IHaveId <Guid> request) => Wrap(async() => { await gc.Load(request.Id).ConfigureAwait(false); return(await gc.Games.FindOrThrowFromRequestAsync(request).ConfigureAwait(false)); }, request.Id);
public static bool SameAs <TKey>(this IHaveId <TKey> source, IHaveId <TKey> target) where TKey : IEquatable <TKey> { return(source.Id.Equals(target.Id)); }
public static async Task<Game> FindGameFromRequestOrThrowAsync(this IGameContextReadOnly gc, IHaveId<Guid> request) { await gc.Load(request.Id).ConfigureAwait(false); return await gc.Games.FindOrThrowFromRequestAsync(request).ConfigureAwait(false); }
public IdBasedEqualityComparer(IHaveId first) { this.First = first; }
public static Task <T> FindOrThrowFromRequestAsync <T, TId>(this IEnumerable <T> col, IHaveId <TId> idBearer) where T : IHaveId <TId> => Task.Run(() => col.FindOrThrowFromRequest(idBearer));
public static T FindFromRequest <T, TId>(this IEnumerable <T> col, IHaveId <TId> idBearer) where T : IHaveId <TId> => col.FirstOrDefault(x => idBearer.Id.Equals(x.Id));
public static MessageMetadata CreateChild(this IMessageMetadata metadata, IHaveId message, params ProcessEntry[] process) { return(metadata.CreateChild(message.Id, process)); }