public IPlanshetViewData Initial(IDbConnection connection, AllianceUserDataModel currentAllianceUser, IGameUserService profileService)
        {
            var userId           = currentAllianceUser.UserId;
            var allianceId       = currentAllianceUser.AllianceId;
            var allianses        = GetAlliancesByRating(connection, i => i);
            var allianceRattings = new List <IAllianceRatingOut>();

            foreach (var i in allianses)
            {
                allianceRattings.Add(SetAllianceRating(connection, i, true, profileService));
            }
            var dataSerch = new TabAllianceSerchOut {
                Collection = allianceRattings
            };

            dataSerch.AddAlianceButtons(allianceId);

            var userAlliance = _getMyAllianceFromRattingTab(connection, dataSerch.Collection, userId, allianceId, profileService);
            var role         = AllianceRoleHelper.GetByRoleId(currentAllianceUser.RoleId);

            userAlliance.AllianceTechesOut = GetAllianceTechesOut(connection, userAlliance.Id, role);
            var manageAlliance = _getManageTab(connection, currentAllianceUser, role);
            var tabs           = AllianceOut.InitialTabs(dataSerch, userAlliance, manageAlliance, _localizer);

            return(tabs);
        }
        private AllianceUserDataModel _leaveFromAlliance(IDbConnection connection, AllianceUserDataModel allianceUser, bool fromNpc)
        {
            if (allianceUser == null)
            {
                throw new NullReferenceException(Error.AllianceUserNotExist);
            }
            var npcId = (int)NpcAllianceId.Confederation;

            if (fromNpc && allianceUser.AllianceId == npcId)
            {
                //пользователь верменно не находистя ни в каком альянсе для создания своего альянса
                _aUserRepo.LeaveUserFromAlliance(connection, allianceUser.AllianceId, allianceUser.UserId, false);

                //todo  проверить на наличие флотов у пользователя и отменить

                _aUserCache.DeleteItem(allianceUser.Id);

                return(null);
            }
            else if (!fromNpc && allianceUser.AllianceId != npcId)
            {
                _aUserCache.DeleteItem(allianceUser.Id);
                var updatedUser = _aUserRepo.LeaveUserFromAlliance(connection, allianceUser.AllianceId, allianceUser.UserId, true);
                return(AddOrUpdateAllianceUser(connection, updatedUser));
            }
            throw new NotImplementedException(Error.NotPermitted);
        }
        private TabAllianceManageOut _getManageTab(IDbConnection connection, AllianceUserDataModel currentUserAllianceMember, AllianceRoleDataModel role)
        {
            var manageAlliance = new TabAllianceManageOut();

            if (role.Id == (byte)AllianceRoles.Creator)
            {
                manageAlliance.CanDeleteAlliance = true;
            }
            manageAlliance.AllianceUserRequests = GetAllianceUserRequests(connection, currentUserAllianceMember, role);
            return(manageAlliance);
        }
        private AllianceUserDataModel _joinToUserAlliance(IDbConnection connection, int newUserId, int allianceId, byte roleId = (byte)AllianceRoles.Recrut)
        {
            var user = new AllianceUserDataModel
            {
                AllianceId = allianceId,
                DateCreate = DateTime.UtcNow,
                RoleId     = roleId,
                UserId     = newUserId
            };

            return(AddOrUpdateAllianceUser(connection, user));
        }
예제 #5
0
        public AllianceUserDataModel CreateStartAllianceUser(IDbConnection connection, UserDataModel user, int toAllianceId = (int)NpcAllianceId.Confederation)
        {
            var au = new AllianceUserDataModel
            {
                AllianceId = toAllianceId,
                DateCreate = user.DateCreate,
                RoleId     = (byte)AllianceRoles.Recrut,
                UserId     = user.Id
            };
            var newAu = AddOrUpdateAllianceUser(connection, au);

            return(newAu);
        }
예제 #6
0
        private static ConnectionUser _setConnectionUser(UserDataModel user, AllianceUserDataModel allianceUser, string allianceName)
        {
            return(new ConnectionUser
            {
                AuthId = user.AuthId,
                UserId = user.Id,

                Name = user.Nickname,
                DateLeft = user.DateLastLeft,
                DateJoin = user.DateLastJoin,
                Connected = user.IsOnline,

                AllianceId = allianceUser.AllianceId,
                AllianceUserId = allianceUser.Id,
                AllianceRoleId = allianceUser.RoleId,
                AllianceName = allianceName
            });
        }
예제 #7
0
        private AllianceDataModel _addAlliance(IDbConnection connection, AllianceDataModel dataModel)
        {
            AllianceDataModel     newAllianceData        = null;
            AllianceUserDataModel newCreatorAllianceUser = null;
            AllianceTechDataModel newTeches = null;

            var tech = new BattleTeches();

            tech.CreateStartTeches();
            var newDbTeches = tech.ConvertToDbTeches().ToSerealizeString();

            var al = _aRepo.AddOrUpdate(connection, _aRepo.ConvertToEntity(dataModel));

            newAllianceData = _aRepo.ConvertToWorkModel(al);
            var au = _aUserRepo.AddOrUpdate(connection, new alliance_user
            {
                allianceId = al.Id,
                userId     = al.creatorId,
                roleId     = (byte)AllianceRoles.Creator,
                dateCreate = al.dateCreate
            });

            newCreatorAllianceUser = _aUserRepo.ConvertToWorkModel(au);

            var teches = _aTechRepo.AddOrUpdate(connection, new alliance_tech
            {
                Id           = al.Id,
                techProgress = newDbTeches
            });

            newTeches = _aTechRepo.ConvertToWorkModel(teches);
            if (newAllianceData == null || newCreatorAllianceUser == null || newTeches == null)
            {
                throw new NotImplementedException();
            }

            var lcAllianceData = _aCache.UpdateLocalItem(connection, newAllianceData);

            _aUserCache.UpdateLocalItem(connection, newCreatorAllianceUser);
            _aTechCahce.UpdateLocalItem(connection, newTeches);
            return(lcAllianceData);
        }
예제 #8
0
        public IList <AllianceUserRequestItem> GetRequestsAllianceForAllianceManage(IDbConnection connection, AllianceUserDataModel allianceUserManager, AllianceRoleDataModel role = null)
        {
            var permition = role ?? AllianceRoleHelper.GetByRoleId(allianceUserManager.RoleId);

            if (!permition.AcceptNewMembers)
            {
                throw new SecurityException(Error.NotPermitted);
            }

            var data = _armCache.LocalOperation(connection, col =>
            {
                var collection = col.Where(i => i.AllianceAccepted != ArmAllianceAcceptedStatus.Reject &&
                                           (i.FromId == allianceUserManager.AllianceId &&
                                            i.SourceType == MessageSourceType.IsAlliance ||
                                            i.ToId == allianceUserManager.AllianceId &&
                                            i.SourceType == MessageSourceType.IsUser))
                                 .OrderByDescending(i => i.DateCreate)
                                 .ToList();
                return(collection);
            });

            var usersGroups = new Dictionary <int, List <AllianceRequestMessageDataModel> >();

            foreach (var request in data)
            {
                if (!usersGroups.ContainsKey(request.ToId) && request.SourceType == MessageSourceType.IsAlliance ||
                    !usersGroups.ContainsKey(request.FromId) && request.SourceType == MessageSourceType.IsUser)
                {
                    usersGroups.Add(request.SourceType == MessageSourceType.IsAlliance ? request.ToId : request.FromId,
                                    new List <AllianceRequestMessageDataModel> {
                        request
                    });
                }
                else
                {
                    usersGroups[request.SourceType == MessageSourceType.IsAlliance ? request.ToId : request.FromId]
                    .Add(request);
                }
            }
            var result = usersGroups.Select(group =>
            {
                var allianceAccepted = ArmAllianceAcceptedStatus.NoAction;
                if (group.Value.Any(i => i.AllianceAccepted == ArmAllianceAcceptedStatus.Accept))
                {
                    allianceAccepted = ArmAllianceAcceptedStatus.Accept;
                }
                var userAccepted = group.Value.Any(i => i.UserAccepted);
                var groupName    = group.Value.First(i => i.SourceType == MessageSourceType.IsUser).FromName;

                return(new AllianceUserRequestItem
                {
                    GroupName = groupName,
                    GroupId = group.Key,
                    Messages = group.Value.OrderBy(i => i.DateCreate).ToList(),
                    AllianceAccepted = allianceAccepted,
                    UserAccepted = userAccepted
                });
            }).ToList();

            return(result);
        }
        public IAllianceUserRequests GetAllianceUserRequests(IDbConnection connection, AllianceUserDataModel allianceUserManager, AllianceRoleDataModel role = null)
        {
            if (role == null)
            {
                role = AllianceRoleHelper.GetByRoleId(allianceUserManager.RoleId);
            }
            if (!role.AcceptNewMembers)
            {
                return(null);
            }
            var aur = new AllianceUserRequests(MessageSourceType.IsAlliance)
            {
                Requests = GetRequestsAllianceForAllianceManage(connection, allianceUserManager, role)
            };

            aur.SetComplexButtonView();
            return(aur);
        }
예제 #10
0
        public AllianceUserDataModel AddOrUpdateAllianceUser(IDbConnection connection, AllianceUserDataModel newAllianceUser)
        {
            var newUser = _aUserRepo.AddOrUpdateeModel(connection, newAllianceUser);

            return(_aUserCache.UpdateLocalItem(connection, newUser));
        }
예제 #11
0
 public static ChannelConnectionDataModel CreateModelByAllianceChannel(this ChannelDataModel allianceChannel, AllianceUserDataModel allianceUser)
 {
     return(allianceChannel.CreateModelByAllianceChannel(allianceUser, AllianceRoleHelper.GetByRoleId(allianceUser.RoleId)));
 }
예제 #12
0
        public void OnUserChangeAlliance(IDbConnection connection, int oldAllianceId, AllianceUserDataModel newAllianceUserDataModel, Action <ChannelConnectionDataModel, ChannelDataModel> setNewChannelData, Action <int> setOldChannelId)
        {
            ChannelConnectionDataModel newChannelConnectionDataModel = null;
            ChannelDataModel           newChannelDataModel           = null;


            _onUserChangeAlliance(connection, oldAllianceId, newAllianceUserDataModel, (chtConn, channel) =>
            {
                newChannelConnectionDataModel = chtConn;
                newChannelDataModel           = channel;
            }, oldChannelId =>
            {
                if (oldChannelId == 0)
                {
                    throw new NullReferenceException(nameof(oldChannelId));
                }
                setOldChannelId(oldChannelId);
            });

            if (newChannelDataModel == null)
            {
                throw new NullReferenceException(nameof(newChannelDataModel));
            }
            if (newChannelConnectionDataModel == null)
            {
                throw new NullReferenceException(nameof(newChannelConnectionDataModel));
            }
            setNewChannelData(newChannelConnectionDataModel, newChannelDataModel);
        }
 public AllianceUserDataModel LeaveFromAlliance(IDbConnection connection, AllianceUserDataModel beforeLeaveAllianceUser, bool fromNpc)
 {
     return(_leaveFromAlliance(connection, beforeLeaveAllianceUser, fromNpc));
 }
예제 #14
0
 public static ChannelConnectionDataModel CreateModelByAllianceChannel(this ChannelDataModel allianceChannel, AllianceUserDataModel allianceUser, AllianceRoleDataModel role)
 {
     return(new ChannelConnectionDataModel
     {
         UserId = allianceUser.UserId,
         ChannelId = allianceChannel.Id,
         Password = allianceChannel.Password,
         MessageRead = role.MessageRead,
         MessageSend = role.MessageSend,
         ChannelType = allianceChannel.ChannelType
     });
 }
예제 #15
0
        public IList <AllianceRequestMessageDataModel> RejectRequestToAlliance(IDbConnection connection, AllianceUserDataModel currentUser, int rejectUserId, AllianceRoleDataModel role = null)
        {
            var permition = role ?? AllianceRoleHelper.GetByRoleId(currentUser.RoleId);

            if (!permition.AcceptNewMembers)
            {
                throw new SecurityException(Error.NotPermitted);
            }
            var data = _armCache.LocalOperation(connection, col =>
            {
                return(col.Where(i =>
                                 i.FromId == currentUser.AllianceId && i.ToId == rejectUserId &&
                                 i.SourceType == MessageSourceType.IsAlliance ||
                                 i.FromId == rejectUserId && i.ToId == currentUser.AllianceId &&
                                 i.SourceType == MessageSourceType.IsUser).ToList());
            });

            if (!data.Any())
            {
                return(data);
            }

            foreach (var request in data)
            {
                request.AllianceAccepted = ArmAllianceAcceptedStatus.Reject;
            }
            var dbData       = _armRepo.AddOrUpdateAllModels(connection, data);
            var newData      = _armCache.UpdateLocalItems(connection, dbData);
            var alData       = newData.FirstOrDefault(i => i.FromId == currentUser.AllianceId && i.SourceType == MessageSourceType.IsAlliance);
            var rejectedUser = data.First(i => i.FromId == rejectUserId && i.SourceType == MessageSourceType.IsUser);

            var armModel = new AllianceRequestMessageDataModel
            {
                AllianceAccepted = ArmAllianceAcceptedStatus.Reject,
                ToId             = rejectUserId,
                DateCreate       = UnixTime.UtcNow(),
                FromId           = currentUser.AllianceId,
                Message          = "Rejected",
                UserAccepted     = false,
                SourceType       = MessageSourceType.IsAlliance,
                ToName           = rejectedUser.FromName
            };

            armModel.AllianceAccepted = ArmAllianceAcceptedStatus.Reject;
            if (alData == null)
            {
                var allaince = GetAllianceById(connection, currentUser.AllianceId, false);
                if (allaince == null)
                {
                    throw new NullReferenceException(Error.AllianceNotExist);
                }
                armModel.FromName    = allaince.Name;
                armModel.CreatorIcon = allaince.Images.Icon;
            }
            else
            {
                armModel.FromName    = alData.FromName;
                armModel.CreatorIcon = alData.CreatorIcon;
            }
            var messageForUser = AddArmItem(connection, armModel);

            newData.Add(messageForUser);
            return(newData);
        }
예제 #16
0
 public ConnectionUser SetConnectionUser(IDbConnection connection, UserDataModel user, AllianceUserDataModel allianceUser, string allianceName)
 {
     return(_setConnectionUser(user, allianceUser, allianceName));
 }
예제 #17
0
 public ConnectionUser GetHubUser(IDbConnection connection, UserDataModel user, AllianceUserDataModel allianceUser, string allianceName, bool isOnline)
 {
     if (user.IsOnline == isOnline)
     {
         return(_setConnectionUser(user, allianceUser, allianceName));
     }
     user = UpdateUserOnlineStatus(connection, user, isOnline);
     return(_setConnectionUser(user, allianceUser, allianceName));
 }
예제 #18
0
 public bool HasRoleToManageMessage(IDbConnection connection, AllianceUserDataModel currentUser, int outAllianceUserId)
 {
     return(currentUser.Id == outAllianceUserId &&
            AllianceRoleHelper.GetByRoleId(currentUser.RoleId).AcceptNewMembers);
 }
        /// <summary>
        /// </summary>
        /// <exception cref="ArgumentNullException">Error.ConnectionUserNotExist</exception>
        /// <exception cref="ArgumentNullException">Error.ConnectionUserNotConnected</exception>
        /// <returns></returns>
        public async Task <bool> AllianceDisbandAlliance()
        {
            return(await _transactionAsync(async transaction =>
            {
                var connection = transaction.Connection;
                var cr = _getCurrentUser(connection);
                if (cr.AllianceRoleId != (byte)AllianceRoles.Creator)
                {
                    throw new SecurityException(Error.NotPermitted);
                }
                var oldNewAlliance = _allianceService.DisbandAlliance(connection, cr.UserId, cr.AllianceId);

                var keys = new List <OldNewAllianceKeys>
                {
                    OldNewAllianceKeys.NewAlliacne,
                    OldNewAllianceKeys.OldAlliacne,
                    OldNewAllianceKeys.OldAllianceUsers,
                    OldNewAllianceKeys.NewAllianceUsers,
                    OldNewAllianceKeys.NewChannelConnections,
                    OldNewAllianceKeys.NewChannel
                };
                foreach (var key in keys)
                {
                    if (!oldNewAlliance.ContainsKey(key))
                    {
                        throw new ArgumentException(Error.NoData, key.ToString());
                    }
                    if (oldNewAlliance[key] == null)
                    {
                        throw new NullReferenceException(key.ToString());
                    }
                }

                var excludeIds = new List <string>();
                var newAlliance = (AllianceDataModel)oldNewAlliance[OldNewAllianceKeys.NewAlliacne];
                var oldAlliance = (AllianceDataModel)oldNewAlliance[OldNewAllianceKeys.OldAlliacne];
                var oldAllianceUses = (List <AllianceUserDataModel>)oldNewAlliance[OldNewAllianceKeys.OldAllianceUsers];
                var newAllianceUses = (List <AllianceUserDataModel>)oldNewAlliance[OldNewAllianceKeys.NewAllianceUsers];
                //todo обработать чаты
                var newChannel = oldNewAlliance[OldNewAllianceKeys.NewChannel];
                var newChannelConnections = oldNewAlliance[OldNewAllianceKeys.NewChannelConnections];

                var oldUserIds = oldAllianceUses.Select(i => i.UserId).ToList();


                AllianceUserDataModel newCurrentAllianceUser = null;
                string newGroupName = null;
                var olnineUsers = new List <ConnectionUser>();
                foreach (var oldAuser in oldAllianceUses)
                {
                    var oldUser = _getOnlineSingleUser(connection, oldAuser.UserId);
                    if (oldUser == null)
                    {
                        continue;
                    }
                    var newAuser = newAllianceUses.First(au => au.UserId == oldAuser.UserId);
                    excludeIds.Add(oldUser.ConnectionId);
                    await oldUser.RemoveAllianceGroupNameAsync(Groups);
                    oldUser.SetNewAllianceData(newAuser.Id, newAlliance.Name, newAuser.RoleId, newAlliance.Id);
                    if (newGroupName == null)
                    {
                        newGroupName = await oldUser.AddOrReplaceAllianceGroupAsync(Groups);
                    }
                    else
                    {
                        await oldUser.AddOrReplaceAllianceGroupAsync(Groups);
                    }

                    var updatedUser = _hubCache.AddOrUpdateLocal(oldUser, true);

                    if (updatedUser.UserId == cr.UserId)
                    {
                        newCurrentAllianceUser = newAuser;
                    }
                    olnineUsers.Add(updatedUser);
                }

                var exludeIdsAr = excludeIds.ToArray();


                var newUserPlanshetData = _allianceGetNewPlanshet(connection, newCurrentAllianceUser);
                var t2 = (TabMyAllianceOut)newUserPlanshetData.Bodys[1].TemplateData;
                var newMembers = t2.AllianceMembers.Members.Where(member => oldUserIds.Contains(member.UserId))
                                 .ToList();
                foreach (var onlineUser in olnineUsers)
                {
                    await Clients.Client(onlineUser.ConnectionId).InvokeAsync("onAllianceDisbanded", oldAlliance.Id, onlineUser, newUserPlanshetData);
                }
                await Clients.AllExcept(exludeIdsAr).InvokeAsync("onAllianceDisbanded", oldAlliance.Id);



                //todo  Clients.Group(newGroupName, exludeIdsAr) метод вызовится повторно для клиента но клиент делает проверку на наличие пользователя в альясне перед добавлением. в любом случае нужно исправить как появится апи

                await Clients.Group(newGroupName).InvokeAsync("allianceAddNewUsersToAlliane", newMembers);
                return true;
            }));
        }
        public Dictionary <string, object> CreateUserAlliance(IDbConnection connection, string newAllianceName, AllianceUserDataModel oldCurrentAllianceUser, string currentUserName, IStoreService storeService)
        {
            if (oldCurrentAllianceUser.AllianceId != (int)NpcAllianceId.Confederation)
            {
                throw new Exception(Error.YouInAlliance);
            }

            var name = newAllianceName.ToUpper();

            name.ValidateAllianceName();
            var currentUserId = oldCurrentAllianceUser.UserId;

            var balance = storeService.BalanceCalcResultCc(connection, currentUserId, AllianceHelper.CreatePrice);
            AllianceDataModel newAlliance;

            try
            {
                var existAlliance = GetAllianceNameObj(connection, name);
                if (existAlliance != null)
                {
                    throw new Exception(Error.AllianceNameNotUnic);
                }
                var am = _createAllianceModel(name, currentUserId, currentUserName);
                newAlliance = _createAlliance(connection, am, oldCurrentAllianceUser);
                if (newAlliance.Id == 0)
                {
                    throw new NotImplementedException("unknown");
                }
            }
            catch (Exception e)
            {
                storeService.BalanceGetCc(connection, currentUserId);
                throw new Exception(e.Message, e);
            }
            var newBalance = storeService.AddOrUpdateBalance(connection, balance);
            var result     = new Dictionary <string, object>();

            result["NewBalanceCc"] = newBalance.Quantity;
            result["NewAlliance"]  = newAlliance;
            var password = Guid.NewGuid().ToString();

            result["NewChannel"] = _channelService.CreateAllianceChannel(connection, newAlliance, password);

            return(result);
        }
 // ReSharper disable once SuggestBaseTypeForParameter
 public void SetUserData(IDbConnection connection, IAllianceService allianceService, AllianceUserDataModel adm, ConnectionUser newCurrentConnectionUser)
 {
     NewCurrentConnectionUser = newCurrentConnectionUser;
     IsCurrentUser            = true;
     if (NewRole.AcceptNewMembers)
     {
         AllianceUserRequests = allianceService.GetAllianceUserRequests(connection, adm, NewRole);
     }
 }
 private IPlanshetViewData _allianceGetNewPlanshet(IDbConnection connection, AllianceUserDataModel allianceUser)
 {
     return(_allianceService.Initial(connection, allianceUser, _gameUserService));
     //todo  нет метода очиски планшетов от старых данных для всех остальных пользователей
 }
        private IPlanshetViewData _allianceSetNewPlanshetAndNotifyNewGroup(IDbConnection connection, ConnectionUser cnnectionUser, AllianceUserDataModel newAllianceUser, string newGroupName)
        {
            var newUserPlanshetData = _allianceGetNewPlanshet(connection, newAllianceUser);
            var t2        = (TabMyAllianceOut)newUserPlanshetData.Bodys[1].TemplateData;
            var newMebmer = t2.AllianceMembers.Members.FirstOrDefault(i => i.UserId == cnnectionUser.UserId);

            // todo  метод асинхронный, на  клиенте для текущего пользователя не будет добавлен
            Clients.Group(newGroupName).InvokeAsync("allianceAddNewUserToAlliane", newMebmer);
            return(newUserPlanshetData);
        }
 private AllianceDataModel _createAlliance(IDbConnection connection, AllianceDataModel allianceData, AllianceUserDataModel oldUser)
 {
     try
     {
         _leaveFromAlliance(connection, oldUser, true);
         return(AddOrUpdate(connection, allianceData));
     }
     catch (Exception)
     {
         // todo  если не получилось возвращаем пользователя в нпц альянс
         throw;
     }
 }
예제 #25
0
        private void _onUserChangeAlliance(IDbConnection connection, int oldAllianceId, AllianceUserDataModel newAllianceUserDataModel, Action <ChannelConnectionDataModel, ChannelDataModel> setNewChannelData, Action <int> setOldChannelId)
        {
            var typeChannel = (byte)ChannelTypes.Alliance;
            ChannelConnectionDataModel newChannelConnectionDataModel = null;
            ChannelDataModel           newChannelDataModel           = null;
            var channels = _channelRepo.GetChannels(connection, new List <int> {
                oldAllianceId, newAllianceUserDataModel.AllianceId
            }, typeChannel);

            if (!channels.Any())
            {
                throw new NotImplementedException("!channels.Any()");
            }
            //var channels = c.channel.Where(i =>
            //                 i.creatorId == oldAllianceId || i.creatorId == newAllianceUserDataModel.AllianceId &&
            //                 i.channelType == typeChannel).ToList();
            var oldChannel = channels.First(i => i.creatorId == oldAllianceId);
            var newChannel = channels.First(i => i.creatorId == newAllianceUserDataModel.AllianceId);

            setOldChannelId(oldChannel.Id);
            var oldConnection = _channelConnRepo.GetUserConnectedChannl(connection, oldChannel.Id, newAllianceUserDataModel.UserId, typeChannel);

            newChannelDataModel = newChannel.ConvertToWorkModel();
            var newRole = AllianceRoleHelper.GetByRoleId(newAllianceUserDataModel.RoleId);

            if (oldConnection != null)
            {
                oldConnection.password    = newChannel.password;
                oldConnection.channelId   = newChannel.Id;
                oldConnection.messageRead = newRole.MessageRead;
                oldConnection.messageSend = newRole.MessageSend;
                var updOldConnection = _channelConnRepo.Update(connection, oldConnection);
                if (!updOldConnection)
                {
                    throw new NotImplementedException();
                }

                newChannelConnectionDataModel = _channelConnRepo.ConvertToWorkModel(oldConnection);
            }
            else
            {
                var data = _channelConnRepo.AddOrUpdate(connection, new channel_connection
                {
                    userId      = newAllianceUserDataModel.UserId,
                    messageRead = newRole.MessageRead,
                    messageSend = newRole.MessageSend,
                    password    = newChannel.password,
                    channelType = newChannel.channelType,
                    channelId   = newChannel.Id
                });

                newChannelConnectionDataModel = _channelConnRepo.ConvertToWorkModel(data);
                setNewChannelData(newChannelConnectionDataModel, newChannelDataModel);
            }

            if (newChannelDataModel.ChannelConnections == null)
            {
                newChannelDataModel.ChannelConnections = new List <ChannelConnectionDataModel> {
                    newChannelConnectionDataModel
                };
            }
            else
            {
                newChannelDataModel.ChannelConnections.Add(newChannelConnectionDataModel);
            }
            setNewChannelData(newChannelConnectionDataModel, newChannelDataModel);
        }