public async Task <IActionResult> Edit(int id, [Bind("CommentVideoId,VideosId,Comment,NrLikes,NrDislikes")] CommentVideo commentVideo)
        {
            if (id != commentVideo.CommentVideoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    commentVideoService.UpdateCommentVideo(commentVideo);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!commentVideoService.CommentVideoExists(commentVideo.CommentVideoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VideosId"] = new SelectList(commentVideoService.GetAllVideos(), "VideosId", "VideosId", commentVideo.VideosId);

            return(View(commentVideo));
        }
 public async Task <IActionResult> Create([Bind("CommentVideoId,VideosId,Comment,NrLikes,NrDislikes")] CommentVideo commentVideo)
 {
     if (ModelState.IsValid)
     {
         commentVideoService.Create(commentVideo);
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["VideosId"] = new SelectList(commentVideoService.GetAllVideos(), "VideosId", "VideosId", commentVideo.VideosId);
     return(View(commentVideo));
 }
예제 #3
0
 public void UpdateCommentVideo(CommentVideo commentVideo)
 {
     _repo.CommentVideo.Update(commentVideo);
     _repo.Save();
 }
예제 #4
0
 public void Create(CommentVideo commentVideo)
 {
     _repo.CommentVideo.Create(commentVideo);
     _repo.Save();
 }