docs: #339 bug fix
This commit is contained in:
parent
b32db1385d
commit
e1befd52c5
@ -1,5 +1,4 @@
|
||||
using DNTPersianUtils.Core;
|
||||
using GanjooRazor.Utils;
|
||||
using GanjooRazor.Utils;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
@ -984,25 +983,5 @@ namespace GanjooRazor.Pages
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetCheckIfHasNotificationsAsync()
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/notifications/unread/count");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return new BadRequestObjectResult(JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync()));
|
||||
}
|
||||
var res = JsonConvert.DeserializeObject<int>(await response.Content.ReadAsStringAsync());
|
||||
if (res == 0)
|
||||
return new OkObjectResult("");
|
||||
return new OkObjectResult(res.ToString().ToPersianNumbers());
|
||||
}
|
||||
}
|
||||
return new BadRequestObjectResult("لطفا از گنجور خارج و مجددا به آن وارد شوید.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using GanjooRazor.Utils;
|
||||
using DNTPersianUtils.Core;
|
||||
using GanjooRazor.Utils;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
@ -131,6 +132,26 @@ namespace GanjooRazor.Pages
|
||||
return Redirect(Request.Path);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetCheckIfHasNotificationsAsync()
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/notifications/unread/count");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return new BadRequestObjectResult(JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync()));
|
||||
}
|
||||
var res = JsonConvert.DeserializeObject<int>(await response.Content.ReadAsStringAsync());
|
||||
if (res == 0)
|
||||
return new OkObjectResult("");
|
||||
return new OkObjectResult(res.ToString().ToPersianNumbers());
|
||||
}
|
||||
}
|
||||
return new BadRequestObjectResult("لطفا از گنجور خارج و مجددا به آن وارد شوید.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HttpClient instance
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user