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

Add a few convenience implementations for UpdateDataValues on IInstance interface #102

Merged
merged 2 commits into from
Jan 3, 2023

Conversation

ivarne
Copy link
Member

@ivarne ivarne commented Dec 5, 2022

Updating DataValues on an instance requires rather ugly code in DataProcessWrite

   var instanceOwnerPartyId = int.Parse(instance.Id.Split("/")[0]);
   var instanceGuid = Guid.Parse(instance.Id.Split("/")[1]);
   var dataValues = new Dictionary<string, string?>{{key, value}};
   return await _instanceClient.UpdateDataValues(instanceOwnerPartyId, instanceGuid, new DataValues{Values = dataValues});

This PR is intended to simplify the code required, so that it can be written

    return await _instanceClient.UpdateDataValue(instance, "key", value);

Or if you want to update multiple values

    var dataValues = new Dictionary<string, string?>()
    {
        {"key1", value1},
        {"key2", value2},
    }
    return await _instanceClient.UpdateDataValues(instance, dataValues);

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

@RonnyB71 RonnyB71 added the external-contribution-❤️ Pull request from a developer outside the Altinn teams. label Dec 9, 2022
@tjololo tjololo assigned tjololo and RonnyB71 and unassigned tjololo Dec 23, 2022
@RonnyB71
Copy link
Member

RonnyB71 commented Jan 2, 2023

@ivarne - starting the new year by reviewing open issues - is this still a change you would like to have? I only had a small comment, but are happy to merge after that.

ivarne added 2 commits January 2, 2023 10:22
Added a new convenicence constructor to improve type safety when
constructing from an instance
@ivarne ivarne force-pushed the simplify_UpdateDataValues branch from 728c3e2 to ea4d900 Compare January 2, 2023 09:35
@ivarne
Copy link
Member Author

ivarne commented Jan 2, 2023

Good start of the year ❤️
I updated the code, but instead of new InstanceIdentifier(instance.Id) I added a new constructor so I could send the instance directly.

@RonnyB71 RonnyB71 merged commit aa733ab into Altinn:main Jan 3, 2023
@ivarne ivarne deleted the simplify_UpdateDataValues branch January 3, 2023 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external-contribution-❤️ Pull request from a developer outside the Altinn teams.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants