Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

RouteProvider.cs

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Nop.Web.Framework;
using Nop.Web.Framework.Mvc.Routing;
using Nop.Web.Infrastructure;

namespace Nop.Plugin.Tax.Avalara.Infrastructure;

/// 
/// Represents plugin route provider
/// 
public class RouteProvider : BaseRouteProvider, IRouteProvider
{
    /// 
    /// Register routes
    /// 
    /// Route builder
    public void RegisterRoutes(IEndpointRouteBuilder endpointRouteBuilder)
    {
        var lang = GetLanguageRoutePattern();

        endpointRouteBuilder.MapControllerRoute(name: AvalaraTaxDefaults.ConfigurationRouteName,
            pattern: "Admin/Avalara/Configure",
            defaults: new { controller = "Avalara", action = "Configure" });

        //override some of default routes in Admin area
        endpointRouteBuilder.MapControllerRoute(name: AvalaraTaxDefaults.TaxCategoriesRouteName,
            pattern: "Admin/Tax/Categories",
            defaults: new { controller = "AvalaraTax", action = "Categories", area = AreaNames.ADMIN });

        endpointRouteBuilder.MapControllerRoute(name: AvalaraTaxDefaults.ExemptionCertificatesRouteName,
            pattern: $"{lang}/customer/exemption-certificates",
            defaults: new { controller = "AvalaraPublic", action = "ExemptionCertificates" });

        endpointRouteBuilder.MapControllerRoute(name: AvalaraTaxDefaults.DownloadCertificateRouteName,
            pattern: "download-tax-exemption-certificate/{id:min(0)}",
            defaults: new { controller = "AvalaraPublic", action = "DownloadCertificate" });

        endpointRouteBuilder.MapControllerRoute(name: AvalaraTaxDefaults.ItemClassificationWebhookRouteName,
            pattern: "avalara/item-classification-webhook",
            defaults: new { controller = "AvalaraWebhook", action = "ItemClassificationWebhook" });
    }

    /// 
    /// Gets a priority of route provider
    /// 
    public int Priority => 1; //set a value that is greater than the default one in Nop.Web to override routes
}