- Wire up lists and todos to C# backend with full CRUD persistence - Add models, DTOs, repositories, and services for lists and todo lists/items - Preserve SQLite DB across vault rebuild/load cycles - Add session store for vault password persistence across navigation - Add inline name input for creating lists and todo lists in SidePanel - Clear editor panel on section change with empty state placeholder - Default markdown editor to preview mode on item selection - Decompose EditorPanel into sub-components: - editor/FragmentEditor, editor/TodoEditor, editor/MarkdownEditor - Shared markdown utilities in utils/markdown.ts - Strip verbose console/eprintln logging from frontend and Tauri backend - Add graceful shutdown with vault persistence on window close Co-Authored-By: Oz <oz-agent@warp.dev>
55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Journal.Core.Dtos;
|
|
using Journal.Core.Models;
|
|
using Journal.Core.Repositories;
|
|
|
|
namespace Journal.Core.Services.Lists;
|
|
|
|
public class ListService(IListRepository repo) : IListService
|
|
{
|
|
private readonly IListRepository _repo = repo ?? throw new ArgumentNullException(nameof(repo));
|
|
|
|
private static ListDocumentDto Map(ListDocument d) => new(
|
|
d.Id,
|
|
d.Label,
|
|
d.Content,
|
|
d.CreatedAt,
|
|
d.UpdatedAt
|
|
);
|
|
|
|
public List<ListDocumentDto> GetAll()
|
|
{
|
|
var items = _repo.GetAll();
|
|
return [.. items.Select(Map)];
|
|
}
|
|
|
|
public ListDocumentDto? GetById(Guid id)
|
|
{
|
|
var d = _repo.GetById(id);
|
|
return d is null ? null : Map(d);
|
|
}
|
|
|
|
public ListDocumentDto Create(CreateListDto dto)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(dto);
|
|
|
|
var ctx = new ValidationContext(dto);
|
|
Validator.ValidateObject(dto, ctx, validateAllProperties: true);
|
|
|
|
var doc = new ListDocument(dto.Label, dto.Content ?? "");
|
|
_repo.Add(doc);
|
|
return Map(doc);
|
|
}
|
|
|
|
public bool Update(Guid id, UpdateListDto dto)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(dto);
|
|
if (dto.Label is not null && string.IsNullOrWhiteSpace(dto.Label))
|
|
throw new ValidationException("Label cannot be empty");
|
|
|
|
return _repo.Update(id, dto.Label?.Trim(), dto.Content);
|
|
}
|
|
|
|
public bool Remove(Guid id) => _repo.Remove(id);
|
|
}
|