Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ private static async Task<IResult> Handle(
// Wrap the code below in a transaction such that the generation count
// is only incremented when the document is rendered successfully.

bool isSuccessful;

await using (var transaction = await repository.UnitOfWork.WrapTransactionAsync())
{
document.IncreaseGenerationCount();
Expand All @@ -90,13 +88,11 @@ private static async Task<IResult> Handle(
document.Tournament.ShiftToTimezone(timeZoneInfo);
document.Tournament.Compute();

isSuccessful = renderer.Render(document.Tournament, configuration, localization, stream);
renderer.Render(document.Tournament, configuration, localization, stream);

transaction.ShouldCommit = isSuccessful;
transaction.ShouldCommit = true;
}

return isSuccessful
? Results.File(stream.ToArray(), "application/pdf")
: Results.InternalServerError();
return Results.File(stream.ToArray(), "application/pdf");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ protected void AssertRender(Tournament tournament, IDocumentConfiguration config
__serviceProvider.GetRequiredService<ILocalizationProvider>().TryGetLocalization(languageCode, out var localization).Should().BeTrue();

using var stream = new MemoryStream();
var isSuccessful = GetRenderer().Render(tournament, configuration, new LocalizationWrapper(localization!), stream);

isSuccessful.Should().BeTrue();
GetRenderer().Render(tournament, configuration, new LocalizationWrapper(localization!), stream);

var pdfData = stream.ToArray();

Expand Down
6 changes: 2 additions & 4 deletions src/Turnierplan.PdfRendering/Renderer/DocumentRendererBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private protected DocumentRendererBase()

protected Activity? CurrentActivity { get; private set; }

public bool Render(Tournament tournament, IDocumentConfiguration configuration, ILocalization localization, Stream destination)
public void Render(Tournament tournament, IDocumentConfiguration configuration, ILocalization localization, Stream destination)
{
lock (this)
{
Expand Down Expand Up @@ -53,7 +53,7 @@ public bool Render(Tournament tournament, IDocumentConfiguration configuration,
CurrentActivity?.AddException(ex);
CurrentActivity?.Stop();

return false;
throw;
}
finally
{
Expand All @@ -66,8 +66,6 @@ public bool Render(Tournament tournament, IDocumentConfiguration configuration,
// Ignored
}
}

return true;
}

protected abstract Document Render(Tournament tournament, T configuration, ILocalization localization);
Expand Down
2 changes: 1 addition & 1 deletion src/Turnierplan.PdfRendering/Renderer/IDocumentRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ public interface IDocumentRenderer
{
Type DocumentConfigurationType { get; }

bool Render(Tournament tournament, IDocumentConfiguration configuration, ILocalization localization, Stream destination);
void Render(Tournament tournament, IDocumentConfiguration configuration, ILocalization localization, Stream destination);
}
Loading