#40 make ff first
This commit is contained in:
parent
abfff693f5
commit
c1697df1c5
@ -581,6 +581,25 @@ namespace RMuseum.Controllers
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes recitations of فریدون فرحاندوز first recitations
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPut("ff")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.AudioRecitationEntityShortName + ":" + 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> MakeFFRecitationsFirst()
|
||||
{
|
||||
var resExec = await _audioService.MakeArtistRecitationsFirst("فریدون فرحاندوز");
|
||||
if (!string.IsNullOrEmpty(resExec.ExceptionString))
|
||||
return BadRequest(resExec.ExceptionString);
|
||||
|
||||
return Ok(resExec.Result);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
|
||||
@ -843,6 +843,12 @@
|
||||
<param name="artistName"></param>
|
||||
<returns>number of transfered items</returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.RecitationController.MakeFFRecitationsFirst">
|
||||
<summary>
|
||||
Makes recitations of فریدون فرحاندوز first recitations
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.RecitationController.#ctor(RMuseum.Services.IRecitationService,RSecurityBackend.Services.IUserPermissionChecker,RSecurityBackend.Services.IAppUserService)">
|
||||
<summary>
|
||||
constructor
|
||||
@ -5165,6 +5171,13 @@
|
||||
<param name="artistName"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.RecitationService.MakeArtistRecitationsFirst(System.String)">
|
||||
<summary>
|
||||
move recitaions of an artist to the first position
|
||||
</summary>
|
||||
<param name="artistName"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:RMuseum.Services.Implementation.RecitationService.Configuration">
|
||||
<summary>
|
||||
Configuration
|
||||
@ -5504,6 +5517,13 @@
|
||||
<param name="finished"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IRecitationService.MakeArtistRecitationsFirst(System.String)">
|
||||
<summary>
|
||||
move recitaions of an artist to the first position
|
||||
</summary>
|
||||
<param name="artistName"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:RMuseum.Services.IRNotificationService">
|
||||
<summary>
|
||||
Internal messaging system interface
|
||||
|
||||
@ -174,5 +174,12 @@ namespace RMuseum.Services
|
||||
/// <param name="finished"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<(PaginationMetadata PagingMeta, RecitationPublishingTracker[] Items)>> GetPublishingQueueStatus(PagingParameterModel paging, bool inProgress, bool finished);
|
||||
|
||||
/// <summary>
|
||||
/// move recitaions of an artist to the first position
|
||||
/// </summary>
|
||||
/// <param name="artistName"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<int>> MakeArtistRecitationsFirst(string artistName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1567,6 +1567,46 @@ namespace RMuseum.Services.Implementation
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// move recitaions of an artist to the first position
|
||||
/// </summary>
|
||||
/// <param name="artistName"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<int>> MakeArtistRecitationsFirst(string artistName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recitations = await _context.Recitations.Where(r => r.AudioArtist == artistName && r.AudioOrder != 1).ToListAsync();
|
||||
foreach (Recitation recitation in recitations)
|
||||
{
|
||||
var otherRecitaions = await _context.Recitations.Where(r => r.GanjoorPostId == recitation.GanjoorPostId && r.AudioArtist != artistName).ToListAsync();
|
||||
|
||||
foreach(Recitation other in otherRecitaions)
|
||||
{
|
||||
other.AudioOrder = other.AudioOrder + 1;
|
||||
other.AudioSyncStatus = (int)AudioSyncStatus.MetadataChanged;
|
||||
_context.Recitations.Update(other);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
await _UpdateRemoteRecitations(other, _context);
|
||||
}
|
||||
|
||||
recitation.AudioOrder = 1;
|
||||
recitation.AudioSyncStatus = (int)AudioSyncStatus.MetadataChanged;
|
||||
_context.Recitations.Update(recitation);
|
||||
|
||||
await _UpdateRemoteRecitations(recitation, _context);
|
||||
}
|
||||
|
||||
|
||||
return new RServiceResult<int>(recitations.Count);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<int>(0, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configuration
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user