2020-04-28 17:48:06 -04:00
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using SharedLibraryCore;
|
|
|
|
|
using SharedLibraryCore.Dtos;
|
|
|
|
|
using SharedLibraryCore.Interfaces;
|
|
|
|
|
using System.Threading.Tasks;
|
2022-06-05 17:27:56 -04:00
|
|
|
|
using WebfrontCore.QueryHelpers.Models;
|
2020-04-28 17:48:06 -04:00
|
|
|
|
|
|
|
|
|
namespace WebfrontCore.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class AdminController : BaseController
|
|
|
|
|
{
|
|
|
|
|
private readonly IAuditInformationRepository _auditInformationRepository;
|
|
|
|
|
private readonly ITranslationLookup _translationLookup;
|
2022-06-05 17:27:56 -04:00
|
|
|
|
private readonly IResourceQueryHelper<BanInfoRequest, BanInfo> _banInfoQueryHelper;
|
2020-04-28 17:48:06 -04:00
|
|
|
|
private static readonly int DEFAULT_COUNT = 25;
|
|
|
|
|
|
2022-06-05 17:27:56 -04:00
|
|
|
|
public AdminController(IManager manager, IAuditInformationRepository auditInformationRepository,
|
|
|
|
|
ITranslationLookup translationLookup,
|
|
|
|
|
IResourceQueryHelper<BanInfoRequest, BanInfo> banInfoQueryHelper) : base(manager)
|
2020-04-28 17:48:06 -04:00
|
|
|
|
{
|
|
|
|
|
_auditInformationRepository = auditInformationRepository;
|
|
|
|
|
_translationLookup = translationLookup;
|
2022-06-05 17:27:56 -04:00
|
|
|
|
_banInfoQueryHelper = banInfoQueryHelper;
|
2020-04-28 17:48:06 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Authorize]
|
|
|
|
|
public async Task<IActionResult> AuditLog()
|
|
|
|
|
{
|
|
|
|
|
ViewBag.EnableColorCodes = Manager.GetApplicationSettings().Configuration().EnableColorCodes;
|
|
|
|
|
ViewBag.IsFluid = true;
|
|
|
|
|
ViewBag.Title = _translationLookup["WEBFRONT_NAV_AUDIT_LOG"];
|
|
|
|
|
ViewBag.InitialOffset = DEFAULT_COUNT;
|
|
|
|
|
|
2022-06-05 17:27:56 -04:00
|
|
|
|
var auditItems = await _auditInformationRepository.ListAuditInformation(new PaginationRequest
|
2020-04-28 17:48:06 -04:00
|
|
|
|
{
|
|
|
|
|
Count = DEFAULT_COUNT
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return View(auditItems);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-17 22:21:11 -04:00
|
|
|
|
public async Task<IActionResult> ListAuditLog([FromQuery] PaginationRequest paginationInfo)
|
2020-04-28 17:48:06 -04:00
|
|
|
|
{
|
|
|
|
|
ViewBag.EnableColorCodes = Manager.GetApplicationSettings().Configuration().EnableColorCodes;
|
|
|
|
|
var auditItems = await _auditInformationRepository.ListAuditInformation(paginationInfo);
|
|
|
|
|
return PartialView("_ListAuditLog", auditItems);
|
|
|
|
|
}
|
2022-06-05 17:27:56 -04:00
|
|
|
|
|
|
|
|
|
public async Task<IActionResult> BanManagement([FromQuery] BanInfoRequest request)
|
|
|
|
|
{
|
|
|
|
|
var results = await _banInfoQueryHelper.QueryResource(request);
|
|
|
|
|
|
|
|
|
|
ViewBag.ClientName = request.ClientName;
|
|
|
|
|
ViewBag.ClientId = request.ClientId;
|
|
|
|
|
ViewBag.ClientIP = request.ClientIP;
|
|
|
|
|
ViewBag.ClientGuid = request.ClientGuid;
|
|
|
|
|
|
2022-07-05 13:02:43 -04:00
|
|
|
|
ViewBag.Title = Localization["WEBFRONT_NAV_TITLE_BAN_MANAGEMENT"];
|
2022-06-05 17:27:56 -04:00
|
|
|
|
|
|
|
|
|
return View(results.Results);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IActionResult> BanManagementList([FromQuery] BanInfoRequest request)
|
|
|
|
|
{
|
|
|
|
|
var results = await _banInfoQueryHelper.QueryResource(request);
|
|
|
|
|
return PartialView("_BanEntries", results.Results);
|
|
|
|
|
}
|
2020-04-28 17:48:06 -04:00
|
|
|
|
}
|
|
|
|
|
}
|