示例#1
0
        public async Task <bool> CreateChannel(Domain.Channel channel)
        {
            var Channel = new Domain.Channel()
            {
                AdminId   = channel.AdminId,
                Caption   = channel.Caption,
                ChannelId = channel.ChannelId,
                ImgPath   = "",
                Messages  = new List <Message>(),
                Name      = channel.Name,
                Status    = false,
                Users     = new List <User>()
                {
                    channel.Users.FirstOrDefault()
                }
            };

            try
            {
                await _channel.InsertOneAsync(Channel);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public void RemoveChannel(string userId, string channelName)
        {
            if (string.IsNullOrWhiteSpace(userId))
            {
                throw new ArgumentException($"The {nameof(userId)} argument requires a value.", nameof(userId));
            }
            if (string.IsNullOrWhiteSpace(channelName))
            {
                throw new ArgumentException($"The {nameof(channelName)} argument requires a value.", nameof(channelName));
            }

            Domain.Channel channel = GetChannel(userId, channelName);
            if (channel == default)
            {
                throw new Exception($"The '{channelName}' is not currently in the list of channel to host.");
            }



            channel.IsDeleted = true;
            _tableClient.UpsertEntity(channel);
        }
示例#3
0
 public Channel(Domain.Channel c)
 {
     ChannelId = c.ChannelId;
     Name      = c.Name;
 }