#266 user upvoted recitations list
This commit is contained in:
parent
671f5cbf6f
commit
08cfd79200
69
GanjooRazor/Areas/User/Pages/UpVotedRecitations.cshtml
Normal file
69
GanjooRazor/Areas/User/Pages/UpVotedRecitations.cshtml
Normal file
@ -0,0 +1,69 @@
|
||||
@page
|
||||
@model GanjooRazor.Areas.User.Pages.UpVotedRecitationsModel
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
ViewData["Title"] = "خوانشهای نشان شده";
|
||||
await GanjooRazor.Utils.GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData);
|
||||
string color = "gray";
|
||||
}
|
||||
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
@if (Model.LastError != "")
|
||||
{
|
||||
<h2>@Model.LastError</h2>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p style="text-align:center">
|
||||
@foreach (var paginationLink in Model.PaginationLinks)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(paginationLink.Url))
|
||||
{
|
||||
<a href="@paginationLink.Url">@paginationLink.Name</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
@paginationLink.Name
|
||||
}
|
||||
}
|
||||
</p>
|
||||
|
||||
@foreach (var upvote in Model.UpVotes)
|
||||
{
|
||||
if (color == "gray")
|
||||
color = "white";
|
||||
else
|
||||
color = "gray";
|
||||
|
||||
<div style="background-color:@color" id="bookmark-@upvote.Id">
|
||||
<blockquote>
|
||||
<p>
|
||||
@upvote.AudioTitle به خوانش @upvote.AudioArtist (<a href="@Html.Raw(upvote.PoemFullUrl)" target="_blank">@upvote.PoemFullTitle</a>)
|
||||
</p>
|
||||
<a href="@($"http://ava.ganjoor.net/#/{upvote.Id}")" target="_blank">
|
||||
پیوند به خوانش
|
||||
</a>
|
||||
</blockquote>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<hr />
|
||||
}
|
||||
|
||||
<p style="text-align:center">
|
||||
@foreach (var paginationLink in Model.PaginationLinks)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(paginationLink.Url))
|
||||
{
|
||||
<a href="@paginationLink.Url">@paginationLink.Name</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
@paginationLink.Name
|
||||
}
|
||||
}
|
||||
</p>
|
||||
|
||||
|
||||
}
|
||||
132
GanjooRazor/Areas/User/Pages/UpVotedRecitations.cshtml.cs
Normal file
132
GanjooRazor/Areas/User/Pages/UpVotedRecitations.cshtml.cs
Normal file
@ -0,0 +1,132 @@
|
||||
using DNTPersianUtils.Core;
|
||||
using GanjooRazor.Utils;
|
||||
using GSpotifyProxy.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RMuseum.Models.GanjoorAudio.ViewModels;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GanjooRazor.Areas.User.Pages
|
||||
{
|
||||
[IgnoreAntiforgeryToken(Order = 1001)]
|
||||
public class UpVotedRecitationsModel : PageModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Last Error
|
||||
/// </summary>
|
||||
public string LastError { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// pagination links
|
||||
/// </summary>
|
||||
public List<NameIdUrlImage> PaginationLinks { get; set; }
|
||||
|
||||
public List<PublicRecitationViewModel> UpVotes { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
LastError = "";
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
{
|
||||
int pageNumber = 1;
|
||||
if (!string.IsNullOrEmpty(Request.Query["page"]))
|
||||
{
|
||||
pageNumber = int.Parse(Request.Query["page"]);
|
||||
}
|
||||
var response = await secureClient.GetAsync($"{APIRoot.Url}/api/audio/votes/?PageNumber={pageNumber}&PageSize=20");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
|
||||
UpVotes = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject<List<PublicRecitationViewModel>>();
|
||||
|
||||
string paginnationMetadata = response.Headers.GetValues("paging-headers").FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(paginnationMetadata))
|
||||
{
|
||||
PaginationMetadata paginationMetadata = JsonConvert.DeserializeObject<PaginationMetadata>(paginnationMetadata);
|
||||
PaginationLinks = new List<NameIdUrlImage>();
|
||||
if (paginationMetadata.totalPages > 1)
|
||||
{
|
||||
if (paginationMetadata.currentPage > 3)
|
||||
{
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "صفحهٔ اول",
|
||||
Url = "/User/UpVotedRecitations/?page=1"
|
||||
}
|
||||
);
|
||||
}
|
||||
for (int i = (paginationMetadata.currentPage - 2); i <= (paginationMetadata.currentPage + 2); i++)
|
||||
{
|
||||
if (i >= 1 && i <= paginationMetadata.totalPages)
|
||||
{
|
||||
if (i == paginationMetadata.currentPage)
|
||||
{
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = i.ToPersianNumbers(),
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = i.ToPersianNumbers(),
|
||||
Url = $"/User/UpVotedRecitations/?page={i}"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (paginationMetadata.totalPages > (paginationMetadata.currentPage + 2))
|
||||
{
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "... ",
|
||||
}
|
||||
);
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "صفحهٔ آخر",
|
||||
Url = $"/User/UpVotedRecitations/?page={paginationMetadata.totalPages}"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -356,6 +356,10 @@
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/Edits">ویرایشهای من</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/UpVotedRecitations">خوانشهای نشان شده</a>
|
||||
</li>
|
||||
|
||||
@if (ViewData.ContainsKey("ganjoor-songrevu"))
|
||||
{
|
||||
<li class="nav-item">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user