#217 adding numberings in UI

This commit is contained in:
Hamid Reza Mohammadi 2021-10-04 10:31:16 +03:30
parent 344b06f062
commit 497cdddbb4
3 changed files with 83 additions and 2 deletions

View File

@ -188,12 +188,49 @@
@numbering.EndCatId
</td>
<td>
@numbering.LastCountingDate.ToLongPersianDateTimeString()
@if(numbering.LastCountingDate != DateTime.MinValue)
{
@numbering.LastCountingDate.ToLongPersianDateTimeString()
}
</td>
</tr>
}
</table>
<form method="post" action="?Handler=Numbering&url=@Model.Cat.Cat.FullUrl">
<table>
<tr>
<td>
عنوان:
</td>
<td>
<input asp-for="NumberingModel.Name" />
</td>
</tr>
<tr>
<td>
شناسهٔ ابتدا
</td>
<td>
<input asp-for="NumberingModel.StartCatId" />
</td>
</tr>
<tr>
<td>
شناسهٔ انتها
</td>
<td>
<input asp-for="NumberingModel.EndCatId" />
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="ایجاد الگوی شماره‌گذاری" />
</td>
</tr>
</table>
</form>

View File

@ -66,6 +66,12 @@ namespace GanjooRazor.Areas.Admin.Pages
/// </summary>
public GanjoorNumbering[] Numberings { get; set; }
/// <summary>
/// numbering model
/// </summary>
[BindProperty]
public GanjoorNumbering NumberingModel { get; set; }
private async Task GetInformationAsync()
{
@ -106,6 +112,13 @@ namespace GanjooRazor.Areas.Admin.Pages
Simulate = true
};
NumberingModel = new GanjoorNumbering()
{
Name = Cat.Cat.Title,
StartCatId = Cat.Cat.Id,
EndCatId = Cat.Cat.Id
};
return Page();
}
@ -118,6 +131,13 @@ namespace GanjooRazor.Areas.Admin.Pages
{
await GetInformationAsync();
NumberingModel = new GanjoorNumbering()
{
Name = Cat.Cat.Title,
StartCatId = Cat.Cat.Id,
EndCatId = Cat.Cat.Id
};
using (HttpClient secureClient = new HttpClient())
{
await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response);
@ -133,6 +153,30 @@ namespace GanjooRazor.Areas.Admin.Pages
return Page();
}
public async Task<IActionResult> OnPostNumberingAsync(GanjoorNumbering NumberingModel)
{
using (HttpClient secureClient = new HttpClient())
{
await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response);
HttpResponseMessage response = await secureClient.PostAsync($"{APIRoot.Url}/api/numberings", new StringContent(JsonConvert.SerializeObject(NumberingModel), Encoding.UTF8, "application/json"));
response.EnsureSuccessStatusCode();
}
await GetInformationAsync();
NamingModel = new GanjoorBatchNamingModel()
{
StartWithNotIncludingSpaces = "شمارهٔ ",
RemovePreviousPattern = true,
RemoveSetOfCharacters = ".-",
Simulate = true
};
return Page();
}
public async Task<IActionResult> OnPostStartRhymeAnalysisAsync(int id)
{
using (HttpClient secureClient = new HttpClient())

View File

@ -74,7 +74,7 @@ namespace RMuseum.Controllers
}
foreach (var numbering in res2.Result)
{
if(combined.Where(n => n.Id == numbering.Id).FirstOrDefault() == numbering)
if(combined.Where(n => n.Id == numbering.Id).FirstOrDefault() == null)
{
combined.Add(numbering);
}