/// <summary>
        /// Creates or updates a channel config based on the channelData.
        /// </summary>
        /// <param name="channelDataRepository">Channel Data repository.</param>
        /// <param name="draftChannelData">Channel data received from the web interface.</param>
        /// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
        public static async Task CreateorUpdateChannelConfig(
            this IChannelDataRepository channelDataRepository,
            ChannelData draftChannelData)
        {
            var tmpChannel = new ChannelDataEntity
            {
                PartitionKey = ChannelDataTableNames.ChannelDataPartition,
                RowKey       = draftChannelData.ChannelId,
                ChannelId    = draftChannelData.ChannelId,
                ChannelImage = draftChannelData.ChannelImage,
                ChannelTitle = draftChannelData.ChannelTitle,
            };

            await channelDataRepository.CreateOrUpdateAsync(tmpChannel);
        }
        public async Task <IActionResult> UpdateChannelAsync([FromBody] ChannelData channel)
        {
            var channelEntity = new ChannelDataEntity
            {
                PartitionKey       = ChannelDataTableName.ChannelDataPartition,
                RowKey             = channel.Id,
                Id                 = channel.Id,
                ChannelName        = channel.ChannelName,
                ChannelDescription = channel.ChannelDescription,
                ChannelAdmins      = channel.ChannelAdmins,
                ChannelAdminDLs    = channel.ChannelAdminDLs,
                ChannelAdminEmail  = channel.ChannelAdminEmail,
            };

            await this.channelDataRepository.CreateOrUpdateAsync(channelEntity);

            return(this.Ok());
        }
Example #3
0
        /// <summary>
        /// Create a new channel.
        /// </summary>
        /// <param name="channelRepository">The channel repository.</param>
        /// <param name="channel">Channel model class instance passed in from Web API.</param>
        /// <returns>The newly created channel's id.</returns>
        public static async Task <string> CreateChannelAsync(
            this IChannelDataRepository channelRepository,
            ChannelData channel)
        {
            var newId = channelRepository.TableRowKeyGenerator.CreateNewKeyOrderingOldestToMostRecent();

            var channelEntity = new ChannelDataEntity
            {
                PartitionKey       = ChannelDataTableName.ChannelDataPartition,
                RowKey             = newId,
                Id                 = newId,
                ChannelName        = channel.ChannelName,
                ChannelDescription = channel.ChannelDescription,
                ChannelAdmins      = channel.ChannelAdmins,
                ChannelAdminDLs    = channel.ChannelAdminDLs,
                ChannelAdminEmail  = channel.ChannelAdminEmail,
            };

            await channelRepository.CreateOrUpdateAsync(channelEntity);

            return(newId);
        }