ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/Shared/_ConfigurePlugin.cshtml
@using Microsoft.AspNetCore.Mvc.Controllers
@using Grand.Core
@using Grand.Core.Plugins
@using Grand.Services.Authentication.External
@using Grand.Services.Cms
@using Grand.Services.Common
@using Grand.Services.Payments
@using Grand.Services.Shipping
@using Grand.Services.Tax
@inject IPluginFinder pluginFinder
@inject IWebHelper webHelper
@inject IServiceProvider serviceProvider    
@{
    var plugin = PluginManager.FindPlugin((this.ViewContext.ActionDescriptor as ControllerActionDescriptor).ControllerTypeInfo.AsType()).Instance(serviceProvider);
    var menuitem = "";

    //friendly name
    var friendlyName = plugin?.PluginDescriptor.FriendlyName;

    var configureLocale = string.Empty;
    var backToLocale = string.Empty;
    var listActionMethodName = string.Empty;
    var listControllerName = string.Empty;

    if (plugin is IPaymentMethod)
    {
        //payment plugin
        configureLocale = "Admin.Configuration.Payment.Methods.Configure";
        backToLocale = "Admin.Configuration.Payment.Methods.BackToList";
        listActionMethodName = "Methods";
        listControllerName = "Payment";
        menuitem = $"/{Constants.AreaAdmin}/Payment/Methods";
    }
    else if (plugin is IShippingRateComputationMethod)
    {
        //shipping rate computation method
        configureLocale = "Admin.Configuration.Shipping.Providers.Configure";
        backToLocale = "Admin.Configuration.Shipping.Providers.BackToList";
        listActionMethodName = "Providers";
        listControllerName = "Shipping";
        menuitem = $"/{Constants.AreaAdmin}/Shipping/Providers";
    }
    else if (plugin is ITaxProvider)
    {
        //tax provider
        configureLocale = "Admin.Configuration.Tax.Providers.Configure";
        backToLocale = "Admin.Configuration.Tax.Providers.BackToList";
        listActionMethodName = "Providers";
        listControllerName = "Tax";
        menuitem = $"/{Constants.AreaAdmin}/Tax/Providers";
    }
    else if (plugin is IExternalAuthenticationMethod)
    {
        //external auth method
        configureLocale = "Admin.Configuration.ExternalAuthenticationMethods.Configure";
        backToLocale = "Admin.Configuration.ExternalAuthenticationMethods.BackToList";
        listActionMethodName = "Methods";
        listControllerName = "ExternalAuthentication";
        menuitem = $"/{Constants.AreaAdmin}/ExternalAuthentication/Methods";
    }
    else if (plugin is IWidgetPlugin)
    {
        //widgets
        configureLocale = "Admin.ContentManagement.Widgets.Configure";
        backToLocale = "Admin.ContentManagement.Widgets.BackToList";
        listActionMethodName = "List";
        listControllerName = "Widget";
        menuitem = $"/{Constants.AreaAdmin}/Widget/List";
    }
    else if (plugin is IMiscPlugin)
    {
        //Misc plugins
        configureLocale = "Admin.Configuration.Plugins.Misc.Configure";
        backToLocale = "Admin.Configuration.Plugins.Misc.BackToList";
        listActionMethodName = "List";
        listControllerName = "Plugin";
        menuitem = $"/{Constants.AreaAdmin}/Plugin/List";
    }

    Layout = "_AdminLayout";
    //page title
    ViewBag.Title = T(configureLocale).Text + " - " + friendlyName;
    
}
<input id="active-menu-item" type="hidden" value="@menuitem" />
<div class="row">
    <div class="col-md-12">
        <div class="x_panel light form-fit">
            <div class="x_title">
                <div class="caption caption-flex">
                    <i class="fa fa-tasks"></i>
                    <div class="captionText">@T(configureLocale) - @friendlyName</div>
                    <small><i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(T(backToLocale).Text, listActionMethodName, listControllerName)</small>
                </div>
            </div>
            <div class="x_content form">
                <div class="form-horizontal">
                    <div class="form-body">
                        <div class="x_content">
                            @RenderBody()
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>