コード例 #1
0
        /// <summary>
        /// Method to persist object.
        /// </summary>
        internal virtual void Persist(SqlTransaction sqlTrans)
        {
            // see if there is exceptions in the business model
            RuleViolationException businessexception = this.BusinessExceptions;

            if (businessexception != null)
            {
                throw businessexception;
            }
        }
コード例 #2
0
        private Task HandleRuleViolationExceptionAsync(HttpContext context, RuleViolationException exception)
        {
            context.Response.ContentType = "application/json";
            context.Response.StatusCode  = (int)HttpStatusCode.BadRequest;

            return(context.Response.WriteAsync(new ErrorDetails()
            {
                StatusCode = context.Response.StatusCode,
                ValidationErrors = exception.RuleViolations
            }.ToJson()));
        }
コード例 #3
0
 public override void When()
 {
     try
     {
         post.Validate();
     }
     catch (RuleViolationException ex)
     {
         exception = ex;
     }
 }