This commit is contained in:
2020-07-30 23:48:32 +00:00
parent dfa47ab89f
commit 3b8b29f277
6 changed files with 205 additions and 134 deletions

View File

@@ -262,11 +262,60 @@ namespace AyaNova.Api.Controllers
}
private bool UserExists(long id)
/// <summary>
/// Get list of Users
/// (rights to User object required)
/// </summary>
/// <returns>All "inside" Users (except Customer and HeadOffice type)</returns>
[HttpGet("list")]
public async Task<IActionResult> GetInsideUserList()
{
return ct.User.Any(z => z.Id == id);
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.User))
return StatusCode(403, new ApiNotAuthorizedResponse());
var ret = await ct.User.Where(z => z.UserType != UserType.Customer && z.UserType != UserType.HeadOffice).Select(z => new dtUser
{
Id = z.Id,
Active = z.Active,
Name = z.Name,
Roles = z.Roles,
UserType = z.UserType,
EmployeeNumber = z.EmployeeNumber,
LastLogin = z.LastLogin
}).ToListAsync();
return Ok(ApiOkResponse.Response(ret));
}
/// <summary>
/// Get list of Customer / Head office Users
/// (Rights to Customer object required)
/// </summary>
/// <returns>All "outside" Users (No staff or contractors)</returns>
[HttpGet("outlist")]
public async Task<IActionResult> GetOutsideUserList()
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.Customer))
return StatusCode(403, new ApiNotAuthorizedResponse());
var ret = await ct.User.Where(z => z.UserType == UserType.Customer || z.UserType == UserType.HeadOffice).Select(z => new dtUser
{
Id = z.Id,
Active = z.Active,
Name = z.Name,
UserType = z.UserType,
LastLogin = z.LastLogin
}).ToListAsync();
return Ok(ApiOkResponse.Response(ret));
}
//------------