Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Hans Børge Pedersen 3 posts 73 karma points
    May 12, 2016 @ 16:48
    Hans Børge Pedersen
    0

    Accessing services in events (e.g. Trashing)

    I have registered a method to the ContentService.Trashing event with:

    ContentService.Trashing += ContentService_Trashing;
    

    This in turn calls this method, which was written by someone else, and causes our application to hang. Here is a snippet of the method (which is a static method btw):

    var oldCustomer = e.MoveInfoCollection.FirstOrDefault(x => x.Entity.ContentType.Alias == "Customerpage");
            if (oldCustomer != null)
            {
                // Delete role
                var roleName = oldCustomer.Entity.Name;
                var existing =
                    ApplicationContext.Current.Services.MemberService.GetAllRoles().FirstOrDefault(x => x == roleName);
                if (existing != null)
                {
                    ApplicationContext.Current.Services.MemberService.DeleteRole(roleName, true);
                }
                return;
            }
    

    Is it a better way to do this than dragging in the memberservice (and then the same for media) to delete related content?

    Should this be moved to some kind of scheduled task?

    Regards, Hans B

Please Sign in or register to post replies

Write your reply to:

Draft