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 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? 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)); } }