49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using RMuseum.Models.Auth.Memory;
|
|
using RMuseum.Services;
|
|
using RSecurityBackend.Models.Generic;
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace RMuseum.Controllers
|
|
{
|
|
[Produces("application/json")]
|
|
[Route("api/ganjoor")]
|
|
public class GanjoorController : Controller
|
|
{
|
|
/// <summary>
|
|
/// imports data from ganjoor SQLite database
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("sqliteimport")]
|
|
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + RMuseumSecurableItem.ImportOperationShortName)]
|
|
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(bool))]
|
|
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
|
public async Task<IActionResult> ImportLocalSQLiteDb()
|
|
{
|
|
RServiceResult<bool> res =
|
|
await _ganjoorService.ImportLocalSQLiteDb();
|
|
if (res.Result)
|
|
return Ok();
|
|
return BadRequest(res.ExceptionString);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ganjoor Service
|
|
/// </summary>
|
|
|
|
protected readonly IGanjoorService _ganjoorService;
|
|
|
|
/// <summary>
|
|
/// constructor
|
|
/// </summary>
|
|
/// <param name="ganjoorService"></param>
|
|
public GanjoorController(IGanjoorService ganjoorService)
|
|
{
|
|
_ganjoorService = ganjoorService;
|
|
}
|
|
}
|
|
}
|