docs: #275 editing suggested photos metadata UI
This commit is contained in:
parent
712b1ceef4
commit
e2dce92d9d
@ -2,8 +2,10 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
@ -52,30 +54,57 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
var suggestionResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/poetphotos/unpublished/next?skip={Skip}");
|
||||
if (!suggestionResponse.IsSuccessStatusCode)
|
||||
|
||||
if(!string.IsNullOrEmpty(Request.Query["id"]) && !string.IsNullOrEmpty(Request.Query["id"]))
|
||||
{
|
||||
if (suggestionResponse.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
//modify mode:
|
||||
int id = int.Parse(Request.Query["id"]);
|
||||
int poetId = int.Parse(Request.Query["poetId"]);
|
||||
|
||||
var responsePhotos = await secureClient.GetAsync($"{APIRoot.Url}/api/poetphotos/poet/{poetId}");
|
||||
if (!responsePhotos.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = "پیشنهادی وجود ندارد.";
|
||||
LastError = JsonConvert.DeserializeObject<string>(await responsePhotos.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
else
|
||||
var photos = JArray.Parse(await responsePhotos.Content.ReadAsStringAsync()).ToObject<List<GanjoorPoetSuggestedPictureViewModel>>();
|
||||
|
||||
Suggestion = photos.Where(p => p.Id == id).FirstOrDefault();
|
||||
if (Suggestion == null)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await suggestionResponse.Content.ReadAsStringAsync());
|
||||
LastError = "تصویری با شناسهٔ ارسالی یافت نشد.";
|
||||
return Page();
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
else
|
||||
{
|
||||
string paginnationMetadata = suggestionResponse.Headers.GetValues("paging-headers").FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(paginnationMetadata))
|
||||
//moderate mode
|
||||
var suggestionResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/poetphotos/unpublished/next?skip={Skip}");
|
||||
if (!suggestionResponse.IsSuccessStatusCode)
|
||||
{
|
||||
TotalCount = JsonConvert.DeserializeObject<PaginationMetadata>(paginnationMetadata).totalCount;
|
||||
if (suggestionResponse.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
{
|
||||
LastError = "پیشنهادی وجود ندارد.";
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await suggestionResponse.Content.ReadAsStringAsync());
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
else
|
||||
{
|
||||
string paginnationMetadata = suggestionResponse.Headers.GetValues("paging-headers").FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(paginnationMetadata))
|
||||
{
|
||||
TotalCount = JsonConvert.DeserializeObject<PaginationMetadata>(paginnationMetadata).totalCount;
|
||||
}
|
||||
Suggestion = JsonConvert.DeserializeObject<GanjoorPoetSuggestedPictureViewModel>(await suggestionResponse.Content.ReadAsStringAsync());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Suggestion = JsonConvert.DeserializeObject<GanjoorPoetSuggestedPictureViewModel>(await suggestionResponse.Content.ReadAsStringAsync());
|
||||
|
||||
if (Suggestion != null)
|
||||
{
|
||||
Suggestion.ImageUrl = $"{APIRoot.InternetUrl}/{Suggestion.ImageUrl}";
|
||||
|
||||
var response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poet/{Suggestion.PoetId}");
|
||||
|
||||
@ -279,6 +279,7 @@
|
||||
{
|
||||
<div class="clear-both">
|
||||
<a role="button" onclick="choosePhoto(@photo.PoetId, @photo.Id)" class="pagebutton" title="انتخاب شده"><i class="noindent-info-button done-icon"></i></a>
|
||||
<a role="button" href="/User/SuggestedPoetPhotos?id=@photo.Id&poetId=@photo.PoetId" class="pagebutton" title="ویرایش"><i class="noindent-info-button edit-poem-button"></i></a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@ -220,7 +220,7 @@ namespace GanjooRazor.Pages
|
||||
if (!responsePhotos.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await responsePhotos.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
return new BadRequestObjectResult(LastError);
|
||||
}
|
||||
var photos = JArray.Parse(await responsePhotos.Content.ReadAsStringAsync()).ToObject<List<GanjoorPoetSuggestedPictureViewModel>>();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user