Exemple #1
0
        public async Task <ChannelConfigContainer> GetChannelConfigAsync(decimal channelId)
        {
            var match = await ChannelConfigs.SingleOrDefaultAsync(s => s.ChannelId == channelId);

            if (match != null)
            {
                return(new ChannelConfigContainer(match));
            }
            return(new ChannelConfigContainer {
                ChannelId = channelId, Broadcasters = new List <BroadcasterConfigContainer>()
            });
        }
Exemple #2
0
        public async Task <ChannelConfigContainer> SetBroadcasterConfigAsync(decimal channelId, string displayName, BroadcasterConfigContainer container)
        {
            var match = await BroadcasterConfigs.SingleOrDefaultAsync(s => s.ChannelId == channelId && s.Broadcaster == displayName);

            BroadcasterConfig broadcasterConfig;

            if (match != null) //mutate it
            {
                broadcasterConfig                     = match;
                broadcasterConfig.Broadcaster         = displayName;
                broadcasterConfig.NumberOfClipsPerDay = container.NumberOfClipsPerDay;
                broadcasterConfig.MinViews            = container.MinViews;
            }
            else
            {
                broadcasterConfig = new BroadcasterConfig
                {
                    ChannelId           = container.ChannelId,
                    Broadcaster         = displayName,
                    NumberOfClipsPerDay = container.NumberOfClipsPerDay,
                    MinViews            = container.MinViews
                };
                ChannelConfig channelConfig;
                var           parent = await ChannelConfigs.SingleOrDefaultAsync(s => s.ChannelId == channelId);

                if (parent != null)
                {
                    channelConfig = parent;
                    channelConfig.BroadcasterConfigs.Add(broadcasterConfig);
                }
                else
                {
                    channelConfig = new ChannelConfig {
                        ChannelId = channelId, BroadcasterConfigs = new List <BroadcasterConfig> {
                            broadcasterConfig
                        }
                    };
                    ChannelConfigs.Add(channelConfig);
                }
            }
            await SaveChangesAsync();

            return(new ChannelConfigContainer(broadcasterConfig.ChannelConfig));
        }
Exemple #3
0
        public async Task <ChannelConfigContainer> SetChannelConfigAsync(decimal channelId, ChannelConfigContainer container)
        {
            var match = await ChannelConfigs.SingleOrDefaultAsync(s => s.ChannelId == channelId);

            ChannelConfig channelConfig;

            if (match != null) //mutate it
            {
                channelConfig                             = match;
                channelConfig.Prefix                      = container.Prefix;
                channelConfig.MinPostingHour              = container.MinPostingHour;
                channelConfig.MaxPostingHour              = container.MaxPostingHour;
                channelConfig.NumberOfClipsAtATime        = container.NumberOfClipsAtATime;
                channelConfig.TimeSpanBetweenClipsAsTicks = container.TimeSpanBetweenClipsAsTicks;
                channelConfig.GlobalMinViews              = container.GlobalMinViews;
                channelConfig.UtcHourOffset               = container.UtcHourOffset;
                channelConfig.ClipOrder                   = container.ClipOrder;
            }
            else
            {
                channelConfig = new ChannelConfig
                {
                    Prefix                      = container.Prefix,
                    MinPostingHour              = container.MinPostingHour,
                    MaxPostingHour              = container.MaxPostingHour,
                    NumberOfClipsAtATime        = container.NumberOfClipsAtATime,
                    TimeSpanBetweenClipsAsTicks = container.TimeSpanBetweenClipsAsTicks,
                    GlobalMinViews              = container.GlobalMinViews,
                    UtcHourOffset               = container.UtcHourOffset,
                    ClipOrder                   = container.ClipOrder
                };
                ChannelConfigs.Add(channelConfig);
            }
            await SaveChangesAsync();

            return(new ChannelConfigContainer(channelConfig));
        }