public async Task <TResult> ExecuteAsync(TArgs args) { var name = ArgumentsNameResolver.GetName <TArgs>(); _logger.LogInformation($"Executing {name} query..."); var result = await _handler.ExecuteAsync(args).ConfigureAwait(false); _logger.LogInformation($"Executed {name} query."); return(result); }
public async Task <TResult> ExecuteAsync(TQuery query, CancellationToken ctk = default(CancellationToken)) { try { return(await _decorated.ExecuteAsync(query, ctk)); } catch (Exception ex) { Logger logger = LogManager.GetLogger(_decorated.GetType().ToString()); logger.Error(ex, "Exception occured"); throw; } }
public async Task <TResult> ExecuteAsync(TQuery query, CancellationToken ctk = default(CancellationToken)) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); var result = await _decorated.ExecuteAsync(query, ctk); stopWatch.Stop(); _logger.Trace(() => string.Format("Query<{0}> executed in {1}ms", query.GetType(), stopWatch.ElapsedMilliseconds)); return(result); }
public async Task <IActionResult> GetMenu([FromRoute][Required] Guid id) { // NOTE: Please ensure the API returns the response codes annotated above var result = await queryHandler.ExecuteAsync(new Query.GetMenuById() { Id = id }); if (result == null) { return(NotFound()); } return(new ObjectResult(result)); }
public async Task <IActionResult> Get(Guid id) { try { var query = new FindProductByIdQuery(id); var info = await findProductByIdQuery.ExecuteAsync(query); if (info == null) { return(new NotFoundResult()); } return(new OkObjectResult(info)); } catch (Exception ex) { return(new BadRequestObjectResult(ex)); } }
public async Task <IActionResult> SearchMenu( [FromQuery] string searchTerm, [FromQuery] Guid?RestaurantId, [FromQuery][Range(0, 50)] int?pageSize = 20, [FromQuery] int?pageNumber = 1) { // NOTE: Please ensure the API returns the response codes annotated above var criteria = new SearchMenu( correlationId: GetCorrelationId(), searchText: searchTerm, restaurantId: RestaurantId, pageSize: pageSize, pageNumber: pageNumber ); var results = await queryHandler.ExecuteAsync(criteria); return(new ObjectResult(results)); //TOOD: we need a mapping here }
public async Task <TResult> ExecuteAsync(TQuery query, CancellationToken ctk = default(CancellationToken)) { if (_policies.Any()) { foreach (var p in _policies) { var policy = await Ex.GetPolicyAsync(p, _authSvc.PolicyProvider); var resource = await Ex.GetResourceAsync(_container, query, policy); if (policy != null) { (var authorized, var messages) = await _authSvc.AuthorizeAsync(_currentUser.Current, resource, policy); if (!authorized) { throw new UnauthorizedAccessException($"Security policy {policy.Name} not satisfied, messages: {string.Join(Environment.NewLine, messages)}"); } } } } return(await _inner.ExecuteAsync(query, ctk)); }
public async Task <TResponse> ExecuteAsync(TQuery query, CancellationToken ctk = default(CancellationToken)) { await _validator.ValidateAndThrowAsync(query); return(await _decorated.ExecuteAsync(query, ctk)); }
public async Task <TResult> ExecuteAsync(TArgs args) { return(await _retryPolicy .ExecuteAsync(async() => await _handler.ExecuteAsync(args).ConfigureAwait(false)) .ConfigureAwait(false)); }