Skip to content

Commit 17f0469

Browse files
marcelkenlayChoc13
authored andcommitted
Map ConflictError to 409 response (#11)
1 parent 6936d2d commit 17f0469

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

Winton.DomainModelling.AspNetCore.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@
461461
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FRESOURCE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
462462
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
463463
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
464+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
464465
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAlwaysTreatStructAsNotReorderableMigration/@EntryIndexedValue">True</s:Boolean>
465466
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
466467
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>

src/Winton.DomainModelling.AspNetCore/ErrorExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ int GetStatusCode()
2828
return StatusCodes.Status403Forbidden;
2929
case NotFoundError _:
3030
return StatusCodes.Status404NotFound;
31+
case ConflictError _:
32+
return StatusCodes.Status409Conflict;
3133
default:
3234
return StatusCodes.Status400BadRequest;
3335
}

src/Winton.DomainModelling.AspNetCore/Winton.DomainModelling.AspNetCore.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
<ItemGroup>
3434
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.1.3" />
3535
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="All" />
36-
<PackageReference Include="Winton.DomainModelling.Abstractions" Version="1.2.0" />
36+
<PackageReference Include="Winton.DomainModelling.Abstractions" Version="1.4.0" />
3737
</ItemGroup>
38-
3938
</Project>

test/Winton.DomainModelling.AspNetCore.Tests/ErrorExtensionsTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ public sealed class ToActionResult : ErrorExtensionsTests
4343
})
4444
},
4545
new object[]
46+
{
47+
new ConflictError("An entity with id 'EntityId' already exists"),
48+
new ConflictObjectResult(
49+
new ProblemDetails
50+
{
51+
Detail = "An entity with id 'EntityId' already exists",
52+
Status = 409,
53+
Title = "Conflict",
54+
Type = "https://httpstatuses.com/409"
55+
})
56+
},
57+
new object[]
4658
{
4759
new Error("Foo error", "A generic error occurred."),
4860
new BadRequestObjectResult(

0 commit comments

Comments
 (0)