Skip to content

Commit

Permalink
Merge pull request #29 from nblumhardt/events-delete
Browse files Browse the repository at this point in the history
Fixes Events.DeleteInSignalAsync()
  • Loading branch information
nblumhardt authored Jan 29, 2017
2 parents 0fc128e + 46f63ea commit f54a9e5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Seq.Api/Api/Client/SeqApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ public async Task DeleteAsync<TEntity>(ILinked entity, string link, TEntity cont
new StreamReader(stream).ReadToEnd();
}

public async Task<TResponse> DeleteAsync<TEntity, TResponse>(ILinked entity, string link, TEntity content, IDictionary<string, object> parameters = null)
{
var linkUri = ResolveLink(entity, link, parameters);
var request = new HttpRequestMessage(HttpMethod.Delete, linkUri) { Content = MakeJsonContent(content) };
var stream = await HttpSendAsync(request).ConfigureAwait(false);
return _serializer.Deserialize<TResponse>(new JsonTextReader(new StreamReader(stream)));
}

public async Task<ObservableStream<TEntity>> StreamAsync<TEntity>(ILinked entity, string link, IDictionary<string, object> parameters = null)
{
return await WebSocketStreamAsync(entity, link, parameters, reader => _serializer.Deserialize<TEntity>(new JsonTextReader(reader)));
Expand Down
6 changes: 6 additions & 0 deletions src/Seq.Api/Api/ResourceGroups/ApiResourceGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,11 @@ protected async Task GroupDeleteAsync<TEntity>(string link, TEntity content, IDi
var group = await LoadGroupAsync().ConfigureAwait(false);
await Client.DeleteAsync(group, link, content, parameters).ConfigureAwait(false);
}

protected async Task<TResponse> GroupDeleteAsync<TEntity, TResponse>(string link, TEntity content, IDictionary<string, object> parameters = null)
{
var group = await LoadGroupAsync().ConfigureAwait(false);
return await Client.DeleteAsync<TEntity, TResponse>(group, link, content, parameters).ConfigureAwait(false);
}
}
}
2 changes: 1 addition & 1 deletion src/Seq.Api/Api/ResourceGroups/EventsResourceGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public async Task<ResultSetPart> DeleteInSignalAsync(
if (toDateUtc != null) { parameters.Add("toDateUtc", toDateUtc.Value); }

var body = signal ?? new SignalEntity();
return await GroupPostAsync<SignalEntity, ResultSetPart>("DeleteInSignal", body, parameters).ConfigureAwait(false);
return await GroupDeleteAsync<SignalEntity, ResultSetPart>("DeleteInSignal", body, parameters).ConfigureAwait(false);
}

/// <summary>
Expand Down

0 comments on commit f54a9e5

Please sign in to comment.