#195 displaying user info in the ExamineUser page

This commit is contained in:
Hamid Reza Mohammadi 2021-08-31 19:20:06 +04:30
parent b5dc87e48b
commit 5f6a638b82
2 changed files with 59 additions and 3 deletions

View File

@ -3,6 +3,31 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = "_AdminLayout";
ViewData["Title"] = "اخراج یا غیرفعالسازی کاربر بدرفتار";
ViewData["Title"] = "مدیریت کاربر";
}
<h1>@ViewData["Title"]</h1>
@if (!string.IsNullOrEmpty(Model.LastError))
{
<p>@Model.LastError</p>
}
else
{
<table>
<tr>
<td>نام:</td>
<td>@Model.UserInfo.FirstName</td>
</tr>
<tr>
<td>نام خانوادگی:</td>
<td>@Model.UserInfo.FirstName</td>
</tr>
<tr>
<td>نام مستعار:</td>
<td>@Model.UserInfo.NickName</td>
</tr>
<tr>
<td>ایمیل:</td>
<td>@Model.UserInfo.Email</td>
</tr>
</table>
}

View File

@ -1,16 +1,47 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using GanjooRazor.Utils;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Newtonsoft.Json;
using RSecurityBackend.Models.Auth.ViewModels;
namespace GanjooRazor.Areas.Admin.Pages
{
public class ExamineUserModel : PageModel
{
public void OnGet()
public PublicRAppUser UserInfo { get; set; }
/// <summary>
/// Last Error
/// </summary>
public string LastError { get; set; }
public async Task OnGetAsync()
{
using (HttpClient secureClient = new HttpClient())
{
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
{
var userInfoResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/users/{Request.Query["id"]}");
if (userInfoResponse.IsSuccessStatusCode)
{
UserInfo = JsonConvert.DeserializeObject<PublicRAppUser>(await userInfoResponse.Content.ReadAsStringAsync());
}
else
{
LastError = await userInfoResponse.Content.ReadAsStringAsync();
}
}
else
{
LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
}
}
}
}
}