/// <summary>
    /// Gets the contact targets.
    /// </summary>
    /// <returns></returns>
    private IList GetContactTargets()
    {
        IList              contactList;
        IQueryable         query       = (IQueryable)EntityFactory.GetRepository <IContact>();
        IExpressionFactory expressions = query.GetExpressionFactory();
        IProjections       projections = query.GetProjectionsFactory();
        ICriteria          criteria    = query.CreateCriteria("a1")
                                         .CreateCriteria("Account", "account")
                                         .CreateCriteria("a1.Addresses", "address")
                                         .SetProjection(projections.ProjectionList()
                                                        .Add(projections.Distinct(projections.Property("Id")))
                                                        .Add(projections.Property("FirstName"))
                                                        .Add(projections.Property("LastName"))
                                                        .Add(projections.Property("AccountName"))
                                                        .Add(projections.Property("Email"))
                                                        .Add(projections.Property("address.City"))
                                                        .Add(projections.Property("address.State"))
                                                        .Add(projections.Property("address.PostalCode"))
                                                        .Add(projections.Property("WorkPhone"))

                                                        );

        AddExpressionsCriteria(criteria, expressions);
        contactList = criteria.List();
        // NOTE: The generic exception handler was removed since the exception was rethrown; this exception would be logged twice otherwise.
        // We may want to throw a UserObservableApplicationException in the future.
        return(contactList);
    }
    /// <summary>
    /// Shows the sales process info.
    /// </summary>
    /// <param name="opportunity">The opportunity.</param>
    /// <returns></returns>
    private bool ShowSalesProcessInfo(IOpportunity opportunity)
    {
        bool result = false;

        if (GetOpportunityStatusMatch(opportunity, "Open") ||
            GetOpportunityStatusMatch(opportunity, "Inactive"))
        {
            IRepository <ISalesProcesses> rep = EntityFactory.GetRepository <ISalesProcesses>();
            IQueryable         qry            = (IQueryable)rep;
            IExpressionFactory ep             = qry.GetExpressionFactory();
            ICriteria          crit           = qry.CreateCriteria();
            crit.Add(ep.Eq("EntityId", opportunity.Id.ToString()));
            IProjection proj = qry.GetProjectionsFactory().Count("Id");
            crit.SetProjection(proj);
            int count = (int)crit.UniqueResult();
            result = (count > 0);
        }
        return(result);
    }
    /// <summary>
    /// Gets the contact targets via a join through Account.
    /// </summary>
    /// <returns></returns>
    private IList GetAccountTargets()
    {
        IList contactList;

        try
        {
            IQueryable         query       = (IQueryable)EntityFactory.GetRepository <IContact>();
            IExpressionFactory expressions = query.GetExpressionFactory();
            IProjections       projections = query.GetProjectionsFactory();
            ICriteria          criteria    = query.CreateCriteria("a1")
                                             .CreateCriteria("Account", "account")
                                             .CreateCriteria("Addresses", "address")
                                             .SetProjection(projections.ProjectionList()
                                                            .Add(projections.Distinct(projections.Property("Id")))
                                                            .Add(projections.Property("FirstName"))
                                                            .Add(projections.Property("LastName"))
                                                            .Add(projections.Property("AccountName"))
                                                            .Add(projections.Property("Email"))
                                                            .Add(projections.Property("address.City"))
                                                            .Add(projections.Property("address.State"))
                                                            .Add(projections.Property("address.PostalCode"))
                                                            .Add(projections.Property("WorkPhone"))
                                                            );
            AddExpressionsCriteria(criteria, expressions);
            contactList = criteria.List();
        }
        catch (NHibernate.QueryException nex)
        {
            log.Error("The call to ManageTargets.GetAccountTargets() failed", nex);
            string message = GetLocalResourceObject("QueryError").ToString();
            if (nex.Message.Contains("could not resolve property"))
            {
                message += "  " + GetLocalResourceObject("QueryErrorInvalidParameter");
            }

            throw new ValidationException(message);
        }
        // NOTE: The generic exception handler was removed since the exception was rethrown; this exception would be logged twice otherwise.
        // We may want to throw a UserObservableApplicationException in the future.
        return(contactList);
    }