v1.2.0
This commit is contained in:
@@ -39,8 +39,16 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
/// </summary>
|
||||
public bool UserHasOrganisationRole(SysId userAccountId, SysId organisationId, Sax.OrganisationRole organisationRole, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId) || !SysId.IsValid(organisationId) || organisationRole <= 0) return false;
|
||||
return GetOrganisationRolesForUser(userAccountId, organisationId, statusCat).Contains(organisationRole);
|
||||
return UserHasAnyOrganisationRole(userAccountId, organisationId, new [] { organisationRole }, statusCat);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does the user have any of the specified roles with the organisation.
|
||||
/// </summary>
|
||||
public bool UserHasAnyOrganisationRole(SysId userAccountId, SysId organisationId, IEnumerable<Sax.OrganisationRole> organisationRoles, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId) || !SysId.IsValid(organisationId) || organisationRoles.IsEmpty() || !organisationRoles.Any(item => item > 0)) return false;
|
||||
return GetOrganisationRolesForUser(userAccountId, organisationId, statusCat).Any(item => organisationRoles.Contains(item));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -67,24 +75,40 @@ namespace Saxonite.Net.Standard.Base.Mgr
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get list of organisation Ids that the user has the specified role with.
|
||||
/// Get list of organisation Ids and names that the user has the specified role with.
|
||||
/// </summary>
|
||||
public List<OrganisationIdName> GetOrganisationsForUserRole(SysId userAccountId, Sax.OrganisationRole organisationRole, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly)
|
||||
{
|
||||
List<OrganisationIdName> organisationsData = new List<OrganisationIdName>();
|
||||
String organisationRoleCode = Internals.OrganisationRoleCodes.GetCodeForType(organisationRole);
|
||||
if (!SysId.IsValid(userAccountId) || StringUtil.IsEmpty(organisationRoleCode)) return organisationsData;
|
||||
// Columns.
|
||||
ColumnDfn colOrganisationId = GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationId);
|
||||
ColumnDfn colOrganisationName = GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Name);
|
||||
return GetOrganisationsForAnyUserRole(userAccountId, new [] { organisationRole }, statusCat);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get list of organisation Ids and names that the user has any of the specified roles with.
|
||||
/// </summary>
|
||||
public List<OrganisationIdName> GetOrganisationsForAnyUserRole(SysId userAccountId, IEnumerable<Sax.OrganisationRole> organisationRoles, SaxUserOrganisation.StatusCat statusCat = SaxUserOrganisation.StatusCat.ActiveOnly)
|
||||
{
|
||||
if (!SysId.IsValid(userAccountId) || organisationRoles.IsEmpty() || !organisationRoles.Any(item => item > 0)) return null;
|
||||
// Filter.
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmUserOrganisation.OrganisationStatusCat = SaxOrganisation.StatusCat.ActiveOnly;
|
||||
prmUserOrganisation.OrganisationMembersOnly = true;
|
||||
prmUserOrganisation.OrganisationRoles.Add(organisationRole);
|
||||
prmUserOrganisation.OrganisationRolesAny.AddRange(organisationRoles);
|
||||
prmUserOrganisation.StatusCat = statusCat;
|
||||
prmUserOrganisation.SortColumns.Add(colOrganisationName);
|
||||
return GetOrganisations(prmUserOrganisation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get list of organisation Ids and names that matc the specified parameters.
|
||||
/// </summary>
|
||||
public List<OrganisationIdName> GetOrganisations(SaxUserOrganisation.Params prmUserOrganisation)
|
||||
{
|
||||
List<OrganisationIdName> organisationsData = new List<OrganisationIdName>();
|
||||
// Columns.
|
||||
ColumnDfn colOrganisationId = GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.OrganisationId);
|
||||
ColumnDfn colOrganisationName = GetUserOrganisationColumnDfn(SaxUserOrganisation.Column.Organisation_Name);
|
||||
if (prmUserOrganisation.SortColumns.IsEmpty())
|
||||
prmUserOrganisation.SortColumns.Add(colOrganisationName);
|
||||
// Query.
|
||||
using (DbResultSet resultSet = ExecuteUserOrganisationQuery(new List<ColumnDfn>() { colOrganisationId, colOrganisationName }, prmUserOrganisation))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user