This commit is contained in:
@@ -9,13 +9,7 @@ using AyaNova.Api.ControllerHelpers;
|
||||
using AyaNova.Biz;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using AyaNova.Util;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
using AyaNova.Models;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using EnumsNET;
|
||||
|
||||
namespace AyaNova.Api.Controllers
|
||||
{
|
||||
@@ -169,7 +163,18 @@ namespace AyaNova.Api.Controllers
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
if (!Authorized.HasSelectRole(HttpContext.Items, AyaType.WorkOrderStatus))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
return Ok(ApiOkResponse.Response(await ct.WorkOrderStatus.AsNoTracking().OrderBy(z => z.Name).ToListAsync()));
|
||||
var allStates = await ct.WorkOrderStatus.AsNoTracking().OrderBy(z => z.Name).ToListAsync();
|
||||
var currentUserRoles = UserRolesFromContext.Roles(HttpContext.Items);
|
||||
var allowedStates = allStates.Where(z => currentUserRoles.HasAnyFlags(z.SelectRoles)).ToList();
|
||||
|
||||
// foreach (var item in rpts)
|
||||
// {
|
||||
// if (CurrentUserRoles.HasAnyFlags(item.roles))
|
||||
// {
|
||||
// ret.Add(new NameIdItem() { Name = item.name, Id = item.id });
|
||||
// }
|
||||
// }
|
||||
return Ok(ApiOkResponse.Response(new { all = allStates, allowed = allowedStates }));
|
||||
}
|
||||
|
||||
//------------
|
||||
|
||||
Reference in New Issue
Block a user