Esempio n. 1
0
        public string GetLink(BusinessRuleViolation type, HttpContext ctx)
        {
            var dictionary = new RouteValueDictionary
            {
                { "name", $"{type.GetType().AssemblyQualifiedName}" }
            };
            var av   = ctx?.Features.Get <IRouteValuesFeature>()?.RouteValues;
            var path = _provider.Router.GetVirtualPath(new VirtualPathContext(ctx, av, dictionary, "ProblemDetails"));

            var link = UriHelper.BuildRelative(ctx.Request.PathBase, path.VirtualPath);

            return(link);
        }
Esempio n. 2
0
        public BusinessRuleProblemDetails(BusinessRuleViolation businessRuleViolation) : base(businessRuleViolation.Status)
        {
            Title  = businessRuleViolation.Title;
            Status = businessRuleViolation.Status;
            Detail = businessRuleViolation.Detail;

            Violation = businessRuleViolation;

            var type       = businessRuleViolation.GetType();
            var properties = type.GetProperties().Where(p => p.DeclaringType != typeof(BusinessRuleViolation)).ToArray();

            foreach (var prop in properties)
            {
                Extensions.Add(prop.Name, prop.GetValue(businessRuleViolation, null));
            }
        }