Example #1
0
        public async Task <ActionResult <CommentPostModel> > GetCommentPostModel(int id)
        {
            if (id <= 0)
            {
                return(NotFound());
            }

            var commentPostModel = await _commentPostServices.GetByIdAsync(id);

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

            return(commentPostModel);
        }
Example #2
0
        public async Task <IActionResult> DeleteComment(int id)
        {
            try
            {
                var userId = await GetUserIdentityAsync();

                var commentPostModel = await _commentPostServices.GetByIdAsync(id);

                if (userId == commentPostModel.IdentityUser)
                {
                    await _commentPostServices.DeleteAsync(id);
                }

                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Home"));
            }
        }