public virtual FormlyFormParams ForCreate(object additionalData = null, Dictionary <string, object> options = null) { AdditionalData = additionalData; Options = options; var config = CommonConfig(FormActionType.Create); config.SubmitUrl = UrlHelper.ActionLink(GetSubmitActionName(FormActionType.Create), ControllerName); return(config); }
public virtual FormlyFormParams ForPatch(string id) { var config = CommonConfig(FormActionType.Patch); config.GetUrl = GetUrlFor(ControllerName, GetGetActionName(), new { id }); config.SubmitUrl = UrlHelper.ActionLink(GetSubmitActionName(FormActionType.Patch), ControllerName, new { id }); config.ModelId = id; return(config); }
public override Task <TableConfig> GetTableConfig() { if (TableItemsApiUrl == null) { TableItemsApiUrl = UrlHelper.ActionLink(ServerSide ? nameof(AdminUsersAdminApiController.DtQuery) : nameof(AdminUsersAdminApiController.Index), TypeHelpers.GetControllerName(typeof(AdminUsersAdminApiController)), TableItemsApiUrlValues); } return(base.GetTableConfig()); }
public void NoRouter_ErrorsWithFriendlyErrorMessage() { // Arrange var urlHelper = new UrlHelper(new ActionContext { RouteData = new RouteData(new RouteValueDictionary()), HttpContext = new DefaultHttpContext() }); // Act var ex = Assert.Throws <InvalidOperationException>(() => urlHelper.ActionLink("contact", "home")); // Assert var expectedMessage = "Could not find an IRouter associated with the ActionContext. " + "If your application is using endpoint routing then you can get a IUrlHelperFactory with " + "dependency injection and use it to create a UrlHelper, or use Microsoft.AspNetCore.Routing.LinkGenerator."; Assert.Equal(expectedMessage, ex.Message); }
public override Task <TableConfig> GetTableConfig() { if (CreateNewItemLink == null) { CreateNewItemLink = new MRichLink( $"{_translationsRepository.GetValueOrSlug("create").Result} {TypeHelpers.GetDisplayNameOrDefault(typeof(TVm)).ToLowerFirstChar()}", typeof(TUiController), nameof(GenericAdminUiController <TE, TFm, TVm, TApiController> .Create)) .WithTag("create").AsButton("outline-primary").WithIconClasses("fas fa-plus") .WithValues(CreateNewItemLinkValues); } if (TableItemsApiUrl == null) { TableItemsApiUrl = UrlHelper.ActionLink(ServerSide ? nameof(IReadOnlyApiController <TVm> .DtQuery) : nameof(IReadOnlyApiController <TVm> .Index), TypeHelpers.GetControllerName(typeof(TApiController)), TableItemsApiUrlValues); } return(base.GetTableConfig()); }
protected virtual string GetUrlFor(string controllerName, string actionName, object values = null) { var url = UrlHelper.ActionLink(actionName, controllerName, values); return(url); }