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:
parent
709ebea097
commit
c779dd4a47
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,4 +27,7 @@ public class Profile
|
||||
|
||||
[NotMapped]
|
||||
public IEnumerable<ProfileObject>? Objects { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public IEnumerable<Button>? Buttons { get; set; }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user