1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Transactions shared between modules

Transactions shared between modules

1 posts, 0 answered
  1. Jaime Weise
    Jaime Weise avatar
    120 posts
    Registered:
    02 Nov 2008
    09 Apr 2012
    Link to this post
    I noticed that all managers have a TransactionName proproperty

    switch (e.CommandName)
    {
        case "DeleteProject":
     
            var projectName = e.CommandArgument.ToString();
            var dynamicModuleManager = DynamicModuleManager.GetManager();
            dynamicModuleManager.TransactionName = "RemoveProject";
     
            var project = GetMyProjects(dynamicModuleManager).FirstOrDefault(p => p.GetValue<String>("Title") == projectName);
            if (project != null)
            {
                var ownerId = project.Owner;
     
                if (ownerId != SecurityManager.GetCurrentUserId())
                {
                    throw new Exception("Incorrect permissions for project deletion.");
                }
                 
                var manager = LibrariesManager.GetManager();
                manager.TransactionName = "RemoveProject";
                var album = GetProjectAlbum(manager, project);
                manager.DeleteAlbum(album);
     
                dynamicModuleManager.DeleteItem(project);
                TransactionManager.CommitTransaction("RemoveProject");
     
                 
            }
            break;
    }

    Obviously, this doesn't work but is there a way to make it work among a couple of managers?
1 posts, 0 answered