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

namespace Nop.Plugin.Misc.SignalRApi.Infrastructure
{
    /// <summary>
    /// Represents plugin route provider
    /// </summary>
    public class RouteProvider : IRouteProvider
    {
        /// <summary>
        /// Register routes
        /// </summary>
        /// <param name="endpointRouteBuilder">Route builder</param>
        public void RegisterRoutes(IEndpointRouteBuilder endpointRouteBuilder)
        {
            endpointRouteBuilder.MapControllerRoute(name: "Plugin.Misc.SignalRapi.Configure",
            pattern: "Admin/SignalRApi/Configure",
            defaults: new { controller = "SignalRApiAdmin", action = "Configure", area = AreaNames.ADMIN });
            endpointRouteBuilder.MapControllerRoute(name: "Plugin.Misc.SignalRapi.TestHubConnection",
                        pattern: "Admin/SignalRApi/TestHubConnection",
                        defaults: new { controller = "SignalRApiAdmin", action = "TestHubConnection", area = AreaNames.ADMIN });
            endpointRouteBuilder.MapControllerRoute(name: "Plugin.Misc.SignalRapi.Hub",
                pattern: "SignalRApi/hub",
                defaults: new { controller = "SignalRHub", action = "Main" });
        }

        /// <summary>
        /// Gets a priority of route provider
        /// </summary>
        public int Priority => 0;
    }
}