Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(changeLogHistory) : add log history method #9

Merged
merged 2 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions GenericRepository/Domain/Entities/ChangeHistoryEntity.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
using System.Text.Json;
using System.Text.Json.Serialization;

namespace GenericRepository.Domain.Entities;

public class ChangeHistoryEntity : BaseEntity
{
public long Id { get; set; }
public string OldValue { get; set; }
public string NewValue { get; set; }
public string RelatedEntityId { get; set; }
public string RelatedEntityType { get; set; }
public string OldValue { get; private set; }

Check warning on line 8 in GenericRepository/Domain/Entities/ChangeHistoryEntity.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; }

Check warning on line 10 in GenericRepository/Domain/Entities/ChangeHistoryEntity.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'NewValue' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

public string RelatedEntityId { get; private set; }

Check warning on line 12 in GenericRepository/Domain/Entities/ChangeHistoryEntity.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'RelatedEntityId' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

public string RelatedEntityType { get; private set; }

Check warning on line 14 in GenericRepository/Domain/Entities/ChangeHistoryEntity.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'RelatedEntityType' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

public void LogHistory(BaseEntity oldEntity , BaseEntity newEntity)
{
OldValue = JsonSerializer.Serialize(oldEntity);
NewValue = JsonSerializer.Serialize(oldEntity);
RelatedEntityId = oldEntity.Id.ToString();
RelatedEntityType = oldEntity.GetType().Name;
}
}
4 changes: 1 addition & 3 deletions GenericRepository/Domain/Entities/OutBoxMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ public OutBoxMessage(string type , string content)
Type = type;
Content = content;
}

public OutBoxMessage(IDomainEvent domainEvent)
{
Type = domainEvent.GetType().Name;
Content = JsonSerializer.Serialize(domainEvent);
}

public long Id { get; private set; }

public string Type { get; private set; }
public string Content { get; private set; }
}
Loading