This commit is contained in:
2020-07-31 21:02:47 +00:00
parent 7ba1f47242
commit 2ee88081d8

View File

@@ -291,7 +291,9 @@ namespace AyaNova.Api.Controllers
return Ok(ApiOkResponse.Response(ret));
}
/// <summary>
/// <summary>
/// Get list of Customer / Head office Users
/// (Rights to Customer object required)
/// </summary>
@@ -309,7 +311,7 @@ namespace AyaNova.Api.Controllers
{
Id = z.Id,
Active = z.Active,
Name = z.Name,
Name = z.Name,
UserType = z.UserType,
LastLogin = z.LastLogin
@@ -317,6 +319,27 @@ namespace AyaNova.Api.Controllers
return Ok(ApiOkResponse.Response(ret));
}
/// <summary>
/// Fetch user type (inside meaning staff or subcontractor or outside meaning customer or headoffice type user)
///
/// </summary>
/// <returns>All "inside" Users (except Customer and HeadOffice type)</returns>
[HttpGet("inside-type/{id}")]
public async Task<IActionResult> GetInsideStatus(long id)
{
//This method is used by the Client UI to determine the correct edit form to show
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasSelectRole(HttpContext.Items, AyaType.User))
return StatusCode(403, new ApiNotAuthorizedResponse());
var u = await ct.User.FirstOrDefaultAsync(z => z.Id == id);
if (u == null)
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
return Ok(ApiOkResponse.Response(u.UserType != UserType.Customer && u.UserType != UserType.HeadOffice));
}
//------------
}//eoc