This commit is contained in:
@@ -76,6 +76,8 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
List<KeyValuePair<string, string>> ret = new List<KeyValuePair<string, string>>();
|
||||
ret.Add(new KeyValuePair<string, string>(StringUtil.TrimTypeName(typeof(UserType).ToString()), "AyaNova user account types"));
|
||||
ret.Add(new KeyValuePair<string, string>("insideusertype", "AyaNova user account types for staff / contractors"));
|
||||
ret.Add(new KeyValuePair<string, string>("outsideusertype", "AyaNova user account types for customer / headoffice users"));
|
||||
ret.Add(new KeyValuePair<string, string>(StringUtil.TrimTypeName(typeof(AuthorizationRoles).ToString()), "AyaNova user account role types"));
|
||||
ret.Add(new KeyValuePair<string, string>(StringUtil.TrimTypeName(typeof(AyaType).ToString()), "All AyaNova object types"));
|
||||
ret.Add(new KeyValuePair<string, string>("Core", "All Core AyaNova business object types"));
|
||||
@@ -169,23 +171,43 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
else if (keyNameInLowerCase == StringUtil.TrimTypeName(typeof(UserType).ToString()).ToLowerInvariant())
|
||||
{
|
||||
TranslationKeysToFetch.Add("UserTypeAdministrator");
|
||||
|
||||
TranslationKeysToFetch.Add("UserTypeService");
|
||||
TranslationKeysToFetch.Add("UserTypeNotService");
|
||||
TranslationKeysToFetch.Add("UserTypeCustomer");
|
||||
TranslationKeysToFetch.Add("UserTypeHeadOffice");
|
||||
TranslationKeysToFetch.Add("UserTypeServiceContractor");
|
||||
TranslationKeysToFetch.Add("UserTypeUtility");
|
||||
var LT = await TranslationBiz.GetSubsetStaticAsync(TranslationKeysToFetch, translationId);
|
||||
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeAdministrator"], Id = (long)UserType.Administrator });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeService"], Id = (long)UserType.Service });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeNotService"], Id = (long)UserType.NotService });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeCustomer"], Id = (long)UserType.Customer });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeHeadOffice"], Id = (long)UserType.HeadOffice });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeUtility"], Id = (long)UserType.Utility });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeServiceContractor"], Id = (long)UserType.ServiceContractor });
|
||||
}
|
||||
else if (keyNameInLowerCase == "insideusertype")
|
||||
{
|
||||
|
||||
TranslationKeysToFetch.Add("UserTypeService");
|
||||
TranslationKeysToFetch.Add("UserTypeNotService");
|
||||
TranslationKeysToFetch.Add("UserTypeServiceContractor");
|
||||
var LT = await TranslationBiz.GetSubsetStaticAsync(TranslationKeysToFetch, translationId);
|
||||
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeService"], Id = (long)UserType.Service });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeNotService"], Id = (long)UserType.NotService });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeServiceContractor"], Id = (long)UserType.ServiceContractor });
|
||||
}
|
||||
else if (keyNameInLowerCase == "outsideusertype")
|
||||
{
|
||||
|
||||
|
||||
TranslationKeysToFetch.Add("UserTypeCustomer");
|
||||
TranslationKeysToFetch.Add("UserTypeHeadOffice");
|
||||
var LT = await TranslationBiz.GetSubsetStaticAsync(TranslationKeysToFetch, translationId);
|
||||
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeCustomer"], Id = (long)UserType.Customer });
|
||||
ReturnList.Add(new NameIdItem() { Name = LT["UserTypeHeadOffice"], Id = (long)UserType.HeadOffice });
|
||||
}
|
||||
else if (keyNameInLowerCase == StringUtil.TrimTypeName(typeof(AyaEvent).ToString()).ToLowerInvariant())
|
||||
{
|
||||
TranslationKeysToFetch.Add("EventDeleted");
|
||||
@@ -355,7 +377,7 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
ReturnList.Add(new NameIdItem() { Name = $"Unknown enum type list key value {enumKey}", Id = (long)UserType.Administrator });
|
||||
ReturnList.Add(new NameIdItem() { Name = $"Unknown enum type list key value {enumKey}", Id = 0 });
|
||||
}
|
||||
|
||||
return ReturnList;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
//------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user