Skip to content

Commit

Permalink
feat(domain): add changeHistory and outboxMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikoo-Asadnejad committed May 3, 2024
1 parent f85d17f commit afc63a6
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Text.Json;
using Product.Domain.Shared.Base;

namespace Product.Domain.Aggregates.Shared.ChangeHistory.AggregateRoot;

public class ChangeHistory : BaseEntity
{
public string OldValue { get; private set; }

Check warning on line 8 in Src/Product.Domain/Aggregates/Shared/ChangeHistory/AggregateRoot/ChangeHistory.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'OldValue' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string NewValue { get;private set; }
public string RelatedEntityId { get; private set; }
public string RelatedEntityType { get; private set; }

public void LogHistory(BaseEntity oldEntity , BaseEntity newEntity)
{
OldValue = JsonSerializer.Serialize(oldEntity);
NewValue = JsonSerializer.Serialize(oldEntity);
RelatedEntityId = oldEntity.Id.ToString();
RelatedEntityType = oldEntity.GetType().Name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Text.Json;
using Product.Domain.Shared.Base;
using Product.Domain.Shared.Events;

namespace Product.Domain.Aggregates.Shared.OutboxMessage.AggregateRoot;

public class OutBoxMessage : BaseEntity
{
public OutBoxMessage(string type , string content)
{
Type = type;
Content = content;
}
public OutBoxMessage(IDomainEvent domainEvent)
{
Type = domainEvent.GetType().Name;
Content = JsonSerializer.Serialize(domainEvent);
}

public string Type { get; private set; }
public string Content { get; private set; }
}
1 change: 1 addition & 0 deletions Src/Product.Domain/Product.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ItemGroup>
<Folder Include="Aggregates\Category\Exceptions" />
<Folder Include="Aggregates\Category\ValueObjects" />
<Folder Include="Aggregates\Shared\ChangeHistory\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using Product.Domain.Shared.Base;

namespace Product.Domain.Shared.GenericRepository.GenericRepository.Command;
namespace Product.Domain.Shared.GenericRepository.Interfaces.Command;

public partial interface IRepository<T> where T : IAggregateRoot
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Product.Domain.Shared.Base;

namespace Product.Domain.Shared.GenericRepository.GenericRepository.Command;
namespace Product.Domain.Shared.GenericRepository.Interfaces.Command;

public partial interface IRepository<T> where T : IAggregateRoot
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Product.Domain.Shared.GenericRepository.UnitOfWork;
namespace Product.Domain.Shared.GenericRepository.Interfaces;

public interface IUnitOfWork
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Product.Domain.Shared.Base;
using Product.Domain.Shared.GenericRepository.Enums;

namespace Product.Domain.Shared.GenericRepository.GenericRepository.Query;
namespace Product.Domain.Shared.GenericRepository.Interfaces.Query;

public partial interface IQueryGenericRepository<T> where T : BaseEntity
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Product.Domain.Shared.Base;
using Product.Domain.Shared.GenericRepository.Enums;

namespace Product.Domain.Shared.GenericRepository.GenericRepository.Query;
namespace Product.Domain.Shared.GenericRepository.Interfaces.Query;

public partial interface IQueryGenericRepository<T> where T : BaseEntity
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;
using Product.Domain.Shared.Base;
using Product.Domain.Shared.GenericRepository.GenericRepository.Command;
using Product.Domain.Shared.GenericRepository.Interfaces.Command;
using Product.Infrastructure.Data.Context;

namespace Product.Infrastructure.Data.Repository.GenericRepository.Command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Extensions.Caching.Memory;
using Product.Domain.Shared.Base;
using Product.Domain.Shared.GenericRepository.Enums;
using Product.Domain.Shared.GenericRepository.GenericRepository.Query;
using Product.Domain.Shared.GenericRepository.Interfaces.Query;

namespace Product.Infrastructure.Data.Repository.GenericRepository.Query;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.EntityFrameworkCore;
using Product.Domain.Shared.Base;
using Product.Domain.Shared.GenericRepository.Enums;
using Product.Domain.Shared.GenericRepository.GenericRepository.Query;
using Product.Domain.Shared.GenericRepository.Interfaces.Query;
using Product.Infrastructure.Data.Context;

namespace Product.Infrastructure.Data.Repository.GenericRepository.Query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.EntityFrameworkCore;
using Product.Domain.Shared.Base;
using Product.Domain.Shared.GenericRepository.Enums;
using Product.Domain.Shared.GenericRepository.GenericRepository.Query;
using Product.Domain.Shared.GenericRepository.Interfaces.Query;

namespace Product.Infrastructure.Data.Repository.GenericRepository.Query;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using Product.Domain.Shared.GenericRepository.UnitOfWork;
using Product.Domain.Shared.GenericRepository.Interfaces;

namespace Product.Infrastructure.Data.Repository.UnitOfWork;

Expand Down

0 comments on commit afc63a6

Please sign in to comment.