Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDAM-465 Add users and job ids for an organisation #149

Merged
merged 17 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace NICE.Identity.Authorisation.WebAPI.ApiModels
{

public class UsersAndJobIdsForOrganisation
{
public int OrganisationId { get; set; }
public Organisation Organisation { get; set; }
public List<UserAndJobId> Users { get; set; }
suegarner marked this conversation as resolved.
Show resolved Hide resolved
}

public class UserAndJobId
{
public UserAndJobId()
{
}

public int UserId { get; set; }
public User User { get; set; }
public int JobId { get; set; }
}
}
28 changes: 28 additions & 0 deletions NICE.Identity.Authorisation.WebAPI/Controllers/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,5 +429,33 @@ public IActionResult GetUsersByOrganisationId(int organisationId)
return StatusCode(500, new ProblemDetails { Status = 500, Title = $"{e.Message}" });
}
}

/// <summary>
/// get users and job Ids by organisation id
/// </summary>
/// <param name="organisationId"></param>
/// <returns></returns>
[HttpGet("usersandjobIdsbyorganisation/{organisationId:int}")]
[ProducesResponseType(typeof(User), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
[Produces("application/json")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Policy = Policies.API.UserAdministration)]
public IActionResult GetUsersAndJobIdsByOrganisationId(int organisationId)
{
try
{
var user = _usersService.GetUsersAndJobIdsByOrganisationId(organisationId);
suegarner marked this conversation as resolved.
Show resolved Hide resolved
if (user != null)
{
return Ok(user);
}
return NotFound(new ProblemDetails { Status = 404, Title = "Organisation not found" });
}
catch (Exception e)
{
return StatusCode(500, new ProblemDetails { Status = 500, Title = $"{e.Message}" });
}
}
}
}
Loading