This commit is contained in:
@@ -101,17 +101,15 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Get the top level ancestor of provided type and id
|
||||
/// (e.g. find the WorkOrder principle for a WorkOrderItemPart object descendent)
|
||||
/// </summary>
|
||||
/// <param name="ayaType"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="phrase"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <returns>A search result excerpt of object</returns>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>A type and id of ancestor</returns>
|
||||
[HttpGet("ancestor/{ayaType}/{id}")]
|
||||
public async Task<IActionResult> GetAncestor([FromRoute] AyaType ayaType, [FromRoute] long id, [FromQuery] string phrase, [FromQuery] int max = 80)
|
||||
public async Task<IActionResult> GetAncestor([FromRoute] AyaType ayaType, [FromRoute] long id)
|
||||
{
|
||||
if (serverState.IsClosed)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
@@ -121,20 +119,34 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
if (id == 0)
|
||||
return NotFound();
|
||||
if (id == 0)
|
||||
return NotFound();
|
||||
switch (ayaType)
|
||||
{
|
||||
case AyaType.WorkOrderItem:
|
||||
case AyaType.WorkOrderItemExpense:
|
||||
case AyaType.WorkOrderItemLabor:
|
||||
case AyaType.WorkOrderItemLoan:
|
||||
case AyaType.WorkOrderItemPart:
|
||||
case AyaType.WorkOrderItemPartRequest:
|
||||
case AyaType.WorkOrderItemScheduledUser:
|
||||
case AyaType.WorkOrderItemTask:
|
||||
case AyaType.WorkOrderItemTravel:
|
||||
return Ok(ApiOkResponse.Response(await WorkOrderBiz.GetAncestor(ayaType, id, ct), true));
|
||||
default:
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, "ayaType", "Only types with ancestors are valid"));
|
||||
|
||||
//pawn this off to biz object static methods as appropriate
|
||||
//if not in this list of types then it has no ancestor so just return the same values back
|
||||
//or, maybe just fail code so people don't think they should run every object through here when they want to open it foolishly / needlessly / ignorantely
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// var res = await Search.GetInfoAsync(ct, UserTranslationIdFromContext.Id(HttpContext.Items),
|
||||
// UserRolesFromContext.Roles(HttpContext.Items), UserIdFromContext.Id(HttpContext.Items), phrase, max, ayaType, id);
|
||||
|
||||
return Ok(ApiOkResponse.Response(res, true));
|
||||
}
|
||||
//------------
|
||||
//------------
|
||||
|
||||
|
||||
}//eoc
|
||||
}//eoc
|
||||
}//eons
|
||||
Reference in New Issue
Block a user