#400 fixes and improvements

This commit is contained in:
Hamid Reza Mohammadi 2023-07-25 17:27:40 +03:30
parent dd43dbf50d
commit 6ec98fa5d9
4 changed files with 170 additions and 7 deletions

View File

@ -884,9 +884,9 @@ namespace RMuseum.Controllers
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<PDFBook>))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
public async Task<IActionResult> GetBookRelatedPFFBooksAsync([FromQuery] PagingParameterModel paging, int bookId)
public async Task<IActionResult> GetBookRelatedPDFBooksAsync([FromQuery] PagingParameterModel paging, int bookId)
{
var res = await _pdfService.GetBookRelatedPFFBooksAsync(paging, bookId);
var res = await _pdfService.GetBookRelatedPDFBooksAsync(paging, bookId);
if (!string.IsNullOrEmpty(res.ExceptionString))
{
return BadRequest(res.ExceptionString);

View File

@ -2566,7 +2566,7 @@
<param name="authorId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.PDFLibraryController.GetBookRelatedPFFBooksAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.Int32)">
<member name="M:RMuseum.Controllers.PDFLibraryController.GetBookRelatedPDFBooksAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.Int32)">
<summary>
get book related pdf books
</summary>
@ -18000,7 +18000,7 @@
<param name="authorId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.GetBookRelatedPFFBooksAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.Int32)">
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.GetBookRelatedPDFBooksAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.Int32)">
<summary>
get book related pdf books
</summary>
@ -18043,6 +18043,48 @@
<param name="volumeId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.GetPDFSourceByIdAsync(System.Int32)">
<summary>
get pdf source by id
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.GetPDFSourcesAsync">
<summary>
Get All PDF Sources
</summary>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.AddPDFSourceAsync(RMuseum.Models.PDFLibrary.PDFSource)">
<summary>
Add PDF Source
</summary>
<param name="source"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.UpdatePDFSourceAsync(RMuseum.Models.PDFLibrary.PDFSource)">
<summary>
update PDF Source
</summary>
<param name="model"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.DeletePDFSourceAsync(System.Int32)">
<summary>
delete PDF Source
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.GetSourceRelatedPDFBooksAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.Int32)">
<summary>
get source pdf books
</summary>
<param name="paging"></param>
<param name="sourceId"></param>
<returns></returns>
</member>
<member name="F:RMuseum.Services.Implementation.PDFLibraryService._context">
<summary>
Database Context
@ -19040,7 +19082,7 @@
<param name="authorId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IPDFLibraryService.GetBookRelatedPFFBooksAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.Int32)">
<member name="M:RMuseum.Services.IPDFLibraryService.GetBookRelatedPDFBooksAsync(RSecurityBackend.Models.Generic.PagingParameterModel,System.Int32)">
<summary>
get book related pdf books
</summary>

View File

@ -214,7 +214,7 @@ namespace RMuseum.Services
/// <param name="paging"></param>
/// <param name="bookId"></param>
/// <returns></returns>
Task<RServiceResult<(PaginationMetadata PagingMeta, PDFBook[] Books)>> GetBookRelatedPFFBooksAsync(PagingParameterModel paging, int bookId);
Task<RServiceResult<(PaginationMetadata PagingMeta, PDFBook[] Books)>> GetBookRelatedPDFBooksAsync(PagingParameterModel paging, int bookId);
/// <summary>
/// add multi volume pdf collection

View File

@ -1144,7 +1144,7 @@ namespace RMuseum.Services.Implementation
/// <param name="paging"></param>
/// <param name="bookId"></param>
/// <returns></returns>
public async Task<RServiceResult<(PaginationMetadata PagingMeta, PDFBook[] Books)>> GetBookRelatedPFFBooksAsync(PagingParameterModel paging, int bookId)
public async Task<RServiceResult<(PaginationMetadata PagingMeta, PDFBook[] Books)>> GetBookRelatedPDFBooksAsync(PagingParameterModel paging, int bookId)
{
try
{
@ -1277,6 +1277,127 @@ namespace RMuseum.Services.Implementation
}
}
/// <summary>
/// get pdf source by id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<RServiceResult<PDFSource>> GetPDFSourceByIdAsync(int id)
{
try
{
return new RServiceResult<PDFSource>(await _context.PDFSources.AsNoTracking().Where(s => s.Id == id).SingleOrDefaultAsync());
}
catch (Exception exp)
{
return new RServiceResult<PDFSource>(null, exp.ToString());
}
}
/// <summary>
/// Get All PDF Sources
/// </summary>
/// <returns></returns>
public async Task<RServiceResult<PDFSource[]>> GetPDFSourcesAsync()
{
try
{
return new RServiceResult<PDFSource[]>(await _context.PDFSources.AsNoTracking().ToArrayAsync());
}
catch (Exception exp)
{
return new RServiceResult<PDFSource[]>(null, exp.ToString());
}
}
/// <summary>
/// Add PDF Source
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public async Task<RServiceResult<PDFSource>> AddPDFSourceAsync(PDFSource source)
{
try
{
_context.PDFSources.Add(source);
await _context.SaveChangesAsync();
return new RServiceResult<PDFSource>(source);
}
catch (Exception exp)
{
return new RServiceResult<PDFSource>(null, exp.ToString());
}
}
/// <summary>
/// update PDF Source
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public async Task<RServiceResult<PDFSource>> UpdatePDFSourceAsync(PDFSource model)
{
try
{
var dbSource = await _context.PDFSources.Where(s => s.Id == model.Id).SingleAsync();
dbSource.Name = model.Name;
dbSource.Description = model.Description;
dbSource.Url = model.Url;
_context.Update(dbSource);
await _context.SaveChangesAsync();
return new RServiceResult<PDFSource>(dbSource);
}
catch (Exception exp)
{
return new RServiceResult<PDFSource>(null, exp.ToString());
}
}
/// <summary>
/// delete PDF Source
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<RServiceResult<bool>> DeletePDFSourceAsync(int id)
{
try
{
var dbSource = await _context.PDFSources.Where(s => s.Id == id).SingleAsync();
_context.Remove(dbSource);
await _context.SaveChangesAsync();
return new RServiceResult<bool>(true);
}
catch (Exception exp)
{
return new RServiceResult<bool>(false, exp.ToString());
}
}
/// <summary>
/// get source pdf books
/// </summary>
/// <param name="paging"></param>
/// <param name="sourceId"></param>
/// <returns></returns>
public async Task<RServiceResult<(PaginationMetadata PagingMeta, PDFBook[] Books)>> GetSourceRelatedPDFBooksAsync(PagingParameterModel paging, int sourceId)
{
try
{
var source =
_context.PDFBooks.AsNoTracking()
.Include(a => a.CoverImage)
.Where(a => a.Status == PublishStatus.Published && a.PDFSourceId == sourceId)
.OrderByDescending(t => t.Title)
.AsQueryable();
(PaginationMetadata PagingMeta, PDFBook[] Books) paginatedResult =
await QueryablePaginator<PDFBook>.Paginate(source, paging);
return new RServiceResult<(PaginationMetadata PagingMeta, PDFBook[] Books)>(paginatedResult);
}
catch (Exception exp)
{
return new RServiceResult<(PaginationMetadata PagingMeta, PDFBook[] Books)>((null, null), exp.ToString());
}
}
/// <summary>
/// Database Context
/// </summary>