protected override async Task <RateLimits> GetRecordValue(IAttributeResolver attributeResolver) { IReadOnlyCollection <string> subscriptionValues = await attributeResolver.Resolve <string>(subscriptionLevel); if (subscriptionValues.Count == 0) { return(new RateLimits()); } IReadOnlyCollection <string> currentRequestValues = await attributeResolver.Resolve <string>(currentRequestsFromQuery); long currentRequests = 0; if (currentRequestValues.Count > 0) { if (long.TryParse(currentRequestValues.First(), out long parsedValue)) { currentRequests = parsedValue; } } long maxRequests = rateLimitMap[subscriptionValues.First()]; return(new RateLimits { MaxRequestsPerDay = maxRequests, CurrentRequestsPerDay = currentRequests }); }
protected override async Task <FinanceDepartmentLimits> GetRecordValue(IAttributeResolver attributeResolver) { // Retrieve the department from the evaluation context IReadOnlyCollection <string> departments = await attributeResolver.Resolve <string>(Department); double purchaseOrderLimit = 0; switch (departments.Single()) { case "engineering": purchaseOrderLimit = 500; break; case "finance": purchaseOrderLimit = 2000; break; } return(new FinanceDepartmentLimits() { MaxPurchaseOrder = purchaseOrderLimit }); }