diff --git a/RMuseum/Controllers/RecitationController.cs b/RMuseum/Controllers/RecitationController.cs index 97017556..1da711ed 100644 --- a/RMuseum/Controllers/RecitationController.cs +++ b/RMuseum/Controllers/RecitationController.cs @@ -581,6 +581,25 @@ namespace RMuseum.Controllers } + /// + /// Makes recitations of فریدون فرح‌اندوز first recitations + /// + /// + [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 MakeFFRecitationsFirst() + { + var resExec = await _audioService.MakeArtistRecitationsFirst("فریدون فرح‌اندوز"); + if (!string.IsNullOrEmpty(resExec.ExceptionString)) + return BadRequest(resExec.ExceptionString); + + return Ok(resExec.Result); + + } + /// /// constructor /// diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 647dd5c0..a23ab48a 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -843,6 +843,12 @@ number of transfered items + + + Makes recitations of فریدون فرح‌اندوز first recitations + + + constructor @@ -5165,6 +5171,13 @@ + + + move recitaions of an artist to the first position + + + + Configuration @@ -5504,6 +5517,13 @@ + + + move recitaions of an artist to the first position + + + + Internal messaging system interface diff --git a/RMuseum/Services/IRecitationService.cs b/RMuseum/Services/IRecitationService.cs index 2309e286..7c10b1c1 100644 --- a/RMuseum/Services/IRecitationService.cs +++ b/RMuseum/Services/IRecitationService.cs @@ -174,5 +174,12 @@ namespace RMuseum.Services /// /// Task> GetPublishingQueueStatus(PagingParameterModel paging, bool inProgress, bool finished); + + /// + /// move recitaions of an artist to the first position + /// + /// + /// + Task> MakeArtistRecitationsFirst(string artistName); } } diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs index 33ca8951..cb9aac07 100644 --- a/RMuseum/Services/Implementation/RecitationService.cs +++ b/RMuseum/Services/Implementation/RecitationService.cs @@ -1567,6 +1567,46 @@ namespace RMuseum.Services.Implementation } } + /// + /// move recitaions of an artist to the first position + /// + /// + /// + public async Task> 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(recitations.Count); + } + catch (Exception exp) + { + return new RServiceResult(0, exp.ToString()); + } + } + /// /// Configuration ///