Blog comment comments

This commit is contained in:
Paul Schneider
2024-12-15 20:48:04 +00:00
parent d4d02b967d
commit ee25a01946
10 changed files with 39 additions and 117 deletions

View File

@ -15,10 +15,11 @@ using Yavsc.Models;
using Yavsc.Services;
using Yavsc.ViewModels.Manage;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.AspNetCore.Authorization;
namespace Yavsc.Controllers
{
[Authorize]
public class ManageController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
@ -91,7 +92,10 @@ namespace Yavsc.Controllers
: "";
var user = await GetCurrentUserAsync();
long pc = _dbContext.Blogspot.Count(x => x.AuthorId == user.Id);
var model = new IndexViewModel
{

View File

@ -228,7 +228,8 @@ namespace Yavsc.Controllers
[ValidateAntiForgeryToken]
public IActionResult DeleteConfirmed(long id)
{
BlogPost blog = _context.Blogspot.Single(m => m.Id == id && m.GetOwnerId()== User.GetUserId());
var uid = User.GetUserId();
BlogPost blog = _context.Blogspot.Single(m => m.Id == id && m.AuthorId == uid );
_context.Blogspot.Remove(blog);
_context.SaveChanges(User.GetUserId());