public async Task <IActionResult> Create([Bind("GroupId,GroupName")] Group @group)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@group);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(@group));
        }
        public async Task <IActionResult> Create([Bind("TagId,TagName,IsActive")] Tag tag)
        {
            if (ModelState.IsValid)
            {
                _context.Add(tag);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(tag));
        }
        public async Task <IActionResult> Create([Bind("ChannelId,ChannelName,GroupId,IsActive")] Channel channel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(channel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GroupId"] = new SelectList(_context.Group, "GroupId", "GroupId", channel.GroupId);
            return(View(channel));
        }
        public async Task <IActionResult> Create([Bind("NewsId,NewsTitle,NewsContent,DayOfPost,ChannelId,IsActive,LinkImage")] News news, string[] selected)
        {
            if (ModelState.IsValid)
            {
                _context.Add(news);
                await _context.SaveChangesAsync();

                var id = news.NewsId;

                var newsToUpdate = await _context.News
                                   .Include(i => i.Channel)
                                   .Include(i => i.NewsTag)
                                   .ThenInclude(i => i.Tag)
                                   .FirstOrDefaultAsync(m => m.NewsId == id);

                UpdateNewsTags(selected, newsToUpdate);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ChannelId"] = new SelectList(_context.Channel, "ChannelId", "ChannelId", news.ChannelId);
            return(View(news));
        }