fixes for song approval (updating cache)

This commit is contained in:
Hamid Reza Mohammadi 2021-05-16 10:45:43 +04:30
parent d71fc54de5
commit 20df0c595b
3 changed files with 46 additions and 0 deletions

View File

@ -6,11 +6,25 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Newtonsoft.Json;
using RMuseum.Models.Ganjoor.ViewModels;
using RMuseum.Services;
namespace GanjooRazor.Areas.User.Pages
{
public class AddSongModel : PageModel
{
/// ganjoor service
/// </summary>
private readonly IGanjoorService _ganjoorService;
/// <summary>
/// constructor
/// </summary>
/// <param name="ganjoorService"></param>
public AddSongModel(IGanjoorService ganjoorService)
{
_ganjoorService = ganjoorService;
}
/// <summary>
/// Last Error
/// </summary>
@ -57,6 +71,10 @@ namespace GanjooRazor.Areas.User.Pages
{
LastError = await putResponse.Content.ReadAsStringAsync();
}
else
{
await _ganjoorService.CacheCleanForPageById(PoemMusicTrackViewModel.PoemId);
}
}
else
{

View File

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Newtonsoft.Json;
using RMuseum.Models.Ganjoor.ViewModels;
using RMuseum.Services;
using RSecurityBackend.Models.Generic;
using System.Linq;
using System.Net.Http;
@ -14,6 +15,19 @@ namespace GanjooRazor.Areas.User.Pages
{
public class ReviewSongsModel : PageModel
{
/// <summary>
/// ganjoor service
/// </summary>
private readonly IGanjoorService _ganjoorService;
/// <summary>
/// constructor
/// </summary>
/// <param name="ganjoorService"></param>
public ReviewSongsModel(IGanjoorService ganjoorService)
{
_ganjoorService = ganjoorService;
}
/// <summary>
/// Last Error
/// </summary>
@ -130,6 +144,13 @@ namespace GanjooRazor.Areas.User.Pages
{
LastError = await putResponse.Content.ReadAsStringAsync();
}
else
{
if(PoemMusicTrackViewModel.Approved)
{
await _ganjoorService.CacheCleanForPageById(PoemMusicTrackViewModel.PoemId);
}
}
}
else
{

View File

@ -1586,6 +1586,11 @@ namespace RMuseum.Services.Implementation
await _context.SaveChangesAsync();
if(track.Approved)
{
await CacheCleanForPageById(track.PoemId);
}
return new RServiceResult<PoemMusicTrackViewModel>(song);
}
catch (Exception exp)
@ -1665,6 +1670,8 @@ namespace RMuseum.Services.Implementation
_context.GanjoorPoemMusicTracks.Update(track);
await _context.SaveChangesAsync();
await CacheCleanForPageById(track.PoemId);
return new RServiceResult<PoemMusicTrackViewModel>(song);
}
catch (Exception exp)