added success message

This commit is contained in:
hannathkadher
2024-10-29 16:33:57 +04:00
parent d6e6eb9b1f
commit 9bd598da31
2 changed files with 4 additions and 13 deletions

View File

@ -109,15 +109,10 @@ export class CommunityService {
try {
const { name } = updateCommunityDto;
// Find the community by its UUID
// Update the community name
community.name = name;
// Save the updated community back to the database
const updatedCommunity = await this.communityRepository.save(community);
// Return a SuccessResponseDto with the updated community data
return new SuccessResponseDto<CommunityDto>({
message: 'Success update Community',
data: updatedCommunity,
@ -146,19 +141,14 @@ export class CommunityService {
);
}
try {
// Find the community by its uuid
await this.communityRepository.remove(community);
// Remove the community from the database
// Return success response
return new SuccessResponseDto({
message: `Community with ID ${communityUuid} successfully deleted`,
data: null,
message: `Community with ID ${communityUuid} has been successfully deleted`,
});
} catch (err) {
// Catch and handle any errors
if (err instanceof HttpException) {
throw err; // If it's an HttpException, rethrow it
throw err;
} else {
throw new HttpException(
'An error occurred while deleting the community',