Skip to content

Commit

Permalink
[Joker.OData]: added fake keys to ODataControllerBase methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfabian committed Jan 25, 2024
1 parent bc9c3e6 commit 621311b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Joker.OData/Controllers/ODataControllerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ protected virtual async Task<IActionResult> OnPostAsync(TEntity entity)

#region Patch

public async Task<IActionResult> Patch(Delta<TEntity> delta)
[HttpPatch]
public async Task<IActionResult> Patch(object key, Delta<TEntity> delta)
{
var keys = GetKeysFromPath();

Expand Down Expand Up @@ -108,7 +109,8 @@ protected virtual Task<IActionResult> ValidatePatchAsync(Delta<TEntity> delta, T

#region Put

public async Task<IActionResult> Put([FromBody]TEntity entity)
[HttpPut]
public async Task<IActionResult> Put(object key, [FromBody]TEntity entity)
{
var validationResult = await ValidatePutAsync(entity);

Expand Down Expand Up @@ -141,7 +143,8 @@ protected virtual Task<IActionResult> ValidatePutAsync(TEntity entity)

#region Delete

public async Task<IActionResult> Delete(ODataOptions oDataOptions)
[HttpDelete]
public async Task<IActionResult> Delete(object key, ODataOptions oDataOptions)
{
return await Delete();
}
Expand Down Expand Up @@ -200,12 +203,11 @@ protected virtual async Task<IActionResult> OnCreateRef(string navigationPropert
{
var keys = GetKeysFromPath();
var keyPredicate = CreateKeysPredicate(keys);
var entity = GetAll().Where(keyPredicate).FirstOrDefault();
var entity = GetAll().Where(keyPredicate).FirstOrDefault(); //TODO: use Find in case of disabled change tracking?

if (entity == null)
return NotFound($"{nameof(TEntity)}: {keys}");


var odataPath = Request.CreateODataPath(link);

var relatedObjectKeys = GetKeysFromPath(odataPath);
Expand Down Expand Up @@ -238,7 +240,8 @@ protected virtual async Task<IActionResult> OnCreateRef(string navigationPropert

#region DeleteRef

public async Task<IActionResult> DeleteRef(string navigationProperty)
[HttpDelete]
public async Task<IActionResult> DeleteRef(object key, string navigationProperty)
{
return await OnDeleteRef(navigationProperty);
}
Expand Down

0 comments on commit 621311b

Please sign in to comment.