Added null checks
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user