public void DiscardWorkflow(int contentItemId, string comment, int portalId, int userId)
        {
            var item     = contentController.GetContentItem(contentItemId);
            var workflow = GetWorkflow(item);
            var stateId  = GetLastWorkflowStateID(workflow);

            AddWorkflowCommentLog(item, comment, userId);
            AddWorkflowLog(item, ContentWorkflowLogType.WorkflowDiscarded, userId);
            SetWorkflowState(stateId, item);
        }
예제 #2
0
        public void ContentController_GetContentItem_Throws_On_Negative_ContentItemId()
        {
            // Arrange
            Mock <IDataService> mockDataService = new Mock <IDataService>();
            ContentController   controller      = new ContentController(mockDataService.Object);

            // Act, Arrange
            Assert.Throws <ArgumentOutOfRangeException>(() => controller.GetContentItem(Null.NullInteger));
        }
예제 #3
0
        public ActionMessage GetActionMessage(StateTransaction stateTransaction, WorkflowState currentState)
        {
            ContentController contentController = new ContentController();

            return(new ActionMessage
            {
                Subject = contentController.GetContentItem(stateTransaction.ContentItemId).ContentTitle + " - New Item Created",
                Body = "Your item has been created.  Would you like to submit it for approval?"
            });
        }
예제 #4
0
        public ContentItem GetContentItem(int contentItemId)
        {
            var typeController  = new ContentTypeController();
            var colContentTypes = (from t in typeController.GetContentTypes() where t.ContentType == ContentTypeName select t);

            var cc    = new ContentController();
            var slide = cc.GetContentItem(contentItemId);

            return(slide);
        }
        public IMenuItem GetItem(int itemId, int moduleId)
        {
            ContentItem ci = _ciCtrl.GetContentItem(itemId);

            if (ci != null)
            {
                return(convertContentItemtoModelItem(ci));
            }
            else
            {
                return(null);
            }
        }
예제 #6
0
        public void ContentController_GetContentItem_Calls_DataService_On_Valid_ContentItemId()
        {
            // Arrange
            Mock <IDataService> mockDataService = new Mock <IDataService>();

            mockDataService.Setup(ds => ds.GetContentItem(Constants.CONTENT_ValidContentItemId)).Returns(MockHelper.CreateValidContentItemReader());
            ContentController controller = new ContentController(mockDataService.Object);

            // Act
            ContentItem content = controller.GetContentItem(Constants.CONTENT_ValidContentItemId);

            // Assert
            mockDataService.Verify(ds => ds.GetContentItem(Constants.CONTENT_ValidContentItemId));
        }
예제 #7
0
        public void ContentController_GetContentItem_Returns_Null_On_InValid_ContentItemId()
        {
            // Arrange
            Mock <IDataService> mockDataService = new Mock <IDataService>();

            mockDataService.Setup(ds => ds.GetContentItem(Constants.CONTENT_InValidContentItemId)).Returns(MockHelper.CreateEmptyContentItemReader());
            ContentController controller = new ContentController(mockDataService.Object);

            // Act
            ContentItem content = controller.GetContentItem(Constants.CONTENT_InValidContentItemId);

            // Assert
            Assert.IsNull(content);
        }
예제 #8
0
        public void ContentController_GetContentItem_Returns_ContentItem_On_Valid_ContentItemId()
        {
            // Arrange
            Mock <IDataService> mockDataService = new Mock <IDataService>();

            mockDataService.Setup(ds => ds.GetContentItem(Constants.CONTENT_ValidContentItemId)).Returns(MockHelper.CreateValidContentItemReader());
            ContentController controller = new ContentController(mockDataService.Object);

            // Act
            ContentItem content = controller.GetContentItem(Constants.CONTENT_ValidContentItemId);

            // Assert
            Assert.AreEqual(Constants.CONTENT_ValidContentItemId, content.ContentItemId);
            Assert.AreEqual(ContentTestHelper.GetContent(Constants.CONTENT_ValidContentItemId), content.Content);
            Assert.AreEqual(ContentTestHelper.GetContentKey(Constants.CONTENT_ValidContentItemId), content.ContentKey);
        }
        public void StartWorkflow(int workflowID, int itemID, int userID)
        {
            var item     = contentController.GetContentItem(itemID);
            var workflow = GetWorkflow(item);

            //If already exists a started workflow
            if (workflow != null && !IsWorkflowCompleted(workflow, item))
            {
                //TODO; Study if is need to throw an exception
                return;
            }
            if (workflow == null)
            {
                workflow = GetWorkflowByID(workflowID);
            }

            //Delete previous logs
            DataProvider.Instance().DeleteContentWorkflowLogs(itemID, workflowID);
            var newStateID = GetFirstWorkflowStateID(workflow);

            SetWorkflowState(newStateID, item);
            AddWorkflowLog(item, ContentWorkflowLogType.WorkflowStarted, userID);
            AddWorkflowLog(item, ContentWorkflowLogType.StateInitiated, userID);
        }
예제 #10
0
        public void DoActionOnStateChanged(StateTransaction stateTransaction)
        {
            // TODO:  Do soemthing when the workflow has started

            // If this is a direct publish workflow, there should be only one state in the workflow
            // Automatically complete the workflow or else it stays in limbo

            ContentController contentController = new ContentController();

            ContentItem content = contentController.GetContentItem(stateTransaction.ContentItemId);

            Workflow workflow = WorkflowManager.Instance.GetWorkflow(content);

            if (workflow.FirstState == workflow.LastState)
            {
                WorkflowController workflowController = new WorkflowController();

                workflowController.CompleteState(content, "Completing direct publish workflow.");
            }
        }