implement

This commit is contained in:
2026-02-11 19:10:55 +01:00
parent caea390d18
commit d72785e37e
14 changed files with 236 additions and 2 deletions

View File

@@ -18,6 +18,11 @@ public abstract class DomainModel<TId> where TId : DomainId
Id = id;
}
public string GetModelName()
{
return this.GetType().Name;
}
public IReadOnlyList<IDomainEvent> GetDomainEvents() => _domainEvents.ToList();
public void ClearDomainEvents() => _domainEvents.Clear();

View File

@@ -0,0 +1,38 @@
using AipsCore.Domain.Common.Validation;
using AipsCore.Domain.Common.ValueObjects;
using AipsCore.Domain.Models.Whiteboard.ValueObjects;
namespace AipsCore.Domain.Abstract.Validation;
public abstract class AbstractErrors<TModel, TId>
where TModel : DomainModel<TId>
where TId : DomainId
{
public static string GetModelName()
{
return typeof(TModel).Name;
}
public static string Prefix()
{
return GetModelName().ToLower();
}
protected static string GetFullCode(string code)
{
return $"{Prefix()}_{code}";
}
protected static ValidationError CreateValidationError(string code, string errorMessage)
{
return new ValidationError(GetFullCode(code), errorMessage);
}
public static ValidationError NotFound(TId id)
{
const string code = "not_found";
string message = $"{GetModelName()} with id '{id}' was not found!";
return CreateValidationError(code,message);
}
}