33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using Journal.Core.Dtos;
|
|
using Journal.Core.Models;
|
|
|
|
namespace Journal.Core.Services.Entries;
|
|
|
|
internal static class JournalEntryDtoMapper
|
|
{
|
|
public static JournalEntryDto ToDto(this JournalEntry entry)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(entry);
|
|
|
|
return new JournalEntryDto(
|
|
Date: entry.Date,
|
|
Fragments:
|
|
[
|
|
.. entry.Fragments.Select(fragment => new FragmentDto(
|
|
Id: fragment.Id,
|
|
Type: fragment.Type,
|
|
Description: fragment.Description,
|
|
Time: fragment.Time,
|
|
Tags: [.. fragment.Tags]))
|
|
],
|
|
RawContent: entry.RawContent,
|
|
Sections: entry.Sections.ToDictionary(
|
|
section => section.Key,
|
|
section => new ParsedSectionDto(
|
|
Title: section.Value.Title,
|
|
Content: [.. section.Value.Content],
|
|
Checkboxes: section.Value.Checkboxes.ToDictionary(checkbox => checkbox.Key, checkbox => checkbox.Value)),
|
|
StringComparer.Ordinal));
|
|
}
|
|
}
|