#438 refactoring

This commit is contained in:
Hamid Reza Mohammadi 2024-05-10 09:44:44 +03:30
parent 5e5b48a746
commit 113544145c
3 changed files with 39 additions and 21 deletions

View File

@ -17849,6 +17849,9 @@
<summary>
IGanjoorService implementation
</summary>
<summary>
IGanjoorService implementation
</summary>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.SwitchCoupletBookmark(System.Guid,System.Int32,System.Int32)">
<summary>

View File

@ -19,7 +19,6 @@ using RSecurityBackend.Models.Generic.Db;
using RMuseum.Models.PDFLibrary;
using DNTPersianUtils.Core;
using System.Collections.Generic;
using RMuseum.Migrations;
namespace RMuseum.Services.Implementation
{
@ -622,25 +621,5 @@ namespace RMuseum.Services.Implementation
return new RServiceResult<int>(0, exp.ToString());
}
}
/// <summary>
/// category paper sources
/// </summary>
/// <param name="categoryId"></param>
/// <returns></returns>
public async Task<RServiceResult<GanjoorPaperSource[]>> GetCategoryPaperSourcesAsync(int categoryId)
{
try
{
return new RServiceResult<GanjoorPaperSource[]>
(
await _context.GanjoorPaperSources.AsNoTracking().Where(p => p.GanjoorCatId == categoryId).OrderByDescending(c => c.IsTextOriginalSource).OrderBy(c => c.OrderIndicator).ThenBy(c => c.Id).ToArrayAsync()
);
}
catch (Exception exp)
{
return new RServiceResult<GanjoorPaperSource[]>(null, exp.ToString());
}
}
}
}

View File

@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore;
using RSecurityBackend.Models.Generic;
using System;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using RMuseum.Models.GanjoorIntegration;
namespace RMuseum.Services.Implementation
{
/// <summary>
/// IGanjoorService implementation
/// </summary>
public partial class GanjoorService : IGanjoorService
{
/// <summary>
/// category paper sources
/// </summary>
/// <param name="categoryId"></param>
/// <returns></returns>
public async Task<RServiceResult<GanjoorPaperSource[]>> GetCategoryPaperSourcesAsync(int categoryId)
{
try
{
return new RServiceResult<GanjoorPaperSource[]>
(
await _context.GanjoorPaperSources.AsNoTracking().Where(p => p.GanjoorCatId == categoryId).OrderByDescending(c => c.IsTextOriginalSource).OrderBy(c => c.OrderIndicator).ThenBy(c => c.Id).ToArrayAsync()
);
}
catch (Exception exp)
{
return new RServiceResult<GanjoorPaperSource[]>(null, exp.ToString());
}
}
}
}