Skip to content

Commit

Permalink
add odata example for post and delete related entities via OData
Browse files Browse the repository at this point in the history
  • Loading branch information
rochar committed Aug 8, 2023
1 parent 6960747 commit 0c2d091
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/SampleWebApp/Controllers/CountriesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public async Task<IResult> GetCountriesIManage()

/// <summary>
/// Example using OData Reference Routing <see cref="https://learn.microsoft.com/en-us/odata/webapi-8/fundamentals/ref-routing?tabs=net60%2Cvisual-studio"/>
/// Delete /countries/{key}/currencies/{relatedKey}
/// </summary>
/// <returns></returns>
public async Task<IResult> DeleteRefToCurrencies([FromRoute] string key, [FromRoute] int relatedKey)
Expand All @@ -52,4 +53,16 @@ public async Task<IResult> DeleteUnConventional(DeleteCountryContactCommand comm
await Task.Delay(100);
return Results.Ok(true);
}

/// <summary>
/// Example of adding a Related entity to Countries
/// POST /countries/{key}/currencies
/// with a json body
/// </summary>

public async Task<IResult> PostToCurrencies([FromRoute] string key, [FromBody] SampleWebApp.Application.Dto.CurrencyCreateDto currency)
{
await Task.Delay(100);
return Results.Ok(true);
}
}

0 comments on commit 0c2d091

Please sign in to comment.