diff --git a/RMuseum/Controllers/RecitationController.cs b/RMuseum/Controllers/RecitationController.cs
index 7a039ccc..adf6649c 100644
--- a/RMuseum/Controllers/RecitationController.cs
+++ b/RMuseum/Controllers/RecitationController.cs
@@ -550,15 +550,46 @@ namespace RMuseum.Controllers
return Ok(res.Result.Items);
}
+ ///
+ /// Transfer Recitations Ownership
+ ///
+ ///
+ ///
+ /// number of transfered items
+
+ [HttpPut("chown")]
+ [Authorize(Policy = RMuseumSecurableItem.AudioNarrationEntityShortName + ":" + RMuseumSecurableItem.ImportOperationShortName)]
+ [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(int))]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
+ [ProducesResponseType((int)HttpStatusCode.NotFound, Type = typeof(string))]
+ public async Task TransferRecitationsOwnership(string targetEmailAddress, string artistName)
+ {
+ Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
+ var userSearchResult = await _appUserService.FindUserByEmail(targetEmailAddress);
+ if (!string.IsNullOrEmpty(userSearchResult.ExceptionString))
+ return BadRequest(userSearchResult);
+ if (userSearchResult.Result == null)
+ return NotFound();
+
+ var resExec = await _audioService.TransferRecitationsOwnership(loggedOnUserId, (Guid)userSearchResult.Result.Id, artistName);
+ if (!string.IsNullOrEmpty(resExec.ExceptionString))
+ return BadRequest(resExec.ExceptionString);
+
+ return Ok(resExec.Result);
+
+ }
+
///
/// constructor
///
///
///
- public RecitationController(IRecitationService audioService, IUserPermissionChecker userPermissionChecker)
+ ///
+ public RecitationController(IRecitationService audioService, IUserPermissionChecker userPermissionChecker, IAppUserService appUserService)
{
_audioService = audioService;
_userPermissionChecker = userPermissionChecker;
+ _appUserService = appUserService;
}
///
@@ -571,5 +602,10 @@ namespace RMuseum.Controllers
///
protected IUserPermissionChecker _userPermissionChecker;
+ ///
+ /// IAppUserService instance
+ ///
+ protected IAppUserService _appUserService;
+
}
}
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index 0f6793b8..b01bb20d 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -833,12 +833,21 @@
-
+
+
+ Transfer Recitations Ownership
+
+
+
+ number of transfered items
+
+
constructor
+
@@ -850,6 +859,11 @@
IUserPermissionChecker instance
+
+
+ IAppUserService instance
+
+
Generic Image Provider
@@ -5138,6 +5152,15 @@
+
+
+ Transfer Recitations Ownership
+
+
+
+
+
+
Configuration
@@ -5444,6 +5467,15 @@
+
+
+ Transfer Recitations Ownership
+
+
+
+
+
+
Get uploads descending by upload time
diff --git a/RMuseum/Services/IRecitationService.cs b/RMuseum/Services/IRecitationService.cs
index 2c2f76f5..41155804 100644
--- a/RMuseum/Services/IRecitationService.cs
+++ b/RMuseum/Services/IRecitationService.cs
@@ -142,6 +142,15 @@ namespace RMuseum.Services
///
Task> DeleteUserNarrationProfiles(Guid id, Guid userId);
+ ///
+ /// Transfer Recitations Ownership
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task> TransferRecitationsOwnership(Guid currentOwenerId, Guid newOwnerId, string artistName);
+
///
/// Get uploads descending by upload time
///
diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs
index cb0ecbc1..569afe11 100644
--- a/RMuseum/Services/Implementation/RecitationService.cs
+++ b/RMuseum/Services/Implementation/RecitationService.cs
@@ -1430,6 +1430,32 @@ namespace RMuseum.Services.Implementation
}
}
+ ///
+ /// Transfer Recitations Ownership
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task> TransferRecitationsOwnership(Guid currentOwenerId, Guid newOwnerId, string artistName)
+ {
+ try
+ {
+ var recitations = await _context.Recitations.Where(r => r.OwnerId == currentOwenerId && r.AudioArtist == artistName).ToListAsync();
+ foreach(Recitation recitation in recitations)
+ {
+ recitation.OwnerId = newOwnerId;
+ }
+ _context.Recitations.UpdateRange(recitations);
+ await _context.SaveChangesAsync();
+ return new RServiceResult(recitations.Count);
+ }
+ catch(Exception exp)
+ {
+ return new RServiceResult(0, exp.ToString());
+ }
+ }
+
///
/// Configuration
///
diff --git a/RMuseum/appsettings.json b/RMuseum/appsettings.json
index 2e6f9021..73abb188 100644
--- a/RMuseum/appsettings.json
+++ b/RMuseum/appsettings.json
@@ -40,20 +40,20 @@
"UploadLimit": "52428800"
},
"AudioMySqlServer": {
- "Server": "185.8.175.123",
- "Username": "ganjoor_wuser",
- "Password": "6Uy^gjjUjj889nN",
- "Database": "ganjoor_adab",
- "2ndDatabase": "ganjoor_audio",
- "2ndUsername": "ganjoor_audio",
- "2ndPassword": "ytTA8mbFRo"
+ "Server": "localhost",
+ "Username": "root",
+ "Password": "",
+ "Database": "adab",
+ "2ndDatabase": "audio",
+ "2ndUsername": "audio",
+ "2ndPassword": ""
},
"AudioSFPServer": {
- "Host": "185.8.175.123",
+ "Host": "localhost",
"Port": "22",
- "Username": "ganjoor",
- "Password": "$693#400%aPo@a",
- "RootPath": "/home/ganjoor/domains/ganjoor.net/public_html"
+ "Username": "root",
+ "Password": "",
+ "RootPath": "/home"
},
"AudioUploadService": {
"TempUploadPath": "C:\\tempaudio",
diff --git a/RSecurityBackend/RSecurityBackend.xml b/RSecurityBackend/RSecurityBackend.xml
index d2c20fda..2838e27b 100644
--- a/RSecurityBackend/RSecurityBackend.xml
+++ b/RSecurityBackend/RSecurityBackend.xml
@@ -2043,6 +2043,13 @@
+
+
+ Find User By Email
+
+
+
+
Administrator role name
@@ -2355,6 +2362,13 @@
+
+
+ Find User By Email
+
+
+
+
delete tenant
diff --git a/RSecurityBackend/Services/IAppUserService.cs b/RSecurityBackend/Services/IAppUserService.cs
index 6796110a..45cdd545 100644
--- a/RSecurityBackend/Services/IAppUserService.cs
+++ b/RSecurityBackend/Services/IAppUserService.cs
@@ -239,6 +239,13 @@ namespace RSecurityBackend.Services
///
RServiceResult DeleteTenant();
+ ///
+ /// Find User By Email
+ ///
+ ///
+ ///
+ Task> FindUserByEmail(string email);
+
///
/// Administrator role name
diff --git a/RSecurityBackend/Services/Implementation/AppUserService.cs b/RSecurityBackend/Services/Implementation/AppUserService.cs
index 59ea62d9..b32319c5 100644
--- a/RSecurityBackend/Services/Implementation/AppUserService.cs
+++ b/RSecurityBackend/Services/Implementation/AppUserService.cs
@@ -1245,6 +1245,26 @@ namespace RSecurityBackend.Services.Implementation
}
}
+ ///
+ /// Find User By Email
+ ///
+ ///
+ ///
+ public async Task> FindUserByEmail(string email)
+ {
+ try
+ {
+ RAppUser user = await _userManager.FindByEmailAsync(email);
+ if (user == null)
+ return new RServiceResult(null);
+ return new RServiceResult(new PublicRAppUser(user));
+ }
+ catch(Exception exp)
+ {
+ return new RServiceResult(null, exp.ToString());
+ }
+ }
+
///
/// delete tenant