using EricksonLopez.Events.Contracts;
using EricksonLopez.SharedKernel;
namespace Example.SharedKernelQuickStart;
public readonly record struct AccountId(Guid Value) : IEntityId<AccountId>
public bool IsEmpty => Value == Guid.Empty;
public static AccountId New() => new(Guid.NewGuid());
public static AccountId Create(Guid value) => new(value);
public static AccountId Parse(string s, IFormatProvider? provider) => new(Guid.Parse(s, provider));
public static bool TryParse(string? s, IFormatProvider? provider, out AccountId result)
if (Guid.TryParse(s, provider, out var guid))
public sealed record AccountOpenedEvent(AccountId AccountId) : DomainEvent;
public sealed class BankAccount : AggregateRoot<AccountId>
public decimal Balance { get; private set; }
private BankAccount(AccountId id, decimal initialDeposit) : base(id)
Balance = initialDeposit;
RaiseDomainEvent(new AccountOpenedEvent(id));
public static BankAccount Open(AccountId id, decimal initialDeposit) =>