public void ApplyTags(List <dtoBulkCommunityForTags> items, 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;
         if (items.Any())
         {
             List <dtoBulkCommunityForTags> cTags = View.CurrentAssignedTags;
             if (ServiceTags.ApplyTagsToCommunities(items))
             {
                 action    = ModuleTags.ActionType.BulkTagsAssigned;
                 pageIndex = (filters.WithoutTags) ? ((pageIndex > 0) ? pageIndex - 1 : pageIndex) : pageIndex;
                 foreach (dtoBulkCommunityForTags item in items)
                 {
                     dtoBulkCommunityForTags current = cTags.Where(c => c.IdCommunity == item.IdCommunity).FirstOrDefault();
                     if (current != null)
                     {
                         current.IdSelectedTags = item.IdSelectedTags;
                     }
                 }
                 View.CurrentAssignedTags = cTags;
                 filters             = RecalcDefaultFilters(filters);
                 View.CurrentFilters = filters;
                 LoadCommunities(idCommunity, filters, pageIndex, pageSize, ModuleTags.ActionType.BulkTagsUpdateListAferTagsAssignment);
             }
         }
         else
         {
             action = ModuleTags.ActionType.BulkTagsNoSelection;
         }
         View.DisplayMessage(action);
         View.SendUserAction(idCommunity, CurrentIdModule, action);
     }
 }
        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);
            }
        }