public async Task <IActionResult> SongChannelsIndex(int?id)
        {
            var user = await GetCurrentUserAsync();

            if (user == null)
            {
                return(NotFound());
            }

            var channelList = await _context.Channel
                              .Include(c => c.Song)
                              .Include(c => c.ChannelToGears)
                              .Where(c => c.SongId == id).ToListAsync();

            var songForIndex = _context.Song
                               .Where(s => s.SongId == id).FirstOrDefault();

            ChannelIndexViewModel channelIndex = new ChannelIndexViewModel();

            channelIndex.ApplicationUser = user;
            channelIndex.Channels        = channelList;
            channelIndex.Song            = songForIndex;

            return(View(channelIndex));
        }
        public async Task <IActionResult> Index()
        {
            var user = await this.userManager.GetUserAsync(User);

            var channel = new ChannelIndexViewModel()
            {
                Channels         = this.channelService.GetUserChannels(user.Id),
                IsChannelCreated = this.channelService.HaveUserCreatedChannel(user.Id)
            };

            return(View(channel));
        }
示例#3
0
        private ChannelsListViewModel ChannelsToChannelsListViewModels(List <ChannelConfig> channels)
        {
            List <ChannelIndexViewModel> channelIndexViewModels = new List <ChannelIndexViewModel>();

            channels.ForEach(channel =>
            {
                var viewModel = new ChannelIndexViewModel()
                {
                    Id    = channel.Id,
                    Title = channel.Title,
                    DevicesListViewModel = DevicesToDevicesListViewModel(channel.Devices.ToList())
                };

                channelIndexViewModels.Add(viewModel);
            });

            return(new ChannelsListViewModel()
            {
                ChannelIndexViewModels = channelIndexViewModels
            });
        }