Skip to content

Add helper method for getting query params #135

Closed
@jaredcnance

Description

@jaredcnance

Something to ease up the following. Perhaps introduce an IQueryAccessor service?

private Guid? GetGuidFilter(string key)
{
    var value = GetFilterValue(key);

    if (value == null)
        return null;

    if (Guid.TryParse(value, out Guid result) == false)
        throw new JsonApiException(422, $"'{value}' is not a valid guid value for query parameter {key}");

    return result;
}

private string GetFilterValue(string key) => _jsonApiContext.QuerySet
        .Filters
        .FirstOrDefault(f => f.Key == key)
        ?.Value;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions