diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index b35a2c74..239d8a7b 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -1833,11 +1833,18 @@ - accepts a reported error for recitations and notify the reporter and recitation owner (and deletes the report) + accepts a reported error for recitations, change status of the recitation to rejected and notify the reporter and recitation owner (and deletes the report) + + + accepts a reported error for recitations, add mistake to approve the mistake and notify the reporter and recitation owner (and deletes the report) + + + + up vote a recitation @@ -12662,6 +12669,13 @@ + + + accepts a reported error for recitations, add mistake to approve the mistake and notify the reporter and recitation owner (and deletes the report) + + + + compute poem recitations order @@ -13070,11 +13084,18 @@ - accepts a reported error for recitations and notify the reporter and recitation owner (and deletes the report) + accepts a reported error for recitations, change status of the recitation to rejected and notify the reporter and recitation owner (and deletes the report) + + + accepts a reported error for recitations, add mistake to approve the mistake and notify the reporter and recitation owner (and deletes the report) + + + + compute poem recitations order diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs index 51c515a4..ccc81432 100644 --- a/RMuseum/Services/Implementation/RecitationService.cs +++ b/RMuseum/Services/Implementation/RecitationService.cs @@ -897,6 +897,15 @@ namespace RMuseum.Services.Implementationa existing.FileLastUpdated = session.UploadEndTime; existing.AudioSyncStatus = AudioSyncStatus.SynchronizedOrRejected; context.Recitations.Update(existing); + + bool recomputeOrders = false; + var mistakes = await context.RecitationApprovedMistakes.Where(m => m.RecitationId == existing.Id).ToListAsync(); + if(mistakes.Count > 0) + { + context.RemoveRange(mistakes); + recomputeOrders = true; + } + await context.SaveChangesAsync(); await new RNotificationService(context).PushNotification @@ -907,6 +916,11 @@ namespace RMuseum.Services.Implementationa $"می‌توانید با مراجعه به این صفحه وضعیت آن را بررسی کنید." ); + if(recomputeOrders) + { + await _ComputePoemRecitationsOrdersAsync(context, existing.GanjoorPostId, true); + } + } } @@ -1938,11 +1952,16 @@ namespace RMuseum.Services.Implementationa /// /// public async Task> ComputePoemRecitationsOrdersAsync(int poemId, bool update = true) + { + return await _ComputePoemRecitationsOrdersAsync(_context, poemId, update); + } + + public async Task> _ComputePoemRecitationsOrdersAsync(RMuseumDbContext context, int poemId, bool update) { try { var recitations = - await _context.Recitations + await context.Recitations .Where(r => r.ReviewStatus == AudioReviewStatus.Approved && r.GanjoorPostId == poemId) .OrderBy(r => r.Id) //this causes the oldest recirations to become the first one .ToListAsync(); @@ -1956,9 +1975,9 @@ namespace RMuseum.Services.Implementationa { RecitationId = recitation.Id, EarlynessAdvantage = recitations.Count - 1 - i, - UpVotes = await _context.RecitationUserUpVotes.AsNoTracking().Where(r => r.RecitationId == recitation.Id && r.UserId != recitation.OwnerId) + UpVotes = await context.RecitationUserUpVotes.AsNoTracking().Where(r => r.RecitationId == recitation.Id && r.UserId != recitation.OwnerId) .CountAsync(), - Mistakes = await _context.RecitationApprovedMistakes.AsNoTracking().Where(m => m.RecitationId == recitation.Id).SumAsync(m => m.NumberOfLinesAffected) + Mistakes = await context.RecitationApprovedMistakes.AsNoTracking().Where(m => m.RecitationId == recitation.Id).SumAsync(m => m.NumberOfLinesAffected) }; @@ -1981,13 +2000,13 @@ namespace RMuseum.Services.Implementationa if (update) { - _context.Update(recitations[i]); + context.Update(recitations[i]); } } if (update) - await _context.SaveChangesAsync(); + await context.SaveChangesAsync(); return new RServiceResult(scores.ToArray());