2019-03-27 20:40:26 -04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2019-04-16 12:32:42 -04:00
|
|
|
|
using SharedLibraryCore.Database.Models;
|
|
|
|
|
using SharedLibraryCore.Dtos;
|
2019-03-27 20:40:26 -04:00
|
|
|
|
using SharedLibraryCore.Services;
|
2019-03-29 22:56:56 -04:00
|
|
|
|
using System;
|
2019-04-16 12:32:42 -04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Security.Claims;
|
2019-03-27 20:40:26 -04:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace WebfrontCore.ViewComponents
|
|
|
|
|
{
|
|
|
|
|
public class ProfileMetaListViewComponent : ViewComponent
|
|
|
|
|
{
|
2019-03-29 22:56:56 -04:00
|
|
|
|
public async Task<IViewComponentResult> InvokeAsync(int clientId, int count, int offset, DateTime? startAt)
|
2019-03-27 20:40:26 -04:00
|
|
|
|
{
|
2019-04-16 12:32:42 -04:00
|
|
|
|
var level = (EFClient.Permission)Enum.Parse(typeof(EFClient.Permission), UserClaimsPrincipal.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Role)?.Value ?? "User");
|
|
|
|
|
|
|
|
|
|
IEnumerable<ProfileMeta> meta = await MetaService.GetRuntimeMeta(clientId, offset, count, startAt ?? DateTime.UtcNow);
|
|
|
|
|
|
|
|
|
|
if (level < EFClient.Permission.Trusted)
|
|
|
|
|
{
|
|
|
|
|
meta = meta.Where(_meta => !_meta.Sensitive);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-27 20:40:26 -04:00
|
|
|
|
return View("_List", meta);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|