Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor BaseController by removing unused event notification #531

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 1 addition & 28 deletions src/Web/Grand.Web.Common/Controllers/BaseController.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using Grand.Business.Core.Interfaces.Common.Localization;
using Grand.Infrastructure.Models;
using Grand.Web.Common.DataSource;
using Grand.Web.Common.Events;
using Grand.Web.Common.Extensions;
using Grand.Web.Common.Filters;
using Grand.Web.Common.Page;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand All @@ -21,18 +18,6 @@ namespace Grand.Web.Common.Controllers;
[CustomerActivity]
public abstract class BaseController : Controller
{
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
// event notification before execute
var mediator = context.HttpContext.RequestServices.GetService<IMediator>();
await mediator.Publish(new ActionExecutingContextNotification(context, true));

await next();

//event notification after execute
await mediator.Publish(new ActionExecutingContextNotification(context, false));
}

#region Notifications

/// <summary>
Expand Down Expand Up @@ -197,8 +182,7 @@ protected virtual async Task AddLocales<TLocalizedModelLocal>(ILanguageService l
var locale = Activator.CreateInstance<TLocalizedModelLocal>();
locale.LanguageId = language.Id;

if (configure != null)
configure.Invoke(locale, locale.LanguageId);
configure?.Invoke(locale, locale.LanguageId);

locales.Add(locale);
}
Expand All @@ -216,16 +200,5 @@ protected IActionResult AccessDeniedView()
{
return RedirectToAction("AccessDenied", "Home");
}

/// <summary>
/// Access denied json data for kendo grid
/// </summary>
/// <returns>Access denied json data</returns>
protected JsonResult AccessDeniedKendoGridJson()
{
var translationService = HttpContext.RequestServices.GetRequiredService<ITranslationService>();
return ErrorForKendoGridJson(translationService.GetResource("Admin.AccessDenied.Description"));
}

#endregion
}