private List <RoleDTO> GetRoles(int userPk) { var roleUserMappings = mappingUserRoleQuery.GetByUserPK(userPk); var roleGroups = new List <RoleGroupDTO>(); var mappingRoleToRoleGroups = new List <MappingRoleToRoleGroupDTO>(); var roles = new List <RoleDTO>(); foreach (var mapping in roleUserMappings) { var roleGroup = roleGroupQuery.GetByPrimaryKey((int)mapping.RoleGroup_PK); roleGroups.Add(roleGroup); } foreach (var roleGroup in roleGroups) { var mappingRoleToRoleGroupRecords = mappingRoleToRoleGroupQuery.GetByRoleGroupPK(roleGroup.RoleGroup_PK); foreach (var mappingRoleToRoleGroup in mappingRoleToRoleGroupRecords) { mappingRoleToRoleGroups.Add(mappingRoleToRoleGroup); } } foreach (var mappingRoleToRoleGroup in mappingRoleToRoleGroups) { var role = roleQuery.GetByPrimaryKey((int)mappingRoleToRoleGroup.Role_PK); roles.Add(role); } return(roles); }
public IHttpActionResult Get(int id) { ThrowIfUserHasNoRole(readRole); using (RoleQuery roleQuery = new RoleQuery(Db)) { var data = roleQuery.GetByPrimaryKey(id); SaveLog("Role", "Get", JsonConvert.SerializeObject(new { primaryKey = id })); return(Ok(new SuccessResponse(data))); } }
public IHttpActionResult Get(int id) { string accessType = "Role_ViewAll"; ThrowIfUserCannotAccess(accessType); using (RoleQuery roleQuery = new RoleQuery(Db)) { var data = roleQuery.GetByPrimaryKey(id); SaveLog("Role", "Get", JsonConvert.SerializeObject(new { primaryKey = id })); return(Ok(new SuccessResponse(data))); } }
private RoleEntryModel GetUpdateStateModel(int rolePK) { RoleEntryFormData formData = new RoleEntryFormData(); List <Control> formControls = CreateFormControls(rolePK); RoleDTO roleDTO = roleQuery.GetByPrimaryKey(rolePK); if (roleDTO == null) { throw new KairosException($"Record with primary key '{roleDTO.Role_PK}' is not found."); } return(new RoleEntryModel() { FormData = formData, FormControls = formControls, Model = roleDTO, }); }