AuditTrail for ExecuteDelete

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
emlim896
User
Posts: 13

AuditTrail for ExecuteDelete

Post by emlim896 »

Hello,

I used ASP.NET Maker 2022. Audit Trail was not created when using method

int affected = ExecuteDelete("Books", new { Id = 1 });

But it's working in RowDeleted().
Any help would be appreciated.

Thanks


MichaelG
User
Posts: 1095

Post by MichaelG »

If you have enabled audit trail for the table, just use the table's Delete method directly. For example:

int affected = Resolve("Books").Delete(data);


emlim896
User
Posts: 13

Post by emlim896 »

I'm calling ExecuteDelete() inside RouteAction which triggered by api using jquery.get.

The record was deleted but Audit Trail was not created.


MichaelG
User
Posts: 1095

Post by MichaelG »

Did you try?

If you have enabled audit trail for the table, just use the table's Delete method directly. For example:
int affected = Resolve("Books").Delete(data);


emlim896
User
Posts: 13

Post by emlim896 »

what (data) should I put?
I tried
int affected = Resolve("Books").Delete( { Id = 1 } );
It doesn't work, affected always return 0 and record was not deleted.


MichaelG
User
Posts: 1095

Post by MichaelG »

Make sure that the field name/value is correct. Also enable debug mode (Tools -> Advanced Settings -> Debug) to check for any errors.


emlim896
User
Posts: 13

Post by emlim896 »

my script:

  app.MapGet("/api/delQueue/{guid}", (string guid) => {
    int affected = ExecuteDelete("Queue", new {Guid = guid} );  // working, affected=1, record deleted
    //int affected = Resolve("Queue").Delete( new {Guid = guid} ); // failed, affected=0, record not delete
    return affected;
  });

with debug mode, all SQL scripts were shown but not the script in app.MapGet.


MichaelG
User
Posts: 1095

Post by MichaelG »

To see why the codes are not working, open your project with Visual Studio, add a break point to the Delete method of the "Queue" table (located in "Models/Queue.cs"), step through the codes and debug from there.


emlim896
User
Posts: 13

Post by emlim896 »

Thanks, problem solved.

new script:

app.MapGet("/api/delQueue/{guid}", (string guid) => {
  var row = ExecuteRow("select id from Queue where Guid='"+guid+"'");
  int res = Resolve("Queue").Delete(row);
  return res;
});

Post Reply