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 })); }
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")); }
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(); }