Example #1
0
        private IEnumerable <User> GetReceivers(Item contentItem, ID currentState, ID nextState)
        {
            if (currentState.Equals(Constants.States.Draft) && nextState.Equals(Constants.States.WaitingForMallSiteApproval))
            {
                return(WorkflowHelper.GetMallAdminsOf(contentItem.GetSiteItem()));
            }
            else if (currentState.Equals(Constants.States.Draft) && nextState.Equals(Constants.States.WaitingForMainSiteApproval))
            {
                return(WorkflowHelper.GetMainAdminsOf(contentItem.GetSiteItem()));
            }
            else if ((currentState.Equals(Constants.States.WaitingForMallSiteApproval) && nextState.Equals(Constants.States.Draft)) ||
                     (currentState.Equals(Constants.States.WaitingForMainSiteApproval) && nextState.Equals(Constants.States.Draft)) ||
                     (currentState.Equals(Constants.States.WaitingForMallSiteApproval) && nextState.Equals(Constants.States.Approved)) ||
                     (currentState.Equals(Constants.States.WaitingForMainSiteApproval) && nextState.Equals(Constants.States.Approved)))
            {
                var result = new List <User>
                {
                    WorkflowHelper.GetAuthorOf(contentItem)
                };

                var sourceItem = _mallSiteWorkflowRepository.TryGetSourceItemBy(contentItem);
                if (sourceItem != null) // Get related user if existed.
                {
                    result.Add(User.FromName(sourceItem.Statistics.UpdatedBy, true));
                }
                return(result.Distinct());
            }
            return(Enumerable.Empty <User>());
        }