Changed link values to IEnumerable<KeyValuePair> as previous implementation was not composable.

This commit is contained in:
Philip Dimitratos 2017-12-18 16:03:30 -08:00
Родитель 234c3ec137
Коммит 5858cc4099
4 изменённых файлов: 15 добавлений и 9 удалений

Просмотреть файл

@ -63,7 +63,7 @@ namespace Sia.Data.Incident.Tests.Filters
var serviceUnderTest = new EventFilters()
{
IncidentId = 1,
EventTypeId = 1,
EventTypes = new long[] { 1 },
Occurred = new DateTime(1970, 1, 1),
EventFired = new DateTime(1970, 1, 1)
};

2
domain

@ -1 +1 @@
Subproject commit 2d04611e9a6bf860030f3c91c50fc40c8eb29bef
Subproject commit 2d236b3c5495ae62a59fd86295c6524f8f2447f1

Просмотреть файл

@ -29,12 +29,18 @@ namespace Sia.Data.Incidents.Filters
return base.Filter(working);
}
public override StringValues NonDataFilterValues() => JsonConvert.SerializeObject(new
public override IEnumerable<KeyValuePair<string, string>> NonDataFilterValues()
{
IncidentId = IncidentId,
EventTypes = EventTypes,
Occurred = Occurred,
EventFired = EventFired
});
if(IncidentId.HasValue) yield return new KeyValuePair<string, string>(nameof(IncidentId), IncidentId.Value.ToString());
if(!(EventTypes is null) && EventTypes.Length != 0)
{
foreach (var eventTypeId in EventTypes)
{
yield return new KeyValuePair<string, string>(nameof(EventTypes), eventTypeId.ToString());
}
}
if (Occurred.HasValue) yield return new KeyValuePair<string, string>(nameof(Occurred), Occurred.Value.ToString());
if (EventFired.HasValue) yield return new KeyValuePair<string, string>(nameof(EventFired), EventFired.Value.ToString());
}
}
}

Просмотреть файл

@ -35,7 +35,7 @@ namespace Sia.Gateway.Controllers
[FromQuery]EventFilters filter)
{
var result = await _mediator.Send(new GetEventsRequest(incidentId, pagination, filter, _authContext));
Response.Headers.AddPagination(new LinksHeader(pagination, _urlHelper, nameof(GetEvents)));
Response.Headers.AddPagination(new FilteredLinksHeader(filter, pagination, _urlHelper, nameof(GetEvents)));
return Ok(result);
}