Skip to content

Tech Debt - move entity updater to lbh core#59

Merged
LBHCallumM merged 2 commits intoreleasefrom
callum/move-entity-updater-to-lbh-core
Jan 11, 2024
Merged

Tech Debt - move entity updater to lbh core#59
LBHCallumM merged 2 commits intoreleasefrom
callum/move-entity-updater-to-lbh-core

Conversation

@LBHCallumM
Copy link
Copy Markdown
Member

Summary of changes

Many APIs use this EntityUpdater class, so I have moved it to this shared library.

EntityUpdater is used for patch endpoints, where we want to detect if any changes have been made.

Example usage:

var updaterResponse =  _updater.UpdateEntity<AssetDb, EditAssetAddressDatabase>(existingAsset, requestBody, editAddressRequest.ToDatabase());

if (updaterResponse.NewValues.Any())
{
    await _dynamoDbContext.SaveAsync<AssetDb>(updaterResponse.UpdatedEntity).ConfigureAwait(false);
}

BodyRewindMiddleware is required to get the raw request body (to get around .net serialization limitations)

For example:

var bodyText = await HttpContext.Request.GetRawBodyStringAsync().ConfigureAwait(false);

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

Successfully merging this pull request may close these issues.

2 participants