Added null checks

This commit is contained in:
CakeAndBanana
2025-10-19 17:39:36 +02:00
parent 4fdc2a5c29
commit bab81aaf51
2 changed files with 19 additions and 3 deletions

View File

@@ -11,7 +11,18 @@ public static class Extensions
{
public static GroupProfileDto ToDTO(this GroupProfile groupProfile)
{
return new GroupProfileDto(groupProfile.Group.ToGroupData(), groupProfile.Description, groupProfile.Tags, groupProfile.Base64GroupProfileImage, groupProfile.IsNSFW, groupProfile.ProfileDisabled);
ArgumentNullException.ThrowIfNull(groupProfile);
return groupProfile.Group == null
? throw new InvalidOperationException("GroupProfile.Group is null when converting to DTO.")
: new GroupProfileDto(
groupProfile.Group.ToGroupData(),
groupProfile.Description,
groupProfile.Tags,
groupProfile.Base64GroupProfileImage,
groupProfile.IsNSFW,
groupProfile.ProfileDisabled
);
}
public static GroupData ToGroupData(this Group group)