예제 #1
0
        public AllianceChannelOut GetAllianceChannelOut(IDbConnection connection, ChannelDataModel allianceChannel, ChannelConnectionDataModel crUserChannelConnection, int skip = 0)
        {
            if (!crUserChannelConnection.MessageRead)
            {
                return(null);
            }
            AllianceChannelOut result = null;
            var allianceChannelOut    = new AllianceChannelOut(allianceChannel);

            allianceChannelOut.SetMessages(connection, _channelMessageRepo, skip);
            allianceChannelOut.SetComplexButtonView();
            allianceChannelOut.SetBtnSend(crUserChannelConnection.MessageSend);
            result = allianceChannelOut;
            return(result);
        }
예제 #2
0
        public AllianceChannelOut GetAllianceChannelOut(IDbConnection connection, int allianceId, int currentUserId, AllianceRoleDataModel allianceUserRole, int skip = 0)
        {
            if (!allianceUserRole.MessageRead)
            {
                return(null);
            }
            AllianceChannelOut result = (AllianceChannelOut)null;
            var allianceChannelType   = (byte)ChannelTypes.Alliance;
            //todo передалать на процедуру
            var channelData = _channelConnRepo.Provider.GetAllianceChannelDb(connection, allianceId);

            if (channelData == null)
            {
                throw new NullReferenceException(Error.ChannelNotExist);
            }
            var connectedData        = _channelConnRepo.GetUserConnectedChannls(connection, currentUserId, allianceChannelType);
            var filtredConnectedData = connectedData.Where(i => i.ChannelData.Id == channelData.Id && i.ChannelData.password == channelData.password).ToList();

            if (!filtredConnectedData.Any())
            {
                throw new SecurityException(Error.NotPermitted);
            }
            if (filtredConnectedData.Count != 1)
            {
                throw new NotImplementedException("GetAllianceChannelOut: filtredConnectedData.Count!= 1");
            }

            var conn = filtredConnectedData[0];

            if (!conn.MessageRead)
            {
                return(null);
            }
            if (allianceUserRole.MessageSend != conn.MessageSend)
            {
                throw new NotImplementedException(Error.NotEquals);
            }

            var allianceChannel    = channelData.ConvertToWorkModel();
            var allianceChannelOut = new AllianceChannelOut(allianceChannel);

            allianceChannelOut.SetMessages(connection, _channelMessageRepo, skip);

            allianceChannelOut.SetBtnSend(allianceUserRole.MessageSend);
            result = allianceChannelOut;
            return(result);
        }