Add player settings feature and settings API
This commit is contained in:
@@ -55,6 +55,31 @@ public class ProfileService(
|
||||
return mapper.Map<AvatarDTO>(profile.Avatar);
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<PlayerSettingDTO>> GetPlayerSettingsAsync(
|
||||
Guid profileId,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var settings = await profileRepository.GetSettingsByProfileIdAsync(profileId, ct);
|
||||
|
||||
return mapper.Map<List<PlayerSettingDTO>>(settings);
|
||||
}
|
||||
|
||||
public async Task<bool> UpdatePlayerSettingAsync(
|
||||
Guid profileId,
|
||||
UpdatePlayerSettingCommand command,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var profile = await profileRepository.GetByIdWithSettingsAsync(profileId, ct);
|
||||
if (profile is null)
|
||||
return false;
|
||||
|
||||
profile.SetSetting(command.Key, command.Value);
|
||||
|
||||
await profileRepository.SaveChangesAsync(ct);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<ProfileDTO>> GetProfilesAsync(
|
||||
List<Guid> profileIds,
|
||||
CancellationToken ct = default)
|
||||
@@ -123,4 +148,4 @@ public class ProfileService(
|
||||
expiresIn: token.ExpiresIn
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user