Beispiel #1
0
        // todo rework
        private async Task <List <int> > GetRightIdsAsync()
        {
            List <int> rights = _cache.Get <List <int> >(CacheKeys.RightsIds);

            if (rights == null)
            {
                rights = (await _repository.GetRightsListAsync()).Select(r => r.RightId).ToList();
                _cache.Set(CacheKeys.RightsIds, rights);
            }

            return(rights);
        }
        public async Task <OperationResultResponse <List <RightInfo> > > ExecuteAsync(string locale)
        {
            if (!await _accessValidator.IsAdminAsync())
            {
                return(_responseCreator.CreateFailureResponse <List <RightInfo> >(HttpStatusCode.Forbidden));
            }

            return(new()
            {
                Status = Kernel.Enums.OperationResultStatusType.FullSuccess,
                Body = (await _repository.GetRightsListAsync(locale))?.Select(right => _mapper.Map(right)).ToList()
            });
        }