Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Commit

Permalink
Adds support for error notification in NotificationService
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos Cordeiro committed Jun 26, 2023
1 parent 208bceb commit 3578da3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Wasari.App/NotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ public NotificationService(HttpClient httpClient)
}

private HttpClient HttpClient { get; }

public async ValueTask SendNotifcationForDownloadedEpisodeAsync(IEnumerable<DownloadedEpisode> downloadedEpisode)
{
var message = downloadedEpisode
.GroupBy(i => i.Episode.SeriesName)
.GroupBy(i => new { i.Episode.SeriesName, i.Success })
.Select(i =>
{
var sb = new StringBuilder();
sb.AppendLine($"Episodes has been downloaded for series: {i.Key}");

if (i.Key.Success)
sb.AppendLine($"Episodes has been downloaded for series: {i.Key.SeriesName}");
else
sb.AppendLine($"Failed to download episodes for series: {i.Key.SeriesName}");

foreach (var episode in i)
{
Expand All @@ -33,7 +37,7 @@ public async ValueTask SendNotifcationForDownloadedEpisodeAsync(IEnumerable<Down
await SendNotificationAsync(message);
}

public async ValueTask SendNotificationAsync(string message)
private async ValueTask SendNotificationAsync(string message)
{
await HttpClient.PostAsJsonAsync(string.Empty, new
{
Expand Down

0 comments on commit 3578da3

Please sign in to comment.