Exemple #1
0
        public ChannelEditResult SaveChannel(IChannelInfo channel)
        {
            if (channel == null)
            {
                throw new ArgumentNullException("channel");
            }

            using (ISession session = Persistance.SessionFactory.OpenSession())
                using (ITransaction transaction = session.BeginTransaction(IsolationLevel.Serializable))
                {
                    var currentChannel = session.Get <LocalChannelInfo> (channel.ChannelId);
                    if (currentChannel == null)
                    {
                        if (channel.ChannelId != 0)
                        {
                            return(ChannelEditResult.FailedChannelDoesntExist);
                        }

                        currentChannel = new LocalChannelInfo();
                    }

                    currentChannel.Name            = channel.Name;
                    currentChannel.Description     = channel.Description;
                    currentChannel.ParentChannelId = channel.ParentChannelId;
                    currentChannel.ReadOnly        = channel.ReadOnly;
                    currentChannel.UserLimit       = channel.UserLimit;

                    session.SaveOrUpdate(currentChannel);

                    transaction.Commit();
                }

            OnChannelsUpdated(EventArgs.Empty);
            return(ChannelEditResult.Success);
        }
Exemple #2
0
        private static void CreateLobby(ISession session)
        {
            var lobby = new LocalChannelInfo
            {
                Name      = "Lobby",
                IsDefault = true,
            };

            session.SaveOrUpdate(lobby);
        }
Exemple #3
0
        private static void CreateLobby(ISession session)
        {
            var lobby = new LocalChannelInfo
            {
                Name = "Lobby",
                IsDefault = true,
            };

            session.SaveOrUpdate (lobby);
        }
Exemple #4
0
        public ChannelEditResult SaveChannel(IChannelInfo channel)
        {
            if (channel == null)
                throw new ArgumentNullException ("channel");

            using (ISession session = Persistance.SessionFactory.OpenSession())
            using (ITransaction transaction = session.BeginTransaction (IsolationLevel.Serializable))
            {
                var currentChannel = session.Get<LocalChannelInfo> (channel.ChannelId);
                if (currentChannel == null)
                {
                    if (channel.ChannelId != 0)
                        return ChannelEditResult.FailedChannelDoesntExist;

                    currentChannel = new LocalChannelInfo();
                }

                currentChannel.Name = channel.Name;
                currentChannel.Description = channel.Description;
                currentChannel.ParentChannelId = channel.ParentChannelId;
                currentChannel.ReadOnly = channel.ReadOnly;
                currentChannel.UserLimit = channel.UserLimit;

                session.SaveOrUpdate (currentChannel);

                transaction.Commit();
            }

            OnChannelsUpdated (EventArgs.Empty);
            return ChannelEditResult.Success;
        }