Esempio n. 1
0
        public async override Task Invoke(AspectContext context, AspectDelegate next)
        {
            await context.Invoke(next);

            var httpContext = context.GetHttpContext();

            if (httpContext != null)
            {
                var modelState = httpContext.Items["modelstate-aspectcore"] as ModelStateDictionary;
                if (modelState != null)
                {
                    var dataState = GetDataState(context.Implementation);
                    if (dataState != null)
                    {
                        foreach (var error in dataState.Errors)
                        {
                            modelState.AddModelError(error.Key, error.ErrorMessage);
                        }
                    }
                }
            }
        }