Skip to content

Extensions on helper class does not save to DB #205

@busrasengul

Description

@busrasengul

Which version of Skybrud Redirects are you using? (Please write the exact version, example: 4.0.8)

13.0.4

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.3.2

Bug description

Hey @abjerner !

Trying to extend RedirectsBackOfficeHelper as stated in the docs here

I'm overriding the Mapping functionality in order to change the destination URL, as far as I could understand that's the bit where the redirects get saved. Here's my code

    public override IEnumerable<RedirectModel> Map(IEnumerable<IRedirect> redirects)
    {
        foreach (var redirect in redirects)
        {
            redirect.Destination.Url = GetCurrentSiteDomain(redirect.Destination.Url);

            _redirectsService.SaveRedirect(redirect);
        }

        return base.Map(redirects);
    }

    public override RedirectModel Map(IRedirect redirect)
    {
        redirect.Destination.Url = GetCurrentSiteDomain(redirect.Destination.Url);

        _redirectsService.SaveRedirect(redirect);

        return base.Map(redirect);
    }

GetCurrentSiteDomain method is just getting the destination URL and adding a FE domain in front of it. I needed this extension so I can use redirects headlessly, as my BE URL is different than my FE URL.

But no matter I try and extend from RedirectsBackOfficeHelper, DB does not pick up my changes. I can see I add my custom URL to IRedirectDestination Destination model URL property, and FullUrl is picked up too, see the old and new Destination model in the screenshots, it doesn't save to DB still..

image
image
image

Am I missing anything or is this a bug?
Thanks in advance :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions