This commit is contained in:
2020-11-18 14:51:50 +00:00
parent 4a3e7dbcb3
commit aee2bbcdfa
4 changed files with 29 additions and 18 deletions

View File

@@ -301,25 +301,29 @@ namespace AyaNova.Api.Controllers
[HttpGet("outlist")]
public async Task<IActionResult> GetOutsideUserList()
{
if (!serverState.IsOpen)
if (!serverState.IsOpen)
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
var ret = await ct.User.Include(o => o.UserOptions).Where(z => z.UserType == UserType.Customer || z.UserType == UserType.HeadOffice).Select(z => new
{
Id = z.Id,
Active = z.Active,
Name = z.Name,
UserType = z.UserType,
LastLogin = z.LastLogin
LastLogin = z.LastLogin,
EmailAddress = z.UserOptions.EmailAddress,
Phone1 = z.UserOptions.Phone1,
Phone2 = z.UserOptions.Phone2,
Phone3 = z.UserOptions.Phone3
}).ToListAsync();
return Ok(ApiOkResponse.Response(ret));
}
/// <summary>
/// <summary>
/// Get list of Customer Contact Users
/// (Rights to Customer object required)
/// </summary>
@@ -327,19 +331,23 @@ namespace AyaNova.Api.Controllers
[HttpGet("customer-contacts/{customerId}")]
public async Task<IActionResult> GetClientContactList(long customerId)
{
if (!serverState.IsOpen)
if (!serverState.IsOpen)
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.CustomerId==customerId).Select(z => new dtUser
var ret = await ct.User.Include(o => o.UserOptions).Where(z => z.UserType == UserType.Customer && z.CustomerId == customerId).Select(z => new
{
Id = z.Id,
Active = z.Active,
Name = z.Name,
UserType = z.UserType,
LastLogin = z.LastLogin
LastLogin = z.LastLogin,
EmailAddress = z.UserOptions.EmailAddress,
Phone1 = z.UserOptions.Phone1,
Phone2 = z.UserOptions.Phone2,
Phone3 = z.UserOptions.Phone3
}).ToListAsync();
return Ok(ApiOkResponse.Response(ret));