@@ -1320,6 +1320,27 @@ public void UpdatePathRelatedMeta(string oldPath, string newPath,bool save=true)
1320
1320
1321
1321
}
1322
1322
public async Task < SaveResult > SaveContent < T > ( T mod , bool makeRevision = true , string userName = null , bool handleNodeNameExists = true , int nodeNameExistsCounter = 0 , bool triggerEvents = true , bool triggerIndexEvents = true , bool shouldIndex = true , bool alwaysUpdatePath = true , bool queueIfIndexerBusy = false ) where T : BaseModel
1323
+ {
1324
+ if ( triggerEvents )
1325
+ {
1326
+ var beforeArgs = new BeforeIndexingEventArgs { Node = mod } ;
1327
+ OnBeforeSave ( this , beforeArgs ) ;
1328
+ if ( beforeArgs . Cancel )
1329
+ throw new SaveCancelledException ( "Saving was cancelled by a custom event handler" ) ;
1330
+ }
1331
+
1332
+ var returnValue = await DoSaveContent < T > ( mod , makeRevision , userName , handleNodeNameExists , nodeNameExistsCounter , triggerEvents , triggerIndexEvents , shouldIndex , alwaysUpdatePath , queueIfIndexerBusy ) ;
1333
+
1334
+ if ( triggerEvents )
1335
+ {
1336
+ var afterArgs = new IndexingEventArgs { Node = mod } ;
1337
+ OnAfterSave ( this , afterArgs ) ;
1338
+ }
1339
+
1340
+ return returnValue ;
1341
+ }
1342
+
1343
+ private async Task < SaveResult > DoSaveContent < T > ( T mod , bool makeRevision = true , string userName = null , bool handleNodeNameExists = true , int nodeNameExistsCounter = 0 , bool triggerEvents = true , bool triggerIndexEvents = true , bool shouldIndex = true , bool alwaysUpdatePath = true , bool queueIfIndexerBusy = false ) where T : BaseModel
1323
1344
{
1324
1345
if ( nodeNameExistsCounter == 0 )
1325
1346
await slock1 . WaitAsync ( ) ;
@@ -1385,13 +1406,7 @@ public async Task<SaveResult> SaveContent<T>(T mod, bool makeRevision = true, st
1385
1406
//set sort order for new content
1386
1407
if ( mod . SortOrder == - 1 )
1387
1408
mod . SortOrder = nodesAtPath . Count ( ) ;
1388
- if ( triggerEvents )
1389
- {
1390
- var beforeArgs = new BeforeIndexingEventArgs { Node = mod } ;
1391
- OnBeforeSave ( this , beforeArgs ) ;
1392
- if ( beforeArgs . Cancel )
1393
- throw new SaveCancelledException ( "Saving was cancelled by a custom event handler" ) ;
1394
- }
1409
+ //beforesave event was triggered here
1395
1410
var revisions = repo . GetPuckRevision ( ) . Where ( x => x . Id . Equals ( mod . Id ) && x . Variant . ToLower ( ) . Equals ( mod . Variant . ToLower ( ) ) ) ;
1396
1411
1397
1412
mod . Updated = DateTime . Now ;
@@ -1908,11 +1923,7 @@ void _SetPath()
1908
1923
if ( shouldIndex )
1909
1924
AddPublishInstruction ( result . ItemsToIndex , save : true ) ;
1910
1925
1911
- if ( triggerEvents )
1912
- {
1913
- var afterArgs = new IndexingEventArgs { Node = mod } ;
1914
- OnAfterSave ( this , afterArgs ) ;
1915
- }
1926
+ //aftersave was triggered here
1916
1927
1917
1928
if ( shouldUpdateDomainMappings )
1918
1929
StateHelper . UpdateDomainMappings ( true ) ;
0 commit comments