public static IPlanshetViewData InitialTabs(ChannelTab privateData, ChannelTab groupData,
                                                    ChannelTab allianceData)
        {
            var tabsData = new List <IPlanshetBodyTemplate> {
                new PlanshetBodyTemplate {
                    LastId       = 1,
                    TemplateData = privateData,
                    TemplateUrl  = PrivateTmpl
                },
                new PlanshetBodyTemplate {
                    LastId       = 1,
                    TemplateData = groupData,
                    TemplateUrl  = GroupTmpl
                },
                new PlanshetBodyTemplate {
                    LastId       = 1,
                    TemplateData = allianceData,
                    TemplateUrl  = AllianceTmpl
                }
            };


            var listNames = new List <string> {
                Resource.Privates, Resource.Groups, Modules.Localize.Game.Alliance.Resource.Alliance
            };


            return(PlanshetTabHelper.SetTabData(UserChannelsPlanshetId, Resource.Messages, listNames, tabsData,
                                                UserChannelsHtmlDirRoot, TabIds));
        }
        public void SetChannelsTabsData(IDbConnection connection, IChannelRepository channelR, IChannelMessageRepository mesR, IChannelConnectionRepository conR, int userId, int allianceId,
                                        bool allianceRoleMessageSend)
        {
            var privateCollection = new Dictionary <int, IBaseChannelOut>();
            var groupCollection   = new Dictionary <int, IBaseChannelOut>();
            Dictionary <int, IBaseChannelOut> allianceCollection = null;
            var provider = channelR.Provider;
            var channelConnectionTbName = conR.SchemeTableName;
            var channelTableName        = channelR.SchemeTableName;
            var ch          = ChannelExtensions.SqlAliaceChannel;
            var chCon       = ChannelExtensions.SqlAliaceChannelConnection;
            var sqlChannels = $"SELECT {chCon}.messageSend as messageSend, {ch}.* FROM {channelConnectionTbName} AS {chCon} " +
                              $"JOIN {channelTableName} AS {ch} ON {ch}.Id = {chCon}.channelId " +
                              $"WHERE {chCon}.userId={userId} AND {chCon}.messageRead=1 AND {ch}.password={chCon}.password";

            var channelData = provider.Text <dynamic>(connection, sqlChannels);
            var channels    = channelData.Select(i => new {
                channelData = channelR.ConvertToWorkModel(((object)i).ToSerealizeString().ToSpecificModel <channel>()),
                messageSend = (bool)i.messageSend
            }
                                                 );

            foreach (var channel in channels)
            {
                switch (channel.channelData.ChannelType)
                {
                case ChannelTypes.Group:
                    var gChOut = new GroupChannelOut(channel.channelData, userId);
                    gChOut.SetMessages(connection, mesR);
                    gChOut.SetComplexButtonView();
                    gChOut.SetBtnSend(channel.messageSend);
                    gChOut.SetUsersIfCanMansge(connection, conR);
                    groupCollection.Add(gChOut.ChannelId, gChOut);


                    break;

                case ChannelTypes.Private:
                    var pChOut = new PrivateChannelOut(channel.channelData);
                    pChOut.SetMessages(connection, mesR);
                    pChOut.SetComplexButtonView();
                    pChOut.SetBtnSend(channel.messageSend);

                    privateCollection.Add(pChOut.ChannelId, pChOut);
                    break;

                case ChannelTypes.Alliance:
                    if (allianceCollection != null)
                    {
                        throw new NotImplementedException("AllianceChannel !=null");
                    }
                    var allianceChannel = new AllianceChannelOut(channel.channelData);
                    allianceChannel.SetMessages(connection, mesR);
                    allianceChannel.SetComplexButtonView();
                    allianceChannel.SetBtnSend(allianceRoleMessageSend);

                    allianceCollection = new Dictionary <int, IBaseChannelOut>(1)
                    {
                        { allianceChannel.ChannelId, allianceChannel }
                    };
                    break;

                default:
                    throw new NotImplementedException();
                }
            }


            Private = new ChannelTab(privateCollection);
            Group   = new ChannelTab(groupCollection)
            {
                MaxChannelsLimit = (int)MaxLenghtConsts.GroupChannelsLimit
            };
            Alliance = new ChannelTab(allianceCollection);
        }