Jacob Schmidt 0d77300c22 feat: Project Journal backend monorepo
Monorepo with centralized build props, npm workspaces, LlamaSharp AI,
SQLite/SQLCipher storage, Svelte frontend, and unified smoke tests.

Co-Authored-By: Oz <oz-agent@warp.dev>
2026-03-02 20:56:26 -06:00

43 lines
1.3 KiB
C#

namespace Journal.Core.Models;
public class Fragment
{
public Guid Id { get; }
public string Type { get; set; }
public string Description { get; set; }
public DateTimeOffset Time { get; set; }
public List<string> Tags { get; set; } = [];
public Fragment(string type, string description)
{
Validate(type, description);
Id = Guid.NewGuid();
Type = type.Trim();
Description = description.Trim();
Time = DateTimeOffset.Now;
}
public Fragment(Guid id, string type, string description, DateTimeOffset time, IEnumerable<string>? tags = null)
{
if (id == Guid.Empty)
throw new ArgumentException("Id is required", nameof(id));
Validate(type, description);
Id = id;
Type = type.Trim();
Description = description.Trim();
Time = time;
if (tags is not null)
Tags = [.. tags.Where(t => !string.IsNullOrWhiteSpace(t)).Select(t => t.Trim())];
}
private static void Validate(string type, string description)
{
if (string.IsNullOrWhiteSpace(type))
throw new ArgumentException("Type is required", nameof(type));
if (string.IsNullOrWhiteSpace(description))
throw new ArgumentException("Description is required", nameof(description));
}
}