#123 finalized
This commit is contained in:
parent
3b45a81873
commit
0e1af6b578
@ -13,12 +13,43 @@
|
||||
<h2>@Model.LastError</h2>
|
||||
}
|
||||
|
||||
|
||||
|
||||
@if (Model.MainImage != null)
|
||||
{
|
||||
<img src="https://ganjgah.ir/api/images/thumb/@(Model.MainImage.EntityImageId).jpg" />
|
||||
}
|
||||
|
||||
@if (Model.PreviouslyLinkedImage != null)
|
||||
{
|
||||
<img src="https://ganjgah.ir/api/images/thumb/@(Model.PreviouslyLinkedImage.EntityImageId).jpg" />
|
||||
}
|
||||
<table style="width:100%" class="noborder">
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<a href="@Model.MainImage.GanjoorUrl" target="_blank">@Model.MainImage.GanjoorTitle</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="https://ganjgah.ir/api/images/thumb/@(Model.MainImage.EntityImageId).jpg" />
|
||||
</td>
|
||||
<td>
|
||||
@if (Model.PreviouslyLinkedImage != null)
|
||||
{
|
||||
<img src="https://ganjgah.ir/api/images/thumb/@(Model.PreviouslyLinkedImage.EntityImageId).jpg" />
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<form method="post">
|
||||
<input type="hidden" asp-for="ImageLinkFinalizeModel.Id" />
|
||||
<input asp-for="ImageLinkFinalizeModel.DisplayOnPage" />
|
||||
<button type="submit" name="approve" id="approve" style="width:100%;color:white;background-color:green">تأیید</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
تعداد کل:
|
||||
</td>
|
||||
<td>
|
||||
@Model.TotalCount
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using GanjooRazor.Models.MuseumLink;
|
||||
using GanjooRazor.Utils;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
@ -32,6 +33,9 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
|
||||
public GanjoorLinkViewModel PreviouslyLinkedImage { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public ImageLinkFinalizeModel ImageLinkFinalizeModel { get; set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
LastError = "";
|
||||
@ -60,8 +64,14 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
if(images != null)
|
||||
{
|
||||
if(images.Length >= 1)
|
||||
{
|
||||
{
|
||||
MainImage = images[0];
|
||||
|
||||
ImageLinkFinalizeModel = new ImageLinkFinalizeModel()
|
||||
{
|
||||
Id = MainImage.Id,
|
||||
DisplayOnPage = false
|
||||
};
|
||||
}
|
||||
|
||||
if (images.Length >= 2)
|
||||
@ -79,5 +89,32 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
LastError = "";
|
||||
Skip = string.IsNullOrEmpty(Request.Query["skip"]) ? 0 : int.Parse(Request.Query["skip"]);
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
var imageResponse = await secureClient.PutAsync($"{APIRoot.Url}/api/artifacts/ganjoor/sync/{ImageLinkFinalizeModel.Id}/{ImageLinkFinalizeModel.DisplayOnPage}", null);
|
||||
if (!imageResponse.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = await imageResponse.Content.ReadAsStringAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Redirect($"/User/FinalizeImages/?skip={Skip}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
|
||||
}
|
||||
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
20
GanjooRazor/Models/MuseumLink/ImageLinkFinalizeModel.cs
Normal file
20
GanjooRazor/Models/MuseumLink/ImageLinkFinalizeModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace GanjooRazor.Models.MuseumLink
|
||||
{
|
||||
/// <summary>
|
||||
/// image link finalize model
|
||||
/// </summary>
|
||||
public class ImageLinkFinalizeModel
|
||||
{
|
||||
/// <summary>
|
||||
/// link id
|
||||
/// </summary>
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// display on page
|
||||
/// </summary>
|
||||
public bool DisplayOnPage { get; set; }
|
||||
}
|
||||
}
|
||||
@ -2906,6 +2906,8 @@ namespace RMuseum.Services.Implementation
|
||||
{
|
||||
link.DisplayOnPage = true;
|
||||
link.Synchronized = true;
|
||||
|
||||
await _ganjoorService.CacheCleanForPageById(link.GanjoorPostId);
|
||||
}//if not user must decide through UI for this link
|
||||
|
||||
_context.GanjoorLinks.Update(link);
|
||||
@ -3048,6 +3050,8 @@ namespace RMuseum.Services.Implementation
|
||||
_context.GanjoorLinks.Update(link);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
await _ganjoorService.CacheCleanForPageById(link.GanjoorPostId);
|
||||
|
||||
return new RServiceResult<bool>(true);
|
||||
}
|
||||
catch (Exception exp)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user