Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

683 B
Raw Blame
using Grand.Business.Core.Interfaces.Common.Seo;
using Grand.Domain.Blogs;
using Grand.Infrastructure.Events;
using Grand.Mediator;

namespace Grand.Business.Cms.Events;

public class BlogPostDeletedEventHandler : INotificationHandler<EntityDeleted<BlogPost>>
{
    private readonly ISlugService _slugService;

    public BlogPostDeletedEventHandler(ISlugService slugService)
    {
        _slugService = slugService;
    }

    public async Task Handle(EntityDeleted<BlogPost> notification, CancellationToken cancellationToken)
    {
        var urlToDelete = await _slugService.GetBySlug(notification.Entity.SeName);
        await _slugService.DeleteEntityUrl(urlToDelete);
    }
}