示例#1
0
        public async Task <IActionResult> OnPostAsync(int channelId)
        {
            ScheduledStream stream = StreamTime.ToModel();

            Channel channel = await _crudRepository.Get <Channel>(channelId);

            stream.ChannelId  = channelId;
            stream.TimeZoneId = channel.TimeZoneId;

            int?id = await _scheduledStreamService.AddScheduledStreamToChannel(stream);

            return(RedirectToPage("./Index", new { channelId }));
        }
示例#2
0
        public async Task <IActionResult> OnPostAsync(int channelId)
        {
            ScheduledStream stream = StreamTime.ToModel();

            var channel = await _context.Channels
                          .Include(x => x.ScheduledStreams)
                          .SingleAsync(x => x.Id == channelId);

            _scheduledStreamService.AddScheduledStreamToChannel(channel, stream);

            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
示例#3
0
        private void TryAddScheduledStreams()
        {
            foreach (Channel channel in _channels)
            {
                for (int i = 0; i < 2; i++)
                {
                    LocalTime localStartTime  = new LocalTime(9, 0).PlusHours(_random.Next(0, 10));
                    var       scheduledStream = new ScheduledStream
                    {
                        DayOfWeek      = (IsoDayOfWeek)_random.Next(1, 8),
                        LocalStartTime = localStartTime,
                        LocalEndTime   = localStartTime.PlusHours(_random.Next(1, 6)),
                    };
                    _scheduledStreamService.AddScheduledStreamToChannel(
                        channel, scheduledStream);
                }
            }

            _db.SaveChanges();
        }