public void ApplyTags(List <Int32> idCommunities, List <long> tags, Boolean applyToAll, lm.Comol.Core.BaseModules.CommunityManagement.dtoCommunitiesFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize)
        {
            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                ModuleTags.ActionType action = ModuleTags.ActionType.BulkTagsUnasigned;
                View.CurrentAssignedTags = new List <dtoBulkCommunityForTags>();
                pageIndex = (filters.WithoutTags) ? ((pageIndex > 0) ? pageIndex - 1 : pageIndex) : pageIndex;
                if (applyToAll)
                {
                    List <lm.Comol.Core.BaseModules.Dashboard.Domain.dtoCommunityForTags> communities = ServiceCommunities.GetCommunitiesForBulkTagsManage(UserContext.CurrentUserID, filters);
                    if (communities != null)
                    {
                        idCommunities = communities.Select(c => c.Id).ToList();
                    }
                }

                if (idCommunities.Any())
                {
                    List <dtoBulkCommunityForTags> cTags = View.CurrentAssignedTags;
                    if (ServiceTags.ApplyTagsToCommunities(idCommunities, tags).Count > 0)
                    {
                        action = ModuleTags.ActionType.BulkTagsAssigned;

                        foreach (Int32 id in idCommunities)
                        {
                            dtoBulkCommunityForTags current = cTags.Where(c => c.IdCommunity == id).FirstOrDefault();
                            if (current != null)
                            {
                                current.IdSelectedTags = tags;
                            }
                        }
                        View.CurrentAssignedTags = cTags;
                        if (applyToAll)
                        {
                            filters = ServiceCommunities.GetDefaultFilters(CurrentManager.GetLitePerson(UserContext.CurrentUserID), CommunityManagement.CommunityAvailability.All, true);
                        }
                        else
                        {
                            filters = RecalcDefaultFilters(filters);
                        }
                        View.CurrentFilters = filters;
                        View.DeselectAll();
                        LoadCommunities(idCommunity, filters, pageIndex, pageSize, ModuleTags.ActionType.BulkTagsUpdateListAferTagsAssignment);
                    }
                    else
                    {
                        LoadCommunities(idCommunity, pageIndex, pageSize);
                    }
                }
                else
                {
                    action = ModuleTags.ActionType.BulkTagsNoSelection;
                }
                View.DisplayMessage(action);
                View.SendUserAction(idCommunity, CurrentIdModule, ModuleTags.ActionType.NoPermissionForBulkTagsAssign);
            }
        }
        private lm.Comol.Core.BaseModules.CommunityManagement.dtoCommunitiesFilters RecalcDefaultFilters(lm.Comol.Core.BaseModules.CommunityManagement.dtoCommunitiesFilters filters)
        {
            List <lm.Comol.Core.BaseModules.Dashboard.Domain.dtoCommunityForTags> communities = ServiceCommunities.GetCommunitiesForBulkTagsManage(UserContext.CurrentUserID, filters);

            if (communities != null && communities.Count == 0)
            {
                return(ServiceCommunities.GetDefaultFilters(CurrentManager.GetLitePerson(UserContext.CurrentUserID), CommunityManagement.CommunityAvailability.All, true));
            }
            else
            {
                return(filters);
            }
        }
        private void LoadCommunities(Int32 idCommunity, lm.Comol.Core.BaseModules.CommunityManagement.dtoCommunitiesFilters filters, Int32 pageIndex, Int32 pageSize, ModuleTags.ActionType action, Boolean firstLoad = false)
        {
            List <lm.Comol.Core.BaseModules.Dashboard.Domain.dtoCommunityForTags> items = ServiceCommunities.GetCommunitiesForBulkTagsManage(UserContext.CurrentUserID, filters);
            Int32 itemsCount = (items == null ? 0 : items.Count);

            PagerBase pager = new PagerBase();

            pager.PageSize  = pageSize;
            pager.Count     = (itemsCount > 0) ? itemsCount - 1 : 0;
            pager.PageIndex = pageIndex;
            View.Pager      = pager;
            if (items != null)
            {
                if (firstLoad && itemsCount == 0)
                {
                    View.HideFilters();
                }
                else if (itemsCount == 0 && ServiceTags.GetCommunitiesWithNoTags() == 0)
                {
                    View.HideFilters();
                }
                View.LoadCommunities(GenerateItems(filters, items.Skip(pager.PageIndex * pageSize).Take(pageSize).ToList(), itemsCount > pageSize));
                View.SendUserAction(idCommunity, CurrentIdModule, action);
            }
            else
            {
                View.DisplayErrorFromDB();
            }
        }