コード例 #1
0
 public static IRuleBuilderOptions <TRequest, Guid> EntityExists <TRequest, TEntity>(
     this IRuleBuilderInitialCollection <TRequest, Guid> ruleBuilder,
     IArpaContext arpaContext,
     string propertyName) where TEntity : BaseEntity
 {
     return(ruleBuilder
            .MustAsync(async(id, cancellation) => (await arpaContext.EntityExistsAsync <TEntity>(id, cancellation)))
            .OnFailure((_) => throw new NotFoundException(typeof(TEntity).Name, propertyName)));
 }
コード例 #2
0
 public static IRuleBuilderOptions <TRequest, byte> InstrumentPart <TRequest>(
     this IRuleBuilderInitialCollection <TRequest, byte> ruleBuilderInitial,
     IArpaContext arpaContext) where TRequest : IHasInstrumentRequest
 {
     return(ruleBuilderInitial
            .MustAsync(async(request, preferredPart, cancellation) => (await arpaContext
                                                                       .FindAsync <Section>(new object[] { request.InstrumentId }, cancellation))
                       .InstrumentPartCount >= preferredPart)
            .WithMessage("The selected part is not valid for this instrument"));
 }