#165 download poet sqlite database from UI

This commit is contained in:
Hamid Reza Mohammadi 2021-06-28 20:05:58 +04:30
parent 42465d484a
commit dc58904e6c
2 changed files with 24 additions and 1 deletions

View File

@ -100,7 +100,13 @@
<table>
<tr>
<a role="button" href="/Admin/PoetDel/?id=@Model.Poet.Id" class="actionlink">حذف شاعر</a>
<td><a role="button" href="/Admin/Poet/?Handler=DownloadSqliteDb&id=@Model.Poet.Id" class="actionlink">sqlite</a></td>
</tr>
</table>
<table>
<tr>
<td><a role="button" href="/Admin/PoetDel/?id=@Model.Poet.Id" class="actionlink">حذف شاعر</a></td>
</tr>
</table>

View File

@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Caching.Memory;
using Newtonsoft.Json;
using RMuseum.Models.Ganjoor.ViewModels;
using RMuseum.Services.Implementation.ImportedFromDesktopGanjoor;
namespace GanjooRazor.Areas.Admin.Pages
{
@ -234,5 +235,21 @@ namespace GanjooRazor.Areas.Admin.Pages
return Page();
}
public async Task<IActionResult> OnGetDownloadSqliteDbAsync(int id)
{
using (HttpClient secureClient = new HttpClient())
{
LastResult = "";
await PreparePoet();
await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response);
var content = await secureClient.GetStreamAsync($"{APIRoot.Url}/api/ganjoor/sqlite/export/{id}");
var contentType = "Application/octet-stream";
var fileName = $"{GPersianTextSync.Farglisize(Poet.Name)}.gdb";
return File(content, contentType, fileName);
}
}
}
}