Exemple #1
0
        private List <TeamPageGroupPublicModel> GetTeamPageGroupPublicModels(int teamId)
        {
            //retrieve all group pages by team
            var groupPages = _teamPageGroupService.GetGroupPagesByTeamId(teamId);

            var listTeamPageGroups = new List <TeamPageGroupPublicModel>();

            //get all group members for performance
            var allMembers            = _teamPageGroupMemberService.GetGroupPageMembersForTeam(teamId);
            var allMembersCustomerIds = allMembers.Select(x => x.CustomerId);

            var allCustomers = _userService.Get(x => allMembersCustomerIds.Contains(x.Id)).ToList();

            foreach (var groupPage in groupPages)
            {
                var groupMembers = allMembers.Where(x => x.GroupPageId == groupPage.Id).OrderBy(x => x.DisplayOrder);
                //setup the individual group model
                var groupModel = groupPage.ToModel();
                //add customers' public models to the list
                foreach (var member in groupMembers)
                {
                    var memberCustomer = allCustomers.First(x => x.Id == member.CustomerId);
                    groupModel.GroupMembers.Add(memberCustomer.ToModel(_mediaService, _mediaSettings));
                }

                //add this group model to the output list
                listTeamPageGroups.Add(groupModel);
            }
            return(listTeamPageGroups);
        }
Exemple #2
0
        private List <TeamPageGroupPublicModel> GetTeamPageGroupPublicModels(int teamId)
        {
            //retrieve all group pages by team
            var groupPages = _teamPageGroupService.GetGroupPagesByTeamId(teamId);

            var listTeamPageGroups = new List <TeamPageGroupPublicModel>();

            //get all group members for performance
            var allMembers            = _teamPageGroupMemberService.GetGroupPageMembersForTeam(teamId);
            var allMembersCustomerIds = allMembers.Select(x => x.CustomerId);

            var allCustomers = _customerService.GetCustomersByIds(allMembersCustomerIds.ToArray());

            foreach (var groupPage in groupPages)
            {
                var groupMembers = allMembers.Where(x => x.GroupPageId == groupPage.Id).OrderBy(x => x.DisplayOrder);
                //setup the individual group model
                var groupModel = new TeamPageGroupPublicModel()
                {
                    CreatedOnUtc    = groupPage.DateCreated,
                    CreatedOn       = _dateTimeHelper.ConvertToUserTime(groupPage.DateCreated, DateTimeKind.Utc),
                    UpdatedOnUtc    = groupPage.DateUpdated,
                    UpdatedOn       = _dateTimeHelper.ConvertToUserTime(groupPage.DateUpdated, DateTimeKind.Utc),
                    Id              = groupPage.Id,
                    DisplayOrder    = groupPage.DisplayOrder,
                    IsDefault       = groupPage.IsDefault,
                    PaypalDonateUrl = groupPage.PayPalDonateUrl,
                    TeamPageId      = groupPage.TeamId,
                    Name            = groupPage.Name,
                    Description     = groupPage.Description,
                    GroupMembers    = new List <CustomerProfilePublicModel>()
                };
                //add customers' public models to the list
                foreach (var member in groupMembers)
                {
                    var memberCustomer = allCustomers.First(x => x.Id == member.CustomerId);
                    groupModel.GroupMembers.Add(memberCustomer.ToPublicModel(_workContext, _customerProfileViewService,
                                                                             _customerProfileService, _pictureService, _mediaSettings, Url));
                }

                //add this group model to the output list
                listTeamPageGroups.Add(groupModel);
            }
            return(listTeamPageGroups);
        }