Ejemplo n.º 1
0
        public async Task <ActionResult <LineItemContainer> > GetLineItemsAsync([Required] string contextId,
                                                                                [FromQuery(Name = "resourceLinkId")] string resourceLinkId = null,
                                                                                [FromQuery(Name = "resourceId")] string resourceId         = null,
                                                                                [FromQuery] string tag = null,
                                                                                [FromQuery] int?limit  = null)
        {
            try
            {
                _logger.LogDebug($"Entering {nameof(GetLineItemsAsync)}.");

                try
                {
                    var request = new GetLineItemsRequest(contextId, resourceLinkId, resourceId, tag, limit);
                    return(await OnGetLineItemsAsync(request).ConfigureAwait(false));
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, $"An unexpected error occurred in {nameof(OnGetLineItemsAsync)}.");
                    return(StatusCode(StatusCodes.Status500InternalServerError, new ProblemDetails
                    {
                        Title = "An unexpected error occurred",
                        Status = StatusCodes.Status500InternalServerError,
                        Detail = _env.IsDevelopment()
                                 ? ex.Message + ex.StackTrace
                                 : ex.Message
                    }));
                }
            }
            finally
            {
                _logger.LogDebug($"Exiting {nameof(GetLineItemsAsync)}.");
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Get the line items for a context.
 /// </summary>
 /// <param name="request">The request parameters.</param>
 /// <returns>The line items.</returns>
 protected abstract Task <ActionResult <LineItemContainer> > OnGetLineItemsAsync(GetLineItemsRequest request);