Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("CommentChannelId,ProfileId,Comment,NrLikes,NrDislikes")] CommentChannel commentChannel)
        {
            if (id != commentChannel.CommentChannelId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    commentChannelService.UpdateCommentChannel(commentChannel);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!commentChannelService.CommentChannelExists(commentChannel.CommentChannelId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProfileId"] = new SelectList(commentChannelService.GetAllProfiles(), "ProfileId", "ProfileId", commentChannel.ProfileId);
            return(View(commentChannel));
        }
Example #2
0
 public async Task <IActionResult> Create([Bind("CommentChannelId,ProfileId,Comment,NrLikes,NrDislikes")] CommentChannel commentChannel)
 {
     if (ModelState.IsValid)
     {
         commentChannelService.Create(commentChannel);
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["ProfileId"] = new SelectList(commentChannelService.GetAllProfiles(), "ProfileId", "ProfileId", commentChannel.ProfileId);
     return(View(commentChannel));
 }
Example #3
0
 public void UpdateCommentChannel(CommentChannel commentChannel)
 {
     _repo.CommentChannel.Update(commentChannel);
     _repo.Save();
 }
Example #4
0
 public void Create(CommentChannel commentChannel)
 {
     _repo.CommentChannel.Create(commentChannel);
     _repo.Save();
 }