From 4b6f57b3afdb8bf9301646a0fb536acdcd9a5dd1 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Tue, 18 May 2021 10:59:48 +0430 Subject: [PATCH] updating cache when a new recitation is published ot and existing one is modified or deleted --- RMuseum/RMuseum.xml | 8 +++++++- .../Implementation/RecitationService.cs | 20 ++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 5659830a..b62482be 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -8506,7 +8506,12 @@ memory cache - + + + ganjoor service + + + constructor @@ -8516,6 +8521,7 @@ + diff --git a/RMuseum/Services/Implementation/RecitationService.cs b/RMuseum/Services/Implementation/RecitationService.cs index 5e12e70f..ca2f4ee7 100644 --- a/RMuseum/Services/Implementation/RecitationService.cs +++ b/RMuseum/Services/Implementation/RecitationService.cs @@ -249,6 +249,8 @@ namespace RMuseum.Services.Implementationa $"خوانش ارسالی {audioTitle} حذف شد.{Environment.NewLine}" + $"می‌توانید با مراجعه به این صفحه وضعیت آن را بررسی کنید." ); + + await _ganjoorService.CacheCleanForPageById(GanjoorPostId); } else { @@ -459,6 +461,8 @@ namespace RMuseum.Services.Implementationa await UpdateRecitation(narration, true); + await _ganjoorService.CacheCleanForPageById(narration.GanjoorPostId); + } return new RServiceResult(new RecitationViewModel(narration, narration.Owner, await _context.GanjoorPoems.Where(p => p.Id == narration.GanjoorPostId).SingleOrDefaultAsync())); } @@ -1077,6 +1081,9 @@ namespace RMuseum.Services.Implementationa $"خوانش ارسالی {narration.AudioTitle} منتشر شد.{Environment.NewLine}" + $"می‌توانید با مراجعه به این صفحه وضعیت آن را بررسی کنید." ); + + + await _ganjoorService.CacheCleanForPageById(narration.GanjoorPostId); } return new RServiceResult(new RecitationViewModel(narration, narration.Owner, await _context.GanjoorPoems.Where(p => p.Id == narration.GanjoorPostId).SingleOrDefaultAsync())); @@ -1742,6 +1749,8 @@ namespace RMuseum.Services.Implementationa await UpdateRecitation(other, false /* owner of this recitation did nothing to expect any notifications*/); + + await _ganjoorService.CacheCleanForPageById(other.GanjoorPostId); } recitation.AudioOrder = 1; @@ -1749,6 +1758,8 @@ namespace RMuseum.Services.Implementationa _context.Recitations.Update(recitation); await UpdateRecitation(recitation, true); + + await _ganjoorService.CacheCleanForPageById(recitation.GanjoorPostId); } @@ -1838,6 +1849,11 @@ namespace RMuseum.Services.Implementationa /// private readonly IMemoryCache _memoryCache; + /// + /// ganjoor service + /// + private readonly IGanjoorService _ganjoorService; + /// /// constructor @@ -1848,7 +1864,8 @@ namespace RMuseum.Services.Implementationa /// /// /// - public RecitationService(RMuseumDbContext context, IConfiguration configuration, IBackgroundTaskQueue backgroundTaskQueue, IRNotificationService notificationService, IAppUserService userService, IMemoryCache memoryCache) + /// + public RecitationService(RMuseumDbContext context, IConfiguration configuration, IBackgroundTaskQueue backgroundTaskQueue, IRNotificationService notificationService, IAppUserService userService, IMemoryCache memoryCache, IGanjoorService ganjoorService) { _context = context; Configuration = configuration; @@ -1856,6 +1873,7 @@ namespace RMuseum.Services.Implementationa _notificationService = notificationService; _userService = userService; _memoryCache = memoryCache; + _ganjoorService = ganjoorService; } } }