public async Task <IActionResult> Edit(int id) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); if (await _postsService.CanEditAsync(userId, id)) { ViewBag.Id = id; return(View(await _postsService.GetByIdAsync(id))); } return(RedirectToAction("Index", "Post")); }