From dd4cd1b39e896e0b5f3903d6661bbb3a9cb95808 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 25 Jul 2025 17:42:58 +0200 Subject: [PATCH] =?UTF-8?q?feat(ReadProfile):=20Unterst=C3=BCtzung=20f?= =?UTF-8?q?=C3=BCr=20das=20bedingte=20Laden=20von=20Profilobjekten=20hinzu?= =?UTF-8?q?gef=C3=BCgt=20-=20Flag=20=E2=80=9EIncludeObject=E2=80=9D=20in?= =?UTF-8?q?=20ReadProfile-Anfrage=20eingef=C3=BChrt=20-=20IProfileObjRepos?= =?UTF-8?q?itory=20in=20ReadProfileHandler=20eingef=C3=BCgt=20-=20Handler?= =?UTF-8?q?=20aktualisiert,=20um=20Profilobjekte=20zu=20laden,=20wenn=20In?= =?UTF-8?q?cludeObject=20wahr=20ist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Profiles/ReadProfile.cs | 19 +++++++++++++------ src/WorkFlow.Domain/Entities/Profile.cs | 2 +- .../Entities/ProfileObjects.cs | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) 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; }