Refactor ReadProfileHandler and add Buttons property

Updated `ReadProfileHandler` to assign buttons directly to the `profile` object before mapping to `ProfileDto`. This ensures the `Buttons` property is populated correctly. Added a new `[NotMapped]` property `Buttons` of type `IEnumerable<Button>?` to the `Profile` class to hold associated buttons.
This commit is contained in:
tekh 2025-08-01 01:58:15 +02:00
parent 709ebea097
commit c779dd4a47
2 changed files with 5 additions and 7 deletions

View File

@ -57,15 +57,10 @@ public class ReadProfileHandler : IRequestHandler<ReadProfileQuery, ProfileDto>
if (request.IncludeObject && profile.Id is int profileId)
profile.Objects = await _objRepository.ReadAsync(request.UserId, profileId, cancel);
var profileDto = _mapper.Map<ProfileDto>(profile);
if (profile.Id is int pId)
{
var bttns = await _bttnRepository.Read(b => b.ProfileId == pId).ToListAsync(cancel);
profileDto.Buttons = _mapper.Map<IEnumerable<ButtonDto>>(bttns);
}
profile.Buttons = await _bttnRepository.Read(b => b.ProfileId == pId).ToListAsync(cancel);
return profileDto;
return _mapper.Map<ProfileDto>(profile);
}
}

View File

@ -27,4 +27,7 @@ public class Profile
[NotMapped]
public IEnumerable<ProfileObject>? Objects { get; set; }
[NotMapped]
public IEnumerable<Button>? Buttons { get; set; }
}