Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,18 @@ private async Task<int> GetLevelAsync(IDictionaryItem item, int level = 0)
}

public override async Task SaveItemAsync(IDictionaryItem item)
=> _ = item.HasIdentity
{
var attempt = item.HasIdentity
? await _dictionaryItemService.UpdateAsync(item, Constants.Security.SuperUserKey)
: await _dictionaryItemService.CreateAsync(item, Constants.Security.SuperUserKey);

if (attempt.Success is false)
{
throw new InvalidOperationException(
$"Could not save dictionary item {item.ItemKey}: {attempt.Status}");
}
}

public override Task DeleteItemAsync(IDictionaryItem item)
=> _dictionaryItemService.DeleteAsync(item.Key, Constants.Security.SuperUserKey);

Expand Down
10 changes: 9 additions & 1 deletion uSync.Core/Serialization/Serializers/LanguageSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,18 @@ public override bool IsValid(XElement node)
=> Task.FromResult(default(ILanguage));

public override async Task SaveItemAsync(ILanguage item)
=> _ = item.HasIdentity
{
var attempt = item.HasIdentity
? await _languageService.UpdateAsync(item, Constants.Security.SuperUserKey)
: await _languageService.CreateAsync(item, Constants.Security.SuperUserKey);

if (attempt.Success is false)
{
throw new InvalidOperationException(
$"Could not save language {item.IsoCode}: {attempt.Status}");
}
}

public override Task DeleteItemAsync(ILanguage item)
=> _languageService.DeleteAsync(item.IsoCode, Constants.Security.SuperUserKey);

Expand Down
12 changes: 11 additions & 1 deletion uSync.Core/Serialization/Serializers/WebhookSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,17 @@ public override string ItemAlias(IWebhook item)
/// <inheritdoc/>
///
public override async Task SaveItemAsync(IWebhook item)
=> _ = item.HasIdentity ? await _webhookService.UpdateAsync(item) : await _webhookService.CreateAsync(item);
{
var attempt = item.HasIdentity
? await _webhookService.UpdateAsync(item)
: await _webhookService.CreateAsync(item);

if (attempt.Success is false)
{
throw new InvalidOperationException(
$"Could not save webhook {item.Key}: {attempt.Status}");
}
}

/// <inheritdoc/>
protected override async Task<SyncAttempt<IWebhook>> DeserializeCoreAsync(XElement node, SyncSerializerOptions options)
Expand Down
Loading