Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 4
0
    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);
    }
Ejemplo n.º 5
0
        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());
        }
Ejemplo n.º 6
0
        protected virtual string GetUrlFor(string controllerName, string actionName, object values = null)
        {
            var url = UrlHelper.ActionLink(actionName, controllerName, values);

            return(url);
        }