Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f274a61
add: GetDepartmentById, UpdateDepartment, DeleteDepartment, EnableRoo…
ChienNQuang May 26, 2023
b141a49
add: update room command and endpoint
ChienNQuang May 26, 2023
944947d
add: get by id command and endpoint
ChienNQuang May 26, 2023
47a8d9b
add: documentation on endpoints I forgot to add
ChienNQuang May 26, 2023
880a6b2
fix: change annotation with some documentation and get all room pagin…
ChienNQuang May 26, 2023
59d5efd
fix: change annotation with some documentation and get all room pagin…
ChienNQuang May 26, 2023
97215f2
add: remove locker endpoint and command
ChienNQuang May 26, 2023
205acc6
add: update locker command and request
ChienNQuang May 26, 2023
10355c3
add: get locker by id endpoint and command
ChienNQuang May 26, 2023
210bddf
add: get all lockers paginated query and endpoint
ChienNQuang May 27, 2023
d440ef3
add: enable folder command and endpoint
ChienNQuang May 27, 2023
5e1d565
add: remove folder command and endpoint
ChienNQuang May 27, 2023
3479715
add: get folder by id query and endpoint
ChienNQuang May 27, 2023
76a6de1
add: get all folders paginated query and endpoint
ChienNQuang May 27, 2023
6d989f7
add: update folder command and endpoint
ChienNQuang May 27, 2023
2f258f1
add: update document command and endpoint
ChienNQuang May 27, 2023
0278989
add: delete document command and endpoint
ChienNQuang May 27, 2023
2ec1ed8
add: update user command and endpoint
ChienNQuang May 27, 2023
aa5ff25
add: get user by id query and endpoint
ChienNQuang May 27, 2023
61a1c53
add: get all users paginated query and endpoint
ChienNQuang May 27, 2023
92786ac
add: remove staff from room command and endpoint
ChienNQuang May 27, 2023
11e894e
add: get staff by id query and endpoint
ChienNQuang May 27, 2023
746acb9
add: get all staffs paginated query and endpoint
ChienNQuang May 27, 2023
a379a92
add: get staff by room query and endpoint
ChienNQuang May 27, 2023
aca6dad
chore: merge from dev
ChienNQuang May 27, 2023
ff11862
chore: merge from dev
ChienNQuang May 27, 2023
5f9bfa1
chore: merge from dev
ChienNQuang May 27, 2023
77db38c
add: enable user command and endpoint
ChienNQuang May 27, 2023
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
1 change: 0 additions & 1 deletion src/Api/Controllers/AuthController.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,7 +104,6 @@ private void SetJweToken(SecurityToken jweToken, RefreshTokenDto newRefreshToken
var cookieOptions = new CookieOptions
{
HttpOnly = true,
Expires = newRefreshToken.ExpiryDateTime
};
var handler = new JwtSecurityTokenHandler();
Response.Cookies.Append("JweToken", handler.WriteToken(jweToken), cookieOptions);
Expand Down
66 changes: 65 additions & 1 deletion src/Api/Controllers/DepartmentsController.cs
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
using Application.Common.Models;
using Api.Controllers.Payload.Requests;
using Application.Common.Models;
using Application.Departments.Commands.DeleteDepartment;
using Application.Departments.Commands.UpdateDepartment;
using Application.Departments.Commands.AddDepartment;
using Application.Departments.Queries.GetAllDepartments;
using Application.Departments.Queries.GetDepartmentById;
using Application.Identity;
using Application.Users.Queries;
using Infrastructure.Identity.Authorization;
Expand DownExpand Up@@ -38,4 +42,64 @@ public async Task<ActionResult<Result<IEnumerable<DepartmentDto>>>> GetAllDepart
var result = await Mediator.Send(new GetAllDepartmentsQuery());
return Ok(Result<IEnumerable<DepartmentDto>>.Succeed(result));
}

/// <summary>
/// Get back a department based on its id
/// </summary>
/// <param name="departmentId">id of the department to be retrieved</param>
/// <returns>A DepartmentDto of the retrieved department</returns>
[HttpGet("{departmentId:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
public async Task<ActionResult<Result<DepartmentDto>>> GetDepartmentById([FromRoute] Guid departmentId)
{
var query = new GetDepartmentByIdQuery()
{
DepartmentId = departmentId
};
var result = await Mediator.Send(query);
return Ok(Result<DepartmentDto>.Succeed(result));
}

/// <summary>
/// Update a department
/// </summary>
/// <param name="departmentId">Id of the department to be updated</param>
/// <param name="request">Update department details</param>
/// <returns>A DepartmentDto of the updated department</returns>
[RequiresRole(IdentityData.Roles.Admin)]
[HttpPut("{departmentId:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<Result<DepartmentDto>>> UpdateDepartment([FromRoute] Guid departmentId, [FromBody] UpdateDepartmentRequest request)
{
var command = new UpdateDepartmentCommand()
{
DepartmentId = departmentId,
Name = request.Name
};
var result = await Mediator.Send(command);
return Ok(Result<DepartmentDto>.Succeed(result));
}

/// <summary>
/// Delete a department
/// </summary>
/// <param name="departmentId">Id of the department to be deleted</param>
/// <returns>A DepartmentDto of the deleted department</returns>
[RequiresRole(IdentityData.Roles.Admin)]
[HttpDelete("{departmentId:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<Result<DepartmentDto>>> DeleteDepartment([FromRoute] Guid departmentId)
{
var command = new DeleteDepartmentCommand()
{
DepartmentId = departmentId,
};
var result = await Mediator.Send(command);
return Ok(Result<DepartmentDto>.Succeed(result));
}
}
47 changes: 47 additions & 0 deletions src/Api/Controllers/DocumentsController.cs
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
using Api.Controllers.Payload.Requests.Documents;
using Application.Common.Models;
using Application.Common.Models.Dtos.Physical;
using Application.Documents.Commands.DeleteDocument;
using Application.Documents.Commands.ImportDocument;
using Application.Documents.Commands.UpdateDocument;
using Application.Documents.Queries.GetAllDocumentsPaginated;
using Application.Documents.Queries.GetDocumentById;
using Application.Documents.Queries.GetDocumentTypes;
Expand DownExpand Up@@ -70,4 +73,48 @@ public async Task<ActionResult<Result<DocumentDto>>> GetDocumentById(Guid id)
var result = await Mediator.Send(query);
return Ok(Result<DocumentDto>.Succeed(result));
}

/// <summary>
/// Update a document
/// </summary>
/// <param name="documentId">Id of the document to be updated</param>
/// <param name="request">Update document details</param>
/// <returns>A DocumentDto of the updated document</returns>
[RequiresRole(IdentityData.Roles.Admin)]
[HttpPut("{documentId:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
public async Task<ActionResult<Result<DocumentDto>>> UpdateDocument([FromRoute] Guid documentId, [FromBody] UpdateDocumentRequest request)
{
var query = new UpdateDocumentCommand()
{
DocumentId = documentId,
Title = request.Title,
Description = request.Description,
DocumentType = request.DocumentType
};
var result = await Mediator.Send(query);
return Ok(Result<DocumentDto>.Succeed(result));
}

/// <summary>
/// Delete a document
/// </summary>
/// <param name="documentId">Id of the document to be deleted</param>
/// <returns>A DocumentDto of the deleted document</returns>
[HttpDelete("{documentId:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<Result<DocumentDto>>> UpdateDocument([FromRoute] Guid documentId)
{
var query = new DeleteDocumentCommand()
{
DocumentId = documentId,
};
var result = await Mediator.Send(query);
return Ok(Result<DocumentDto>.Succeed(result));
}
}
125 changes: 125 additions & 0 deletions src/Api/Controllers/FoldersController.cs
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
using Api.Controllers.Payload.Requests.Folders;
using Application.Common.Models;
using Application.Common.Models.Dtos.Physical;
using Application.Folders.Commands.AddFolder;
using Application.Folders.Commands.DisableFolder;
using Application.Folders.Commands.EnableFolder;
using Application.Folders.Commands.RemoveFolder;
using Application.Folders.Commands.UpdateFolder;
using Application.Folders.Queries.GetAllFoldersPaginated;
using Application.Folders.Queries.GetFolderById;
using Application.Identity;
using Infrastructure.Identity.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand All@@ -10,7 +16,57 @@ namespace Api.Controllers;

public class FoldersController : ApiControllerBase
{
/// <summary>
/// Get a folder by id
/// </summary>
/// <param name="folderId">Id of the folder to be retrieved</param>
/// <returns>A FolderDto of the retrieved folder</returns>
[RequiresRole(IdentityData.Roles.Admin, IdentityData.Roles.Staff)]
[HttpGet("{folderId:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<Result<FolderDto>>> GetById([FromRoute] Guid folderId)
{
var query = new GetFolderByIdQuery()
{
FolderId = folderId
};
var result = await Mediator.Send(query);
return Ok(Result<FolderDto>.Succeed(result));
}

/// <summary>
/// Get all folders paginated
/// </summary>
/// <param name="queryParameters">Get all folders query parameters</param>
/// <returns>A paginated list of FolderDto</returns>
[RequiresRole(IdentityData.Roles.Admin, IdentityData.Roles.Staff)]
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
public async Task<ActionResult<Result<PaginatedList<FolderDto>>>> GetAllPaginated(
[FromQuery] GetAllFoldersPaginatedQueryParameters queryParameters)
{
var query = new GetAllFoldersPaginatedQuery()
{
RoomId = queryParameters.RoomId,
LockerId = queryParameters.LockerId,
Page = queryParameters.Page,
Size = queryParameters.Size,
SortBy = queryParameters.SortBy,
SortOrder = queryParameters.SortOrder,
};
var result = await Mediator.Send(query);
return Ok(Result<PaginatedList<FolderDto>>.Succeed(result));
}

/// <summary>
/// Add a folder
/// </summary>
/// <param name="command">Add folder details</param>
/// <returns>A FolderDto of the added folder</returns>
[RequiresRole(IdentityData.Roles.Admin)]
[HttpPost]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
Expand All@@ -22,7 +78,52 @@ public async Task<ActionResult<Result<FolderDto>>> AddFolder([FromBody] AddFolde
var result = await Mediator.Send(command);
return Ok(Result<FolderDto>.Succeed(result));
}

/// <summary>
/// Remove a folder
/// </summary>
/// <param name="folderId">Id of the folder to be removed</param>
/// <returns>A FolderDto of the removed folder</returns>
[RequiresRole(IdentityData.Roles.Admin)]
[HttpDelete("{folderId:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
public async Task<ActionResult<Result<FolderDto>>> RemoveFolder([FromRoute] Guid folderId)
{
var command = new RemoveFolderCommand()
{
FolderId = folderId,
};
var result = await Mediator.Send(command);
return Ok(Result<FolderDto>.Succeed(result));
}

/// <summary>
/// Enable a folder
/// </summary>
/// <param name="command">Enable folder details</param>
/// <returns>A FolderDto of the enabled folder</returns>
[RequiresRole(IdentityData.Roles.Admin, IdentityData.Roles.Staff)]
[HttpPut("enable")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
public async Task<ActionResult<Result<FolderDto>>> EnableFolder([FromBody] EnableFolderCommand command)
{
var result = await Mediator.Send(command);
return Ok(Result<FolderDto>.Succeed(result));
}

/// <summary>
/// Disable a folder
/// </summary>
/// <param name="command">Disable folder details</param>
/// <returns>A FolderDto of the disabled folder</returns>
[RequiresRole(IdentityData.Roles.Admin, IdentityData.Roles.Staff)]
[HttpPut("disable")]
[ProducesResponseType(StatusCodes.Status200OK)]
Expand All@@ -35,4 +136,28 @@ public async Task<ActionResult<Result<FolderDto>>> DisableFolder([FromBody] Disa
var result = await Mediator.Send(command);
return Ok(Result<FolderDto>.Succeed(result));
}

/// <summary>
/// Update a folder
/// </summary>
/// <param name="folderId">Id of the folder to be updated</param>
/// <param name="request">Update folder details</param>
/// <returns>A FolderDto of the updated folder</returns>
[HttpPut("{folderId:guid}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status409Conflict)]
public async Task<ActionResult<Result<FolderDto>>> Update([FromRoute] Guid folderId, [FromBody] UpdateFolderRequest request)
{
var command = new UpdateFolderCommand()
{
FolderId = folderId,
Name = request.Name,
Description = request.Description,
Capacity = request.Capacity
};
var result = await Mediator.Send(command);
return Ok(Result<FolderDto>.Succeed(result));
}
}
Loading