public List <SalesRepresentative> GetAllSalesRepresentatives()
        {
            var franchiseeFranchiseeUserView = new FranchiseeFranchiseeUserTypedView();
            IRelationPredicateBucket bucket  = new RelationPredicateBucket(FranchiseeFranchiseeUserFields.IsActive == true);

            bucket.PredicateExpression.Add(FranchiseeFranchiseeUserFields.RoleId == Roles.SalesRep);

            using (var myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                myAdapter.FetchTypedView(franchiseeFranchiseeUserView, bucket, false);
            }

            if (franchiseeFranchiseeUserView.AsEnumerable().Count() < 1)
            {
                return(null);                                                         // Might need to throw an exception
            }
            List <long> userIds = franchiseeFranchiseeUserView.AsEnumerable().Select(ffuv => ffuv.UserId).ToList();
            List <User> users   = _userRepository.GetUsers(userIds);

            return(_salesRepresentativeFactory.CreateSalesRepresentatives(franchiseeFranchiseeUserView, users));
        }
        public List <SalesRepresentative> GetSalesRepresentativesForFranchisee(long organizationId)
        {
            var franchiseeFranchiseeUserView = new FranchiseeFranchiseeUserTypedView();
            IRelationPredicateBucket bucket  = new RelationPredicateBucket(FranchiseeFranchiseeUserFields.IsActive == true);

            bucket.PredicateExpression.Add(FranchiseeFranchiseeUserFields.OrganizationId == organizationId);
            bucket.PredicateExpression.Add(FranchiseeFranchiseeUserFields.RoleId == Roles.SalesRep);

            using (var myAdapter = PersistenceLayer.GetDataAccessAdapter())
            {
                myAdapter.FetchTypedView(franchiseeFranchiseeUserView, bucket, false);
            }

            List <long> userIds = franchiseeFranchiseeUserView.AsEnumerable().Select(ffuv => ffuv.UserId).ToList();
            List <User> users   = _userRepository.GetActiveSystemUsers(userIds);

            return(_salesRepresentativeFactory.CreateSalesRepresentatives(franchiseeFranchiseeUserView, users));
        }