33 lines
1,021 B
C#
33 lines
1,021 B
C#
using System.Collections.Generic;
|
|
using System.Web.Routing;
|
|
|
|
namespace Kreta.Web.Helpers.Grid
|
|
{
|
|
public class ApiUrlBuilder
|
|
{
|
|
private readonly string Controller = nameof(Controller).ToLower();
|
|
private readonly string Action = nameof(Action).ToLower();
|
|
public string Route { get; private set; }
|
|
public RouteValueDictionary RouteValues { get; private set; }
|
|
|
|
public ApiUrlBuilder(string controller, string action, IDictionary<string, object> parameters = null, string route = Constants.RouteKey.ActionApi)
|
|
{
|
|
var routeValues = new RouteValueDictionary
|
|
{
|
|
{ Controller, controller },
|
|
{ Action, action }
|
|
};
|
|
|
|
if (parameters != null)
|
|
{
|
|
foreach (var item in parameters)
|
|
{
|
|
routeValues.Add(item.Key, item.Value);
|
|
}
|
|
}
|
|
|
|
RouteValues = routeValues;
|
|
Route = route;
|
|
}
|
|
}
|
|
}
|