#401 StartImportingKnownSourceAsync
This commit is contained in:
parent
a66ec0f8c6
commit
0d6731ed0b
@ -251,6 +251,23 @@ namespace RMuseum.Controllers
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
}
|
||||
/// <summary>
|
||||
/// import from known sources
|
||||
/// </summary>
|
||||
/// <param name="srcUrl"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpPost("import")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.PDFLibraryEntityShortName + ":" + SecurableItem.AddOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> StartImportingKnownSourceAsync([FromBody]string srcUrl)
|
||||
{
|
||||
var res = await _pdfService.StartImportingKnownSourceAsync(srcUrl);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -12,6 +12,12 @@ namespace RMuseum.Services
|
||||
/// </summary>
|
||||
public interface IPDFLibraryService
|
||||
{
|
||||
/// <summary>
|
||||
/// import from known sources
|
||||
/// </summary>
|
||||
/// <param name="srcUrl"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> StartImportingKnownSourceAsync(string srcUrl);
|
||||
/// <summary>
|
||||
/// get pdf book by id
|
||||
/// </summary>
|
||||
|
||||
@ -15,14 +15,13 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Security.Policy;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
namespace RMuseum.Services.Implementation
|
||||
{
|
||||
public partial class PDFLibraryService
|
||||
{
|
||||
public async Task<RServiceResult<bool>> StartImportingSohaLibraryUrlAsync(string srcUrl)
|
||||
private async Task<RServiceResult<bool>> StartImportingSohaLibraryUrlAsync(string srcUrl)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@ -23,6 +23,20 @@ namespace RMuseum.Services.Implementation
|
||||
/// </summary>
|
||||
public partial class PDFLibraryService : IPDFLibraryService
|
||||
{
|
||||
/// <summary>
|
||||
/// import from known sources
|
||||
/// </summary>
|
||||
/// <param name="srcUrl"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> StartImportingKnownSourceAsync(string srcUrl)
|
||||
{
|
||||
if(srcUrl.Contains("https://sohalibrary.com/"))
|
||||
{
|
||||
return await StartImportingSohaLibraryUrlAsync(srcUrl);
|
||||
}
|
||||
return new RServiceResult<bool>(false, "Unknown source url");
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// get pdf book by id
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user