Exemplo n.º 1
0
        /// <summary>
        ///     Remove a generated channel.
        /// </summary>
        /// <param name="channel">tThe generated channel object.</param>
        /// <exception cref="InvalidChannelException">Thrown if the channel doesn't exist.</exception>
        public async Task RemoveGeneratedChannel(GeneratedChannel channel)
        {
            if (channel == null || channel.ServerId == 0 || channel.ChannelId == 0)
            {
                throw new InvalidChannelException("The generated channel doesn't exist in the database.");
            }

            await _dbGenerated.Remove(channel);
        }
Exemplo n.º 2
0
        public async Task Update(GeneratedChannel value)
        {
            //try
            //{
            //    var entry = Context.Attach(value);
            //    entry.State = EntityState.Modified;
            //}
            //catch
            //{
            //    //ignore
            //}

            Context.GeneratedChannels.Update(value);
            await Context.SaveChangesAsync();
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Register a generated channel.
        /// </summary>
        /// <param name="serverId">The id of the server.</param>
        /// <param name="channelId">The id of the channel.</param>
        /// <exception cref="ChannelExistsException">Thrown if the channel is already registered.</exception>
        public async Task AddGeneratedChannel(ulong serverId, ulong channelId)
        {
            var channel = await _dbGenerated.Get(serverId, channelId);

            if (channel != null)
            {
                throw new ChannelExistsException("The generated channel already exists in the database.");
            }

            channel = new GeneratedChannel
            {
                ServerId  = serverId,
                ChannelId = channelId
            };
            await _dbGenerated.Add(channel);
        }
Exemplo n.º 4
0
 public async Task Remove(GeneratedChannel value)
 {
     Context.GeneratedChannels.Remove(value);
     await Context.SaveChangesAsync();
 }
Exemplo n.º 5
0
 public async Task Add(GeneratedChannel value)
 {
     Context.GeneratedChannels.Add(value);
     await Context.SaveChangesAsync();
 }