Add base product DbEntities and domain Entities

This commit is contained in:
lumijiez
2025-05-04 00:53:16 +03:00
parent 6e98b7dc22
commit 7fd2af2d5a
13 changed files with 379 additions and 15 deletions

View File

@@ -0,0 +1,49 @@
namespace Printbase.Domain.Entities.Products;
public class ProductGroup
{
public Guid Id { get; private set; }
public string Name { get; private set; }
public string? Description { get; private set; }
public IReadOnlyCollection<ProductType> Types => _types.AsReadOnly();
private readonly List<ProductType> _types = new();
private ProductGroup() { }
public ProductGroup(Guid id, string name, string? description = null)
{
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentException("Group name cannot be empty", nameof(name));
Id = id;
Name = name;
Description = description;
}
public void AddType(ProductType type)
{
ArgumentNullException.ThrowIfNull(type);
_types.Add(type);
}
public void RemoveType(Guid typeId)
{
var type = _types.Find(t => t.Id == typeId);
if (type != null) _types.Remove(type);
}
public void UpdateName(string name)
{
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentException("Group name cannot be empty", nameof(name));
Name = name;
}
public void UpdateDescription(string? description)
{
Description = description;
}
}