/// <summary> /// Converts a Worflow into a CommunityMembershipWorkflow /// </summary> /// <param name="workflow">Workflow to be adapted</param> /// <returns>CommunityMembershipWorkflow</returns> public CommunityMembershipWorkflow Adapt(Workflow workflow) { CommunityMembershipWorkflow viewModel = null; if (workflow != null) { viewModel = new CommunityMembershipWorkflow(workflow.Id.ToString(), workflow.Name, workflow.InitialState.Name); } return(viewModel); }
/// <summary> /// Returns the moderation workflow supporting the specified group. /// </summary> /// <param name="group">ID of the group</param> /// <returns>Moderation workflow supporting the specified group</returns> private CommunityMembershipWorkflow GetWorkflowFor(string group) { CommunityMembershipWorkflow expectedSocialWorkflow = null; var listOfWorkflow = Enumerable.Empty <Composite <Workflow, MembershipModeration> >(); var filterWorkflowsByGroup = FilterExpressionBuilder <MembershipModeration> .Field(m => m.Group) .EqualTo(group); var criteria = new CompositeCriteria <WorkflowFilter, MembershipModeration> { PageInfo = new PageInfo { PageSize = 1 }, ExtensionFilter = filterWorkflowsByGroup }; try { listOfWorkflow = _workflowService.Get(criteria).Results; if (listOfWorkflow.Any()) { var workflow = listOfWorkflow.First().Data; expectedSocialWorkflow = new CommunityMembershipWorkflow(workflow.Id.Id, workflow.Name, workflow.InitialState.Name); } } catch (SocialAuthenticationException ex) { throw new SocialRepositoryException("The application failed to authenticate with Episerver Social.", ex); } catch (MaximumDataSizeExceededException ex) { throw new SocialRepositoryException( "The application request was deemed too large for Episerver Social.", ex); } catch (SocialCommunicationException ex) { throw new SocialRepositoryException("The application failed to communicate with Episerver Social.", ex); } catch (SocialException ex) { throw new SocialRepositoryException("Episerver Social failed to process the application request.", ex); } return(expectedSocialWorkflow); }