#35 api for transferring recitation ownership
This commit is contained in:
parent
7a09d7ad1b
commit
105aae9333
@ -550,15 +550,46 @@ namespace RMuseum.Controllers
|
|||||||
return Ok(res.Result.Items);
|
return Ok(res.Result.Items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Transfer Recitations Ownership
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="targetEmailAddress"></param>
|
||||||
|
/// <param name="artistName"></param>
|
||||||
|
/// <returns>number of transfered items</returns>
|
||||||
|
|
||||||
|
[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<IActionResult> 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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// constructor
|
/// constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="audioService"></param>
|
/// <param name="audioService"></param>
|
||||||
/// <param name="userPermissionChecker"></param>
|
/// <param name="userPermissionChecker"></param>
|
||||||
public RecitationController(IRecitationService audioService, IUserPermissionChecker userPermissionChecker)
|
/// <param name="appUserService"></param>
|
||||||
|
public RecitationController(IRecitationService audioService, IUserPermissionChecker userPermissionChecker, IAppUserService appUserService)
|
||||||
{
|
{
|
||||||
_audioService = audioService;
|
_audioService = audioService;
|
||||||
_userPermissionChecker = userPermissionChecker;
|
_userPermissionChecker = userPermissionChecker;
|
||||||
|
_appUserService = appUserService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -571,5 +602,10 @@ namespace RMuseum.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected IUserPermissionChecker _userPermissionChecker;
|
protected IUserPermissionChecker _userPermissionChecker;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IAppUserService instance
|
||||||
|
/// </summary>
|
||||||
|
protected IAppUserService _appUserService;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -833,12 +833,21 @@
|
|||||||
<param name="finished"></param>
|
<param name="finished"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:RMuseum.Controllers.RecitationController.#ctor(RMuseum.Services.IRecitationService,RSecurityBackend.Services.IUserPermissionChecker)">
|
<member name="M:RMuseum.Controllers.RecitationController.TransferRecitationsOwnership(System.String,System.String)">
|
||||||
|
<summary>
|
||||||
|
Transfer Recitations Ownership
|
||||||
|
</summary>
|
||||||
|
<param name="targetEmailAddress"></param>
|
||||||
|
<param name="artistName"></param>
|
||||||
|
<returns>number of transfered items</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:RMuseum.Controllers.RecitationController.#ctor(RMuseum.Services.IRecitationService,RSecurityBackend.Services.IUserPermissionChecker,RSecurityBackend.Services.IAppUserService)">
|
||||||
<summary>
|
<summary>
|
||||||
constructor
|
constructor
|
||||||
</summary>
|
</summary>
|
||||||
<param name="audioService"></param>
|
<param name="audioService"></param>
|
||||||
<param name="userPermissionChecker"></param>
|
<param name="userPermissionChecker"></param>
|
||||||
|
<param name="appUserService"></param>
|
||||||
</member>
|
</member>
|
||||||
<member name="F:RMuseum.Controllers.RecitationController._audioService">
|
<member name="F:RMuseum.Controllers.RecitationController._audioService">
|
||||||
<summary>
|
<summary>
|
||||||
@ -850,6 +859,11 @@
|
|||||||
IUserPermissionChecker instance
|
IUserPermissionChecker instance
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="F:RMuseum.Controllers.RecitationController._appUserService">
|
||||||
|
<summary>
|
||||||
|
IAppUserService instance
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="T:RMuseum.Controllers.RImageController">
|
<member name="T:RMuseum.Controllers.RImageController">
|
||||||
<summary>
|
<summary>
|
||||||
Generic Image Provider
|
Generic Image Provider
|
||||||
@ -5138,6 +5152,15 @@
|
|||||||
<param name="finished"></param>
|
<param name="finished"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:RMuseum.Services.Implementation.RecitationService.TransferRecitationsOwnership(System.Guid,System.Guid,System.String)">
|
||||||
|
<summary>
|
||||||
|
Transfer Recitations Ownership
|
||||||
|
</summary>
|
||||||
|
<param name="currentOwenerId"></param>
|
||||||
|
<param name="newOwnerId"></param>
|
||||||
|
<param name="artistName"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="P:RMuseum.Services.Implementation.RecitationService.Configuration">
|
<member name="P:RMuseum.Services.Implementation.RecitationService.Configuration">
|
||||||
<summary>
|
<summary>
|
||||||
Configuration
|
Configuration
|
||||||
@ -5444,6 +5467,15 @@
|
|||||||
<param name="userId"></param>
|
<param name="userId"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:RMuseum.Services.IRecitationService.TransferRecitationsOwnership(System.Guid,System.Guid,System.String)">
|
||||||
|
<summary>
|
||||||
|
Transfer Recitations Ownership
|
||||||
|
</summary>
|
||||||
|
<param name="currentOwenerId"></param>
|
||||||
|
<param name="newOwnerId"></param>
|
||||||
|
<param name="artistName"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:RMuseum.Services.IRecitationService.GetUploads(RSecurityBackend.Models.Generic.PagingParameterModel,System.Guid)">
|
<member name="M:RMuseum.Services.IRecitationService.GetUploads(RSecurityBackend.Models.Generic.PagingParameterModel,System.Guid)">
|
||||||
<summary>
|
<summary>
|
||||||
Get uploads descending by upload time
|
Get uploads descending by upload time
|
||||||
|
|||||||
@ -142,6 +142,15 @@ namespace RMuseum.Services
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<RServiceResult<bool>> DeleteUserNarrationProfiles(Guid id, Guid userId);
|
Task<RServiceResult<bool>> DeleteUserNarrationProfiles(Guid id, Guid userId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Transfer Recitations Ownership
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="currentOwenerId"></param>
|
||||||
|
/// <param name="newOwnerId"></param>
|
||||||
|
/// <param name="artistName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<RServiceResult<int>> TransferRecitationsOwnership(Guid currentOwenerId, Guid newOwnerId, string artistName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get uploads descending by upload time
|
/// Get uploads descending by upload time
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -1430,6 +1430,32 @@ namespace RMuseum.Services.Implementation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Transfer Recitations Ownership
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="currentOwenerId"></param>
|
||||||
|
/// <param name="newOwnerId"></param>
|
||||||
|
/// <param name="artistName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<RServiceResult<int>> 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<int>(recitations.Count);
|
||||||
|
}
|
||||||
|
catch(Exception exp)
|
||||||
|
{
|
||||||
|
return new RServiceResult<int>(0, exp.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Configuration
|
/// Configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -40,20 +40,20 @@
|
|||||||
"UploadLimit": "52428800"
|
"UploadLimit": "52428800"
|
||||||
},
|
},
|
||||||
"AudioMySqlServer": {
|
"AudioMySqlServer": {
|
||||||
"Server": "185.8.175.123",
|
"Server": "localhost",
|
||||||
"Username": "ganjoor_wuser",
|
"Username": "root",
|
||||||
"Password": "6Uy^gjjUjj889nN",
|
"Password": "",
|
||||||
"Database": "ganjoor_adab",
|
"Database": "adab",
|
||||||
"2ndDatabase": "ganjoor_audio",
|
"2ndDatabase": "audio",
|
||||||
"2ndUsername": "ganjoor_audio",
|
"2ndUsername": "audio",
|
||||||
"2ndPassword": "ytTA8mbFRo"
|
"2ndPassword": ""
|
||||||
},
|
},
|
||||||
"AudioSFPServer": {
|
"AudioSFPServer": {
|
||||||
"Host": "185.8.175.123",
|
"Host": "localhost",
|
||||||
"Port": "22",
|
"Port": "22",
|
||||||
"Username": "ganjoor",
|
"Username": "root",
|
||||||
"Password": "$693#400%aPo@a",
|
"Password": "",
|
||||||
"RootPath": "/home/ganjoor/domains/ganjoor.net/public_html"
|
"RootPath": "/home"
|
||||||
},
|
},
|
||||||
"AudioUploadService": {
|
"AudioUploadService": {
|
||||||
"TempUploadPath": "C:\\tempaudio",
|
"TempUploadPath": "C:\\tempaudio",
|
||||||
|
|||||||
@ -2043,6 +2043,13 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:RSecurityBackend.Services.IAppUserService.FindUserByEmail(System.String)">
|
||||||
|
<summary>
|
||||||
|
Find User By Email
|
||||||
|
</summary>
|
||||||
|
<param name="email"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="P:RSecurityBackend.Services.IAppUserService.AdministratorRoleName">
|
<member name="P:RSecurityBackend.Services.IAppUserService.AdministratorRoleName">
|
||||||
<summary>
|
<summary>
|
||||||
Administrator role name
|
Administrator role name
|
||||||
@ -2355,6 +2362,13 @@
|
|||||||
<param name="clientIPAddress"></param>
|
<param name="clientIPAddress"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:RSecurityBackend.Services.Implementation.AppUserService.FindUserByEmail(System.String)">
|
||||||
|
<summary>
|
||||||
|
Find User By Email
|
||||||
|
</summary>
|
||||||
|
<param name="email"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:RSecurityBackend.Services.Implementation.AppUserService.DeleteTenant">
|
<member name="M:RSecurityBackend.Services.Implementation.AppUserService.DeleteTenant">
|
||||||
<summary>
|
<summary>
|
||||||
delete tenant
|
delete tenant
|
||||||
|
|||||||
@ -239,6 +239,13 @@ namespace RSecurityBackend.Services
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
RServiceResult<bool> DeleteTenant();
|
RServiceResult<bool> DeleteTenant();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find User By Email
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="email"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<RServiceResult<PublicRAppUser>> FindUserByEmail(string email);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Administrator role name
|
/// Administrator role name
|
||||||
|
|||||||
@ -1245,6 +1245,26 @@ namespace RSecurityBackend.Services.Implementation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find User By Email
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="email"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<RServiceResult<PublicRAppUser>> FindUserByEmail(string email)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RAppUser user = await _userManager.FindByEmailAsync(email);
|
||||||
|
if (user == null)
|
||||||
|
return new RServiceResult<PublicRAppUser>(null);
|
||||||
|
return new RServiceResult<PublicRAppUser>(new PublicRAppUser(user));
|
||||||
|
}
|
||||||
|
catch(Exception exp)
|
||||||
|
{
|
||||||
|
return new RServiceResult<PublicRAppUser>(null, exp.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// delete tenant
|
/// delete tenant
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user