Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while update Role #208

Open
anasseb opened this issue Jun 25, 2022 · 5 comments
Open

Error while update Role #208

anasseb opened this issue Jun 25, 2022 · 5 comments

Comments

@anasseb
Copy link

anasseb commented Jun 25, 2022

Hello,
I think there is a regression in the front while updating role, before there was no bug, this month I tried to update a role and I have the error bellow
Unhandled exception rendering component: The given key 'PermissionViewModel { Description = View Dashboard, Action = View, Resource = Dashboard, IsBasic = False, IsRoot = False, Name = Permissions.Dashboard.View, Enabled = True }' was not present in the dictionary.

I download the last version in this repo and the error existe too.

To reproduce, juste go to Basic role and check or uncheck any field then save.

@fretje
Copy link
Contributor

fretje commented Jun 27, 2022

The actual role seems to be saved successfully though...

Not sure what's going on. I have a suspicion it has something to do with the fact that PermissionViewModel is a record in stead of a regular class...

@fretje
Copy link
Contributor

fretje commented Jun 27, 2022

Indeed like I thought... Adding an Equals method to PermissionViewModel that delegates to the base (FSHPermission) seems to get rid of the exception (otherwise it also takes the Enabled property into account when comparing):

public sealed record PermissionViewModel : FSHPermission
{
    public bool Enabled { get; set; }

    public PermissionViewModel(string Description, string Action, string Resource, bool IsBasic = false, bool IsRoot = false)
        : base(Description, Action, Resource, IsBasic, IsRoot)
    {
    }

    public bool Equals(PermissionViewModel? other) => base.Equals(other);
    public override int GetHashCode() => base.GetHashCode();
}

@anasseb
Copy link
Author

anasseb commented Jun 27, 2022

I'll test that and give you a feedback

@anasseb
Copy link
Author

anasseb commented Jul 3, 2022

Worked fine after adding the Equals method.
Thanks

@anasseb anasseb closed this as completed Jul 3, 2022
@fretje
Copy link
Contributor

fretje commented Jul 4, 2022

This shouldn't be closed as long as it isn't fixed in the actual repo... You're welcome to create a PR ;-)

@anasseb anasseb reopened this Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants