public override void OnException(IDeleteRequestHandler handler, Exception exception)
 {
     if (exception is SqlException)
     {
         SqlExceptionHelper.HandleDeleteForeignKeyException(exception, handler.Context?.Localizer);
     }
 }
 public override void OnException(ISaveRequestHandler handler, Exception exception)
 {
     if (exception is SqlException)
     {
         SqlExceptionHelper.HandleSavePrimaryKeyException(exception, handler.Context?.Localizer,
                                                          handler.Row?.IdField?.GetTitle(handler.Context?.Localizer));
     }
 }
Esempio n. 3
0
        public static void HandleSavePrimaryKeyException(Exception e, string fieldName = "ID")
        {
            PrimaryKeyExceptionInfo fk;

            if (SqlExceptionHelper.IsPrimaryKeyException(e, out fk))
            {
                throw new ValidationError(String.Format(Texts.Validation.SavePrimaryKeyError, fk.TableName, fieldName));
            }
        }
Esempio n. 4
0
        public static void HandleDeleteForeignKeyException(Exception e)
        {
            ForeignKeyExceptionInfo fk;

            if (SqlExceptionHelper.IsForeignKeyException(e, out fk))
            {
                throw new ValidationError(String.Format(Texts.Validation.DeleteForeignKeyError, fk.TableName));
            }
        }