public async Task <ActionResult> RemoveLogin(string loginProvider, string providerKey)
        {
            ManageMessageId?message;
            var             result = await AplicationUserService.RemoveLoginAsync(User.Identity.GetUserId(), new UserLoginInfo(loginProvider, providerKey));

            if (result.Succeeded)
            {
                var user = await AplicationUserService.FindByIdAsync(User.Identity.GetUserId());

                if (user != null)
                {
                    await AplicationSignInService.SignInAsync(user, isPersistent : false, rememberBrowser : false);
                }
                message = ManageMessageId.RemoveLoginSuccess;
            }
            else
            {
                message = ManageMessageId.Error;
            }
            return(RedirectToAction("ManageLogins", new { Message = message }));
        }
        public ActionResult Post(int?Id)
        {
            if (!Id.HasValue)
            {
                return(HomePage());
            }

            var post = postService.GetById(Id.Value);

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

            if (!post.IsActive || post.IsDelete)
            {
                return(NotActive());
            }

            string cookieKey = string.Format(CookieConstant.POST_VIEW, post.Id);

            if (!CookieHelper.Exists(cookieKey))
            {
                CookieHelper.Set(cookieKey, WebHelper.IpAddress, 1);
                post.ViewCount += 1;
                postService.Update(post);
            }

            var model = new PostDetailModel
            {
                Id              = post.Id,
                Title           = post.Title,
                Content         = post.Description,
                PicturePath     = post.Picture.FilePath,
                Url             = urlService.GetUrl(post.Id, nameof(Post)),
                User            = post.User,
                CreateDate      = post.CreateDateUtc,
                UpdateDate      = post.UpdateDateUtc,
                ViewCount       = post.ViewCount,
                CategoryName    = post.Category.Name,
                CategoryUrl     = post.Category.Url,
                AllowComment    = post.AllowComment,
                PostFormat      = post.Format,
                PostFormatValue = post.FormatValue,
                ApproveComment  = post.ApproveComment,
                CommentCount    = postService.GetCommentCount(post.Id, true),
                Tags            = tagService.GetTagsByPostId(postId: post.Id).Select(x => new TagModel
                {
                    Name = x.Name
                }).ToList()
            };

            model.User.SocialNetworks = post.User.SocialNetworks;

            if (settingService.GetByName("post.related.view").BoolValue)
            {
                model.RelatedPosts = postService.GetRelatedPosts(post.CategoryId, post.Id).Select(x => new PostModel
                {
                    Id           = x.Id,
                    Title        = x.Title,
                    PicturePath  = mediaStorageService.GetPictureUrl(x.PictureId),
                    CreateDate   = x.CreateDateUtc,
                    CategoryName = categoryService.GetById(x.CategoryId).Name,
                    User         = userService.FindByIdAsync(x.UserId).Result,
                    CommentCount = 0,
                    ViewCount    = x.ViewCount,
                    Url          = urlService.GetUrl(x.Id, nameof(Post))
                }).ToList();
            }

            if (settingService.GetByName("post.comment.enabled").BoolValue)
            {
                model.Comments = postService.GetComments(post.Id, true).Select(x => new CommentListModel
                {
                    Id            = x.Id,
                    ParentId      = x.ParentId,
                    FullName      = x.FullName,
                    Comment       = x.Commentary,
                    UserId        = x.UserId,
                    UserAvatarUrl = userService.GetById(x.UserId).Avatar.FilePath,
                    Approved      = x.Approved,
                    CreateDate    = x.CommentDateUtc.ToRelativeFormat(),
                    ChildComments = postService.GetChildComments(post.Id, x.Id, approved: true).Select(c => new CommentListModel
                    {
                        Id            = c.Id,
                        ParentId      = c.ParentId,
                        FullName      = c.FullName,
                        Comment       = c.Commentary,
                        UserId        = c.UserId,
                        UserAvatarUrl = userService.GetById(x.UserId).Avatar.FilePath,
                        Approved      = c.Approved,
                        CreateDate    = c.CommentDateUtc.ToRelativeFormat(),
                    }).ToList()
                }).ToList();
            }

            return(View(this.GetViewName(post), model));
        }