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); }
private static void CreateLobby(ISession session) { var lobby = new LocalChannelInfo { Name = "Lobby", IsDefault = true, }; session.SaveOrUpdate(lobby); }
private static void CreateLobby(ISession session) { var lobby = new LocalChannelInfo { Name = "Lobby", IsDefault = true, }; session.SaveOrUpdate (lobby); }
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; }