示例#1
0
        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);
        }
示例#2
0
 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);
     }
 }
示例#3
0
 public CreatedActionResult(HttpRequestMessage request, IHaveId idBearer)
 {
     _request = request;
     _idBearer = idBearer;
 }
示例#4
0
 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);
示例#5
0
 public static bool SameAs <TKey>(this IHaveId <TKey> source, IHaveId <TKey> target)
     where TKey : IEquatable <TKey>
 {
     return(source.Id.Equals(target.Id));
 }
示例#6
0
 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;
 }
示例#8
0
 public static Task <T> FindOrThrowFromRequestAsync <T, TId>(this IEnumerable <T> col, IHaveId <TId> idBearer)
     where T : IHaveId <TId> => Task.Run(() => col.FindOrThrowFromRequest(idBearer));
示例#9
0
 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));
示例#10
0
 public static MessageMetadata CreateChild(this IMessageMetadata metadata,
                                           IHaveId message,
                                           params ProcessEntry[] process)
 {
     return(metadata.CreateChild(message.Id, process));
 }