This commit is contained in:
2021-04-05 23:11:48 +00:00
parent 4b87fbb1fb
commit 0d21545c0b
2 changed files with 14 additions and 9 deletions

View File

@@ -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 }));
}
//------------