Skip to content

Commit

Permalink
Merge pull request #202 from amosproj/185-resource-filterbar
Browse files Browse the repository at this point in the history
185 resource filterbar
  • Loading branch information
n3rdc4ptn authored Jan 31, 2023
2 parents c620ade + de0a266 commit 1281f81
Show file tree
Hide file tree
Showing 10 changed files with 438 additions and 119 deletions.
10 changes: 5 additions & 5 deletions src/deskstar-backend/Deskstar/Controllers/AuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public AuthController(ILogger<AuthController> logger, IAuthUsecases authUsecases
/// Sample request:
/// Post /auth/createToken
/// </remarks>
///
///
/// <response code="200">Login succesful </response>
/// <response code="401">Credentials wrong or user not approved</response>
[HttpPost("createToken")]
Expand All @@ -56,7 +56,7 @@ public IActionResult CreateToken(CreateTokenUser user)
/// Sample request:
/// Post /auth/register
/// </remarks>
///
///
/// <response code="200">User added to db</response>
/// <response code="400">Mail already in use</response>
/// <response code="404">Company not found</response>
Expand All @@ -82,7 +82,7 @@ public IActionResult Register(RegisterUser registerUser)
/// Sample request:
/// Post /auth/registerAdmin
/// </remarks>
///
///
/// <response code="200">Admin added to db</response>
/// <response code="400">Mail or Company name already in use</response>
[HttpPost("registerAdmin")]
Expand All @@ -102,7 +102,7 @@ public IActionResult RegisterAdmin(RegisterAdminDto registerAdmin)
}
catch (Exception e)
{
return Problem(statusCode: 500);
return Problem(statusCode: 500, detail:e.Message);
}
}
}
}
133 changes: 114 additions & 19 deletions src/deskstar-backend/Deskstar/Controllers/ResourceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,17 +473,49 @@ public IActionResult GetFloorsByBuildingId(string buildingId)
return Ok(floor.ToList());
}

// /// <summary>
// /// Returns a list of Floors.
// /// </summary>
// /// <returns>A List of Floors in JSON Format </returns>
// /// <remarks>
// /// Sample request:
// /// GET /resources/floors with JWT Token
// /// </remarks>
// ///
// /// <response code="200">Returns the floor list</response>
// /// <response code="400">Bad Request</response>
// /// <response code="500">Internal Server Error</response>
// [HttpGet("floors")]
// [Authorize]
// [ProducesResponseType(typeof(List<CurrentFloor>), StatusCodes.Status200OK)]
// [ProducesResponseType(StatusCodes.Status500InternalServerError)]
// [Produces("application/json")]
// public IActionResult GetAllFloors()
// {
// var callerId = RequestInteractions.ExtractIdFromRequest(Request);
// List<CurrentFloor> floor;
// try
// {
// floor = _resourceUsecases.GetFloors(callerId, "");
// }
// catch (ArgumentException e)
// {
// return Problem(statusCode: 500, detail: e.Message);
// }

// return Ok(floor.ToList());
// }

/// <summary>
/// Returns a list of Floors.
/// Returns a list of all Floors.
/// </summary>
/// <returns>A List of Floors in JSON Format </returns>
/// <returns>A List of Floors in JSON Format (can be empty) </returns>
/// <remarks>
/// Sample request:
/// GET /resources/floors with JWT Token
/// </remarks>
///
/// <response code="200">Returns the floor list</response>
/// <response code="400">Bad Request</response>
/// <response code="500">Internal Server Error</response>
[HttpGet("floors")]
[Authorize]
Expand All @@ -492,17 +524,16 @@ public IActionResult GetFloorsByBuildingId(string buildingId)
[Produces("application/json")]
public IActionResult GetAllFloors()
{
var callerId = RequestInteractions.ExtractIdFromRequest(Request);
List<CurrentFloor> floor;
var adminId = RequestInteractions.ExtractIdFromRequest(Request);
try
{
floor = _resourceUsecases.GetFloors(callerId, "");
floor = _resourceUsecases.GetAllFloors(adminId);
}
catch (ArgumentException e)
{
return Problem(statusCode: 500, detail: e.Message);
}

return Ok(floor.ToList());
}

Expand Down Expand Up @@ -670,17 +701,49 @@ public IActionResult GetRoomsByFloorId(string floorId)
return Ok(rooms.ToList());
}

// /// <summary>
// /// Returns a list of Rooms.
// /// </summary>
// /// <returns>A List of Rooms in JSON Format </returns>
// /// <remarks>
// /// Sample request:
// /// GET /resources/rooms with JWT Token
// /// </remarks>
// ///
// /// <response code="200">Returns the rooms list</response>
// /// <response code="400">Bad Request</response>
// /// <response code="500">Internal Server Error</response>
// [HttpGet("rooms")]
// [Authorize]
// [ProducesResponseType(typeof(List<CurrentRoom>), StatusCodes.Status200OK)]
// [ProducesResponseType(StatusCodes.Status500InternalServerError)]
// [Produces("application/json")]
// public IActionResult GetAllRooms()
// {
// var callerId = RequestInteractions.ExtractIdFromRequest(Request);
// List<CurrentRoom> rooms;
// try
// {
// rooms = _resourceUsecases.GetRooms(callerId, "");
// }
// catch (ArgumentException e)
// {
// return Problem(statusCode: 500, detail: e.Message);
// }

// return Ok(rooms.ToList());
// }

/// <summary>
/// Returns a list of Rooms.
/// Returns a list of all Rooms.
/// </summary>
/// <returns>A List of Rooms in JSON Format </returns>
/// <returns>A List of Rooms in JSON Format (can be empty) </returns>
/// <remarks>
/// Sample request:
/// GET /resources/rooms with JWT Token
/// </remarks>
///
/// <response code="200">Returns the rooms list</response>
/// <response code="400">Bad Request</response>
/// <response code="500">Internal Server Error</response>
[HttpGet("rooms")]
[Authorize]
Expand All @@ -689,11 +752,11 @@ public IActionResult GetRoomsByFloorId(string floorId)
[Produces("application/json")]
public IActionResult GetAllRooms()
{
var callerId = RequestInteractions.ExtractIdFromRequest(Request);
List<CurrentRoom> rooms;
var adminId = RequestInteractions.ExtractIdFromRequest(Request);
try
{
rooms = _resourceUsecases.GetRooms(callerId, "");
rooms = _resourceUsecases.GetAllRooms(adminId);
}
catch (ArgumentException e)
{
Expand Down Expand Up @@ -871,18 +934,50 @@ public IActionResult GetDesksByRoomId(string roomId, long start = 0, long end =
return Ok(desks.ToList());
}

// /// <summary>
// /// Returns a list of Desks.
// /// </summary>
// /// <returns>A List of Desks in JSON Format </returns>
// /// <remarks>
// /// Sample request:
// /// GET /resources/desks
// /// with JWT Token
// /// </remarks>
// ///
// /// <response code="200">Returns the desks list</response>
// /// <response code="400">Bad Request</response>
// /// <response code="500">Internal Server Error</response>
// [HttpGet("desks")]
// [Authorize]
// [ProducesResponseType(typeof(List<CurrentDesk>), StatusCodes.Status200OK)]
// [ProducesResponseType(StatusCodes.Status500InternalServerError)]
// [Produces("application/json")]
// public IActionResult GetAllDesks()
// {
// var callerId = RequestInteractions.ExtractIdFromRequest(Request);
// List<CurrentDesk> desks;
// try
// {
// desks = _resourceUsecases.GetDesks(callerId, "", DateTime.MinValue, DateTime.MaxValue);
// }
// catch (ArgumentException e)
// {
// return Problem(statusCode: 500, detail: e.Message);
// }

// return Ok(desks.ToList());
// }

/// <summary>
/// Returns a list of Desks.
/// Returns a list of all Desks.
/// </summary>
/// <returns>A List of Desks in JSON Format </returns>
/// <returns>A List of Desks in JSON Format by RoomId (can be empty) </returns>
/// <remarks>
/// Sample request:
/// GET /resources/desks
/// with JWT Token
/// GET /resources/desks with JWT Token
/// </remarks>
///
/// <response code="200">Returns the desks list</response>
/// <response code="400">Bad Request</response>
/// <response code="500">Internal Server Error</response>
[HttpGet("desks")]
[Authorize]
Expand All @@ -891,11 +986,11 @@ public IActionResult GetDesksByRoomId(string roomId, long start = 0, long end =
[Produces("application/json")]
public IActionResult GetAllDesks()
{
var callerId = RequestInteractions.ExtractIdFromRequest(Request);
List<CurrentDesk> desks;
var adminId = RequestInteractions.ExtractIdFromRequest(Request);
try
{
desks = _resourceUsecases.GetDesks(callerId, "", DateTime.MinValue, DateTime.MaxValue);
desks = _resourceUsecases.GetAllDesks(adminId);
}
catch (ArgumentException e)
{
Expand Down Expand Up @@ -1246,4 +1341,4 @@ public IActionResult RestoreDeskType(string deskTypeId)
return Problem(statusCode: 500);
}
}
}
}
3 changes: 3 additions & 0 deletions src/deskstar-backend/Deskstar/Models/CurrentFloor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class CurrentFloor
[Required]
public string FloorName { get; set; } = null!;

[Required]
public string BuildingId { get; set; } = null!;

[Required]
public string BuildingName { get; set; } = null!;

Expand Down
3 changes: 3 additions & 0 deletions src/deskstar-backend/Deskstar/Models/CurrentRoom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class CurrentRoom
[Required]
public string RoomName { get; set; } = null!;

[Required]
public string FloorId { get; set; } = null!;

[Required]
public string Floor { get; set; } = null!;

Expand Down
Loading

0 comments on commit 1281f81

Please sign in to comment.