private bool IsCurrentUserVaultAdmin(int vaultId)
        {
            var currentUser = QueryBuilder.ResultingIn <User>()
                              .Execute(new NameCriterion(User.Identity.Name));

            var vault = QueryBuilder.ResultingIn <Vault>()
                        .Execute(new IdCriterion(vaultId));

            return(_vaultAccessService.IsUserVaultAdmin(currentUser, vault));
        }
Ejemplo n.º 2
0
 public override VaultViewModel[] Execute(GetAllVaultViewModelsCriterion criterion)
 {
     using (var uow = UnitOfWorkFactory.Create())
     {
         return(uow.VaultRepository
                .GetAll()
                .Select(x => new VaultViewModel
         {
             Id = x.Id.ToString(),
             Name = x.Name,
             Description = x.Description,
             IsCurrentUserVaultAdmin = _vaultAccessService.IsUserVaultAdmin(criterion.CurrentUser, x),
             HasAccessLogs = x.VaultAccessLogs.Any()
         })
                .ToArray());
     }
 }