Exemple #1
0
        public async Task <ActionResult <IEnumerable <ExpressionValueResponse> > > GetExpressionValue([FromBody] IEnumerable <ExpressionValueRequest> request)
        {
            var tasks = request
                        .Where(x => _permissionService.IsAllowed(new ActionRequestInfo(HttpContext, _implementationsContainer, x.EntityTypeName, ActionTypeEnum.Select)))
                        .Select(x => new { x.EntityTypeName, Task = _entityHandler.GetExpressionValue(x) }).ToList();
            var results = new List <ExpressionValueResponse>();

            foreach (var task in tasks)
            {
                results.Add(await task.Task);
            }
            return(results);
        }
        private async Task <Dictionary <string, string> > GetTemplateValues(IEnumerable <string> expressions, int entityIdentifier, string entityTypeName)
        {
            var request = new ExpressionValueRequest
            {
                EntityTypeName = entityTypeName,
                Ids            = new int[] { entityIdentifier },
                Properties     = expressions.Select(e => new PropertyInfoModel
                {
                    Name = e
                }).ToArray()
            };
            var response = await _entityHandler.GetExpressionValue(request) as ExpressionValueResponse <int>;

            var result = new Dictionary <string, string>();

            foreach (var prop in response.PropertyValues)
            {
                result.Add(prop.Key, prop.Value.FirstOrDefault().Value?.ToString());
            }
            return(result);
        }