#144 cat utils page
This commit is contained in:
parent
64b111f094
commit
c907e8a0d4
32
GanjooRazor/Areas/Admin/Pages/CatUtils.cshtml
Normal file
32
GanjooRazor/Areas/Admin/Pages/CatUtils.cshtml
Normal file
@ -0,0 +1,32 @@
|
||||
@page
|
||||
@model GanjooRazor.Areas.Admin.Pages.CatUtilsModel
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@{
|
||||
Layout = "_AdminLayout";
|
||||
ViewData["Title"] = "مدیریت بخش";
|
||||
}
|
||||
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.LastMessage))
|
||||
{
|
||||
<p>
|
||||
@Model.LastMessage
|
||||
</p>
|
||||
}
|
||||
|
||||
|
||||
<table>
|
||||
@foreach (var poem in Model.Cat.Cat.Poems)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/Admin/ModifyPage?id=@poem.Id">@poem.Title</a>
|
||||
</td>
|
||||
<td>
|
||||
@poem.Excerpt
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
|
||||
67
GanjooRazor/Areas/Admin/Pages/CatUtils.cshtml.cs
Normal file
67
GanjooRazor/Areas/Admin/Pages/CatUtils.cshtml.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Newtonsoft.Json;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
|
||||
namespace GanjooRazor.Areas.Admin.Pages
|
||||
{
|
||||
public class CatUtilsModel : PageModel
|
||||
{
|
||||
// <summary>
|
||||
/// HttpClient instance
|
||||
/// </summary>
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
/// <summary>
|
||||
/// memory cache
|
||||
/// </summary>
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="httpClient"></param>
|
||||
/// <param name="memoryCache"></param>
|
||||
public CatUtilsModel(HttpClient httpClient, IMemoryCache memoryCache)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_memoryCache = memoryCache;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// category
|
||||
/// </summary>
|
||||
public GanjoorPoetCompleteViewModel Cat { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// last message
|
||||
/// </summary>
|
||||
public string LastMessage { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
LastMessage = Request.Query["edit"] == "true" ? "ویرایش انجام شد." : "";
|
||||
if (string.IsNullOrEmpty(Request.Query["url"]))
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "نشانی صفحه مشخص نیست.");
|
||||
}
|
||||
|
||||
var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/cat?url={Request.Query["url"]}&poems=true");
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
Cat = JsonConvert.DeserializeObject<GanjoorPoetCompleteViewModel>(await response.Content.ReadAsStringAsync());
|
||||
|
||||
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -121,5 +121,11 @@
|
||||
<a href="/Admin/PageHistory?id=@Request.Query["id"]">سوابق</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<a role="button" href="/Admin/CatUtils?url=@Model.PageInformation.FullUrl" class="actionlink">مدیریت بخش متناظر</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
@ -44,6 +44,11 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
/// </summary>
|
||||
public GanjoorMetre[] Rhythms { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// page
|
||||
/// </summary>
|
||||
public GanjoorPageCompleteViewModel PageInformation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// last message
|
||||
/// </summary>
|
||||
@ -79,20 +84,20 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, await pageQuery.Content.ReadAsStringAsync());
|
||||
}
|
||||
GanjoorPageCompleteViewModel page = JObject.Parse(await pageQuery.Content.ReadAsStringAsync()).ToObject<GanjoorPageCompleteViewModel>();
|
||||
PageInformation = JObject.Parse(await pageQuery.Content.ReadAsStringAsync()).ToObject<GanjoorPageCompleteViewModel>();
|
||||
|
||||
ModifyModel = new GanjoorModifyPageViewModel()
|
||||
{
|
||||
Title = page.Title,
|
||||
UrlSlug = page.UrlSlug,
|
||||
HtmlText = page.HtmlText,
|
||||
Title = PageInformation.Title,
|
||||
UrlSlug = PageInformation.UrlSlug,
|
||||
HtmlText = PageInformation.HtmlText,
|
||||
Note = "",
|
||||
SourceName = page.Poem == null ? null : page.Poem.SourceName,
|
||||
SourceUrlSlug = page.Poem == null ? null : page.Poem.SourceUrlSlug,
|
||||
OldTag = page.Poem == null ? null : page.Poem.OldTag,
|
||||
OldTagPageUrl = page.Poem == null ? null : page.Poem.OldTagPageUrl,
|
||||
RhymeLetters = page.Poem == null ? null : page.Poem.RhymeLetters,
|
||||
Rhythm = page.Poem == null ? null : page.Poem.GanjoorMetre == null ? null : page.Poem.GanjoorMetre.Rhythm
|
||||
SourceName = PageInformation.Poem == null ? null : PageInformation.Poem.SourceName,
|
||||
SourceUrlSlug = PageInformation.Poem == null ? null : PageInformation.Poem.SourceUrlSlug,
|
||||
OldTag = PageInformation.Poem == null ? null : PageInformation.Poem.OldTag,
|
||||
OldTagPageUrl = PageInformation.Poem == null ? null : PageInformation.Poem.OldTagPageUrl,
|
||||
RhymeLetters = PageInformation.Poem == null ? null : PageInformation.Poem.RhymeLetters,
|
||||
Rhythm = PageInformation.Poem == null ? null : PageInformation.Poem.GanjoorMetre == null ? null : PageInformation.Poem.GanjoorMetre.Rhythm
|
||||
};
|
||||
|
||||
return Page();
|
||||
|
||||
@ -353,7 +353,7 @@ namespace RMuseum.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// cat by url
|
||||
/// cat by full url
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="poems"></param>
|
||||
|
||||
@ -749,7 +749,7 @@
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetCatByUrl(System.String,System.Boolean)">
|
||||
<summary>
|
||||
cat by url
|
||||
cat by full url
|
||||
</summary>
|
||||
<param name="url"></param>
|
||||
<param name="poems"></param>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user