diff --git a/src/WorkFlow.Application/Profiles/ReadProfile.cs b/src/WorkFlow.Application/Profiles/ReadProfile.cs
index c70551d..48bd4e0 100644
--- a/src/WorkFlow.Application/Profiles/ReadProfile.cs
+++ b/src/WorkFlow.Application/Profiles/ReadProfile.cs
@@ -7,7 +7,7 @@ namespace WorkFlow.Application.Profiles;
/// Represents a request to read a user profile by their user ID.
///
/// The ID of the user whose profile is being requested.
-public record ReadProfile(int UserId) : IRequest;
+public record ReadProfile(int UserId, bool IncludeObject = true) : IRequest;
///
/// Handles the request by retrieving the user profile
@@ -15,15 +15,19 @@ public record ReadProfile(int UserId) : IRequest;
///
public class ReadProfileHandler : IRequestHandler
{
- private readonly IProfileRepository _repository;
+ private readonly IProfileRepository _profileRepository;
+
+ private readonly IProfileObjRepository _objRepository;
///
/// Initializes a new instance of the class.
///
- /// The profile repository used to access profile data.
- public ReadProfileHandler(IProfileRepository repository)
+ /// The profile repository used to access profile data.
+ /// The profile object repository used to access object data.
+ public ReadProfileHandler(IProfileRepository profileRepository, IProfileObjRepository objRepository)
{
- _repository = repository;
+ _profileRepository = profileRepository;
+ _objRepository = objRepository;
}
///
@@ -35,7 +39,10 @@ public class ReadProfileHandler : IRequestHandlerThe user profile if found; otherwise, null.
public async Task Handle(ReadProfile request, CancellationToken cancel = default)
{
- var profile = await _repository.ReadAsync(request.UserId, cancel);
+ var profile = await _profileRepository.ReadAsync(request.UserId, cancel);
+ if (request.IncludeObject && profile?.Id is int profileId)
+ profile.Objects = await _objRepository.ReadAsync(request.UserId, profileId, cancel);
+
return profile;
}
}
diff --git a/src/WorkFlow.Domain/Entities/Profile.cs b/src/WorkFlow.Domain/Entities/Profile.cs
index dc7df36..6f4204b 100644
--- a/src/WorkFlow.Domain/Entities/Profile.cs
+++ b/src/WorkFlow.Domain/Entities/Profile.cs
@@ -26,5 +26,5 @@ public class Profile
public string? BackColor { get; set; }
[NotMapped]
- public IEnumerable? Objects;
+ public IEnumerable? Objects { get; set; }
}
\ No newline at end of file
diff --git a/src/WorkFlow.Domain/Entities/ProfileObjects.cs b/src/WorkFlow.Domain/Entities/ProfileObjects.cs
index 5f16fd4..0336a67 100644
--- a/src/WorkFlow.Domain/Entities/ProfileObjects.cs
+++ b/src/WorkFlow.Domain/Entities/ProfileObjects.cs
@@ -5,10 +5,10 @@ namespace WorkFlow.Domain.Entities;
public class ProfileObject
{
[Column("ObjStateID")]
- public int? ObjStateId { get; set; }
+ public long? ObjStateId { get; set; }
[Column("ObjectID")]
- public int? ObjectId { get; set; }
+ public long? Id { get; set; }
[Column("Headline1")]
public string? Headline1 { get; set; }