diff --git a/src/Api/Controllers/AuthController.cs b/src/Api/Controllers/AuthController.cs index 30291352..efdd1591 100644 --- a/src/Api/Controllers/AuthController.cs +++ b/src/Api/Controllers/AuthController.cs @@ -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); diff --git a/src/Api/Controllers/DepartmentsController.cs b/src/Api/Controllers/DepartmentsController.cs index 465738a9..98045cf7 100644 --- a/src/Api/Controllers/DepartmentsController.cs +++ b/src/Api/Controllers/DepartmentsController.cs @@ -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; @@ -38,4 +42,64 @@ public async Task>>> GetAllDepart var result = await Mediator.Send(new GetAllDepartmentsQuery()); return Ok(Result>.Succeed(result)); } + + /// + /// Get back a department based on its id + /// + /// id of the department to be retrieved + /// A DepartmentDto of the retrieved department + [HttpGet("{departmentId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + public async Task>> GetDepartmentById([FromRoute] Guid departmentId) + { + var query = new GetDepartmentByIdQuery() + { + DepartmentId = departmentId + }; + var result = await Mediator.Send(query); + return Ok(Result.Succeed(result)); + } + + /// + /// Update a department + /// + /// Id of the department to be updated + /// Update department details + /// A DepartmentDto of the updated department + [RequiresRole(IdentityData.Roles.Admin)] + [HttpPut("{departmentId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task>> 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.Succeed(result)); + } + + /// + /// Delete a department + /// + /// Id of the department to be deleted + /// A DepartmentDto of the deleted department + [RequiresRole(IdentityData.Roles.Admin)] + [HttpDelete("{departmentId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task>> DeleteDepartment([FromRoute] Guid departmentId) + { + var command = new DeleteDepartmentCommand() + { + DepartmentId = departmentId, + }; + var result = await Mediator.Send(command); + return Ok(Result.Succeed(result)); + } } \ No newline at end of file diff --git a/src/Api/Controllers/DocumentsController.cs b/src/Api/Controllers/DocumentsController.cs index a4b4d8bf..41f8fb3d 100644 --- a/src/Api/Controllers/DocumentsController.cs +++ b/src/Api/Controllers/DocumentsController.cs @@ -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; @@ -70,4 +73,48 @@ public async Task>> GetDocumentById(Guid id) var result = await Mediator.Send(query); return Ok(Result.Succeed(result)); } + + /// + /// Update a document + /// + /// Id of the document to be updated + /// Update document details + /// A DocumentDto of the updated document + [RequiresRole(IdentityData.Roles.Admin)] + [HttpPut("{documentId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status409Conflict)] + public async Task>> 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.Succeed(result)); + } + + /// + /// Delete a document + /// + /// Id of the document to be deleted + /// A DocumentDto of the deleted document + [HttpDelete("{documentId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task>> UpdateDocument([FromRoute] Guid documentId) + { + var query = new DeleteDocumentCommand() + { + DocumentId = documentId, + }; + var result = await Mediator.Send(query); + return Ok(Result.Succeed(result)); + } } \ No newline at end of file diff --git a/src/Api/Controllers/FoldersController.cs b/src/Api/Controllers/FoldersController.cs index e37a6691..8ea03dd6 100644 --- a/src/Api/Controllers/FoldersController.cs +++ b/src/Api/Controllers/FoldersController.cs @@ -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; @@ -10,7 +16,57 @@ namespace Api.Controllers; public class FoldersController : ApiControllerBase { + /// + /// Get a folder by id + /// + /// Id of the folder to be retrieved + /// A FolderDto of the retrieved folder [RequiresRole(IdentityData.Roles.Admin, IdentityData.Roles.Staff)] + [HttpGet("{folderId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task>> GetById([FromRoute] Guid folderId) + { + var query = new GetFolderByIdQuery() + { + FolderId = folderId + }; + var result = await Mediator.Send(query); + return Ok(Result.Succeed(result)); + } + + /// + /// Get all folders paginated + /// + /// Get all folders query parameters + /// A paginated list of FolderDto + [RequiresRole(IdentityData.Roles.Admin, IdentityData.Roles.Staff)] + [HttpGet] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + public async Task>>> 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>.Succeed(result)); + } + + /// + /// Add a folder + /// + /// Add folder details + /// A FolderDto of the added folder + [RequiresRole(IdentityData.Roles.Admin)] [HttpPost] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] @@ -22,7 +78,52 @@ public async Task>> AddFolder([FromBody] AddFolde var result = await Mediator.Send(command); return Ok(Result.Succeed(result)); } + + /// + /// Remove a folder + /// + /// Id of the folder to be removed + /// A FolderDto of the removed folder + [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>> RemoveFolder([FromRoute] Guid folderId) + { + var command = new RemoveFolderCommand() + { + FolderId = folderId, + }; + var result = await Mediator.Send(command); + return Ok(Result.Succeed(result)); + } + + /// + /// Enable a folder + /// + /// Enable folder details + /// A FolderDto of the enabled folder + [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>> EnableFolder([FromBody] EnableFolderCommand command) + { + var result = await Mediator.Send(command); + return Ok(Result.Succeed(result)); + } + /// + /// Disable a folder + /// + /// Disable folder details + /// A FolderDto of the disabled folder [RequiresRole(IdentityData.Roles.Admin, IdentityData.Roles.Staff)] [HttpPut("disable")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -35,4 +136,28 @@ public async Task>> DisableFolder([FromBody] Disa var result = await Mediator.Send(command); return Ok(Result.Succeed(result)); } + + /// + /// Update a folder + /// + /// Id of the folder to be updated + /// Update folder details + /// A FolderDto of the updated folder + [HttpPut("{folderId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status409Conflict)] + public async Task>> 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.Succeed(result)); + } } \ No newline at end of file diff --git a/src/Api/Controllers/LockersController.cs b/src/Api/Controllers/LockersController.cs index 350ca406..f064090e 100644 --- a/src/Api/Controllers/LockersController.cs +++ b/src/Api/Controllers/LockersController.cs @@ -1,9 +1,15 @@ -using Application.Common.Models; +using Api.Controllers.Payload.Requests; +using Api.Controllers.Payload.Requests.Lockers; +using Application.Common.Models; using Application.Common.Models.Dtos.Physical; using Application.Identity; using Application.Lockers.Commands.AddLocker; using Application.Lockers.Commands.DisableLocker; using Application.Lockers.Commands.EnableLocker; +using Application.Lockers.Commands.RemoveLocker; +using Application.Lockers.Commands.UpdateLocker; +using Application.Lockers.Queries.GetAllLockersPaginated; +using Application.Lockers.Queries.GetLockerById; using Infrastructure.Identity.Authorization; using Microsoft.AspNetCore.Mvc; @@ -11,6 +17,48 @@ namespace Api.Controllers; public class LockersController : ApiControllerBase { + /// + /// Get a locker by id + /// + /// Id of the locker to be retrieved + /// A LockerDto of the retrieved locker + [HttpGet("{lockerId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task>> GetById([FromRoute] Guid lockerId) + { + var query = new GetLockerByIdQuery() + { + LockerId = lockerId + }; + var result = await Mediator.Send(query); + return Ok(Result.Succeed(result)); + } + + /// + /// Get all lockers paginated + /// + /// Get all lockers query parameters + /// A paginated list of LockerDto + [HttpGet] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + public async Task>>> GetAllPaginated( + [FromQuery] GetAllLockersPaginatedQueryParameters queryParameters) + { + var query = new GetAllLockersPaginatedQuery() + { + RoomId = queryParameters.RoomId, + Page = queryParameters.Page, + Size = queryParameters.Size, + SortBy = queryParameters.SortBy, + SortOrder = queryParameters.SortOrder, + }; + var result = await Mediator.Send(query); + return Ok(Result>.Succeed(result)); + } + [RequiresRole(IdentityData.Roles.Staff)] [HttpPost] [ProducesResponseType(StatusCodes.Status200OK)] @@ -49,4 +97,48 @@ public async Task>> EnableLocker([FromBody] Enabl var result = await Mediator.Send(command); return Ok(Result.Succeed(result)); } + + /// + /// Update a locker + /// + /// Id of the locker to be updated + /// Update locker details + /// A LockerDto of the updated locker + [HttpPut("{lockerId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status409Conflict)] + public async Task>> Update([FromRoute] Guid lockerId, [FromBody] UpdateLockerRequest request) + { + var command = new UpdateLockerCommand() + { + LockerId = lockerId, + Name = request.Name, + Description = request.Description, + Capacity = request.Capacity + }; + var result = await Mediator.Send(command); + return Ok(Result.Succeed(result)); + } + + /// + /// Remove a locker + /// + /// Id of the locker to be removed + /// A LockerDto of the removed locker + [HttpDelete("{lockerId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status409Conflict)] + public async Task>> Remove([FromRoute] Guid lockerId) + { + var command = new RemoveLockerCommand() + { + LockerId = lockerId + }; + var result = await Mediator.Send(command); + return Ok(Result.Succeed(result)); + } } diff --git a/src/Api/Controllers/Payload/Requests/Documents/UpdateDocumentRequest.cs b/src/Api/Controllers/Payload/Requests/Documents/UpdateDocumentRequest.cs new file mode 100644 index 00000000..e6a0885b --- /dev/null +++ b/src/Api/Controllers/Payload/Requests/Documents/UpdateDocumentRequest.cs @@ -0,0 +1,8 @@ +namespace Api.Controllers.Payload.Requests.Documents; + +public class UpdateDocumentRequest +{ + public string Title { get; set; } = null!; + public string? Description { get; set; } + public string DocumentType { get; set; } = null!; +} \ No newline at end of file diff --git a/src/Api/Controllers/Payload/Requests/Folders/GetAllFoldersPaginatedQueryParameters.cs b/src/Api/Controllers/Payload/Requests/Folders/GetAllFoldersPaginatedQueryParameters.cs new file mode 100644 index 00000000..db642122 --- /dev/null +++ b/src/Api/Controllers/Payload/Requests/Folders/GetAllFoldersPaginatedQueryParameters.cs @@ -0,0 +1,11 @@ +namespace Api.Controllers.Payload.Requests.Folders; + +public class GetAllFoldersPaginatedQueryParameters +{ + public Guid? RoomId { get; set; } + public Guid? LockerId { get; set; } + public int? Page { get; set; } + public int? Size { get; set; } + public string? SortBy { get; set; } + public string? SortOrder { get; set; } +} \ No newline at end of file diff --git a/src/Api/Controllers/Payload/Requests/Folders/UpdateFolderRequest.cs b/src/Api/Controllers/Payload/Requests/Folders/UpdateFolderRequest.cs new file mode 100644 index 00000000..97e9691f --- /dev/null +++ b/src/Api/Controllers/Payload/Requests/Folders/UpdateFolderRequest.cs @@ -0,0 +1,8 @@ +namespace Api.Controllers.Payload.Requests.Folders; + +public class UpdateFolderRequest +{ + public string Name { get; set; } = null!; + public string? Description { get; set; } + public int Capacity { get; set; } +} \ No newline at end of file diff --git a/src/Api/Controllers/Payload/Requests/Lockers/GetAllLockersPaginatedQueryParameters.cs b/src/Api/Controllers/Payload/Requests/Lockers/GetAllLockersPaginatedQueryParameters.cs new file mode 100644 index 00000000..b4b7f837 --- /dev/null +++ b/src/Api/Controllers/Payload/Requests/Lockers/GetAllLockersPaginatedQueryParameters.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Api.Controllers.Payload.Requests.Lockers; + + +public class GetAllLockersPaginatedQueryParameters +{ + public Guid? RoomId { get; set; } + public int? Page { get; set; } + public int? Size { get; set; } + public string? SortBy { get; set; } + public string? SortOrder { get; set; } +} \ No newline at end of file diff --git a/src/Api/Controllers/Payload/Requests/Lockers/UpdateLockerRequest.cs b/src/Api/Controllers/Payload/Requests/Lockers/UpdateLockerRequest.cs new file mode 100644 index 00000000..a7f69036 --- /dev/null +++ b/src/Api/Controllers/Payload/Requests/Lockers/UpdateLockerRequest.cs @@ -0,0 +1,8 @@ +namespace Api.Controllers.Payload.Requests.Lockers; + +public class UpdateLockerRequest +{ + public string Name { get; set; } = null!; + public string? Description { get; set; } + public int Capacity { get; set; } +} \ No newline at end of file diff --git a/src/Api/Controllers/Payload/Requests/Staffs/GetAllStaffsPaginatedQueryParameters.cs b/src/Api/Controllers/Payload/Requests/Staffs/GetAllStaffsPaginatedQueryParameters.cs new file mode 100644 index 00000000..bcb47cb4 --- /dev/null +++ b/src/Api/Controllers/Payload/Requests/Staffs/GetAllStaffsPaginatedQueryParameters.cs @@ -0,0 +1,10 @@ +namespace Api.Controllers.Payload.Requests.Staffs; + +public class GetAllStaffsPaginatedQueryParameters +{ + public string? SearchTerm { get; set; } + public int? Page { get; set; } + public int? Size { get; set; } + public string? SortBy { get; set; } + public string? SortOrder { get; set; } +} \ No newline at end of file diff --git a/src/Api/Controllers/Payload/Requests/Staffs/RemoveStaffFromRoomRequest.cs b/src/Api/Controllers/Payload/Requests/Staffs/RemoveStaffFromRoomRequest.cs new file mode 100644 index 00000000..811608df --- /dev/null +++ b/src/Api/Controllers/Payload/Requests/Staffs/RemoveStaffFromRoomRequest.cs @@ -0,0 +1,6 @@ +namespace Api.Controllers.Payload.Requests.Staffs; + +public class RemoveStaffFromRoomRequest +{ + public Guid RoomId { get; set; } +} \ No newline at end of file diff --git a/src/Api/Controllers/Payload/Requests/UpdateDepartmentRequest.cs b/src/Api/Controllers/Payload/Requests/UpdateDepartmentRequest.cs new file mode 100644 index 00000000..467ceeb5 --- /dev/null +++ b/src/Api/Controllers/Payload/Requests/UpdateDepartmentRequest.cs @@ -0,0 +1,6 @@ +namespace Api.Controllers.Payload.Requests; + +public class UpdateDepartmentRequest +{ + public string Name { get; set; } = null!; +} \ No newline at end of file diff --git a/src/Api/Controllers/Payload/Requests/UpdateRoomRequest.cs b/src/Api/Controllers/Payload/Requests/UpdateRoomRequest.cs new file mode 100644 index 00000000..a579a447 --- /dev/null +++ b/src/Api/Controllers/Payload/Requests/UpdateRoomRequest.cs @@ -0,0 +1,8 @@ +namespace Api.Controllers.Payload.Requests; + +public class UpdateRoomRequest +{ + public string Name { get; set; } = null!; + public string? Description { get; set; } + public int Capacity { get; set; } +} \ No newline at end of file diff --git a/src/Api/Controllers/Payload/Requests/Users/GetAllUsersPaginatedQueryParameters.cs b/src/Api/Controllers/Payload/Requests/Users/GetAllUsersPaginatedQueryParameters.cs new file mode 100644 index 00000000..d3484660 --- /dev/null +++ b/src/Api/Controllers/Payload/Requests/Users/GetAllUsersPaginatedQueryParameters.cs @@ -0,0 +1,11 @@ +namespace Api.Controllers.Payload.Requests.Users; + +public class GetAllUsersPaginatedQueryParameters +{ + public Guid? DepartmentId { get; set; } + public string? SearchTerm { get; set; } + public int? Page { get; set; } + public int? Size { get; set; } + public string? SortBy { get; set; } + public string? SortOrder { get; set; } +} \ No newline at end of file diff --git a/src/Api/Controllers/Payload/Requests/Users/UpdateUserRequest.cs b/src/Api/Controllers/Payload/Requests/Users/UpdateUserRequest.cs new file mode 100644 index 00000000..77bcb0e4 --- /dev/null +++ b/src/Api/Controllers/Payload/Requests/Users/UpdateUserRequest.cs @@ -0,0 +1,11 @@ +namespace Api.Controllers.Payload.Requests.Users; + +public class UpdateUserRequest +{ + public string Username { get; set; } = null!; + public string Email { get; set; } = null!; + public string? FirstName { get; set; } + public string? LastName { get; set; } + public string Role { get; set; } = null!; + public string? Position { get; set; } +} \ No newline at end of file diff --git a/src/Api/Controllers/RoomsController.cs b/src/Api/Controllers/RoomsController.cs index 39c156e9..3cbeb8dd 100644 --- a/src/Api/Controllers/RoomsController.cs +++ b/src/Api/Controllers/RoomsController.cs @@ -1,10 +1,15 @@ +using Api.Controllers.Payload.Requests; using Application.Common.Models; using Application.Common.Models.Dtos.Physical; using Application.Identity; using Application.Rooms.Commands.AddRoom; using Application.Rooms.Commands.DisableRoom; +using Application.Rooms.Commands.EnableRoom; using Application.Rooms.Commands.RemoveRoom; +using Application.Rooms.Commands.UpdateRoom; +using Application.Rooms.Queries.GetAllRoomPaginated; using Application.Rooms.Queries.GetEmptyContainersPaginated; +using Application.Rooms.Queries.GetRoomById; using Infrastructure.Identity.Authorization; using Microsoft.AspNetCore.Mvc; @@ -59,4 +64,88 @@ public async Task>> RemoveRoom(RemoveRoomCommand co var result = await Mediator.Send(command); return Ok(Result.Succeed(result)); } + + /// + /// Enable a room + /// + /// Enable room details + /// A RoomDto of the enabled room + [HttpPut("enable")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status409Conflict)] + public async Task>> EnableRoom([FromBody] EnableRoomCommand command) + { + var result = await Mediator.Send(command); + return Ok(Result.Succeed(result)); + } + + /// + /// Update a room + /// + /// Id of the room to be updated + /// Update room details + /// A RoomDto of the updated room + [HttpPut("{roomId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status409Conflict)] + public async Task>> Update([FromRoute] Guid roomId, [FromBody] UpdateRoomRequest request) + { + Console.WriteLine(request.Description); + var command = new UpdateRoomCommand() + { + RoomId = roomId, + Name = request.Name, + Description = request.Description, + Capacity = request.Capacity, + }; + var result = await Mediator.Send(command); + return Ok(Result.Succeed(result)); + } + + /// + /// Get a room by id + /// + /// Id of the room to be retrieved + /// A RoomDto of the retrieved room + [HttpGet("{roomId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task>> GetById([FromRoute] Guid roomId) + { + var query = new GetRoomByIdQuery() + { + RoomId = roomId, + }; + var result = await Mediator.Send(query); + return Ok(Result.Succeed(result)); + } + + /// + /// Get all rooms paginated + /// + /// The page index + /// The size number + /// Criteria + /// The order in which the rooms are sorted + /// A paginated list of rooms + [HttpGet] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + public async Task>>> GetAllPaginated(int? page, int? size, string? sortBy, string? sortOrder) + { + var query = new GetAllRoomsPaginatedQuery() + { + Page = page, + Size = size, + SortBy = sortBy, + SortOrder = sortOrder + }; + var result = await Mediator.Send(query); + return Ok(Result>.Succeed(result)); + } } \ No newline at end of file diff --git a/src/Api/Controllers/StaffsController.cs b/src/Api/Controllers/StaffsController.cs index d714b2bf..1ad6fff1 100644 --- a/src/Api/Controllers/StaffsController.cs +++ b/src/Api/Controllers/StaffsController.cs @@ -1,5 +1,10 @@ +using Api.Controllers.Payload.Requests.Staffs; using Application.Common.Models; using Application.Identity; +using Application.Staffs.Commands.RemoveStaffFromRoom; +using Application.Staffs.Queries.GetAllStaffsPaginated; +using Application.Staffs.Queries.GetStaffById; +using Application.Staffs.Queries.GetStaffByRoom; using Application.Staffs.Commands.AddStaff; using Application.Users.Queries.Physical; using Infrastructure.Identity.Authorization; @@ -9,6 +14,66 @@ namespace Api.Controllers; public class StaffsController : ApiControllerBase { + /// + /// Get a staff by id + /// + /// Id of the staff to be retrieved + /// A StaffDto of the retrieved staff + [HttpGet("{staffId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task>> GetById([FromRoute] Guid staffId) + { + var query = new GetStaffByIdQuery() + { + StaffId = staffId + }; + var result = await Mediator.Send(query); + return Ok(Result.Succeed(result)); + } + + /// + /// Get a staff by room + /// + /// Id of the room to retrieve staff + /// A StaffDto of the retrieved staff + [HttpGet("get-by-room/{roomId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task>> GetByRoom([FromRoute] Guid roomId) + { + var query = new GetStaffByRoomQuery() + { + RoomId = roomId + }; + var result = await Mediator.Send(query); + return Ok(Result.Succeed(result)); + } + + /// + /// Get all staffs paginated + /// + /// Get all staffs query parameters + /// A paginated list of StaffDto + [HttpGet] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + public async Task>>> GetAllPaginated( + [FromQuery] GetAllStaffsPaginatedQueryParameters queryParameters) + { + var query = new GetAllStaffsPaginatedQuery() + { + Page = queryParameters.Page, + Size = queryParameters.Size, + SortBy = queryParameters.SortBy, + SortOrder = queryParameters.SortOrder, + }; + var result = await Mediator.Send(query); + return Ok(Result>.Succeed(result)); + } + [RequiresRole(IdentityData.Roles.Admin)] [HttpPost] [ProducesResponseType(StatusCodes.Status200OK)] @@ -19,4 +84,26 @@ public async Task>> AddStaff([FromBody] AddStaffCo var result = await Mediator.Send(command); return Ok(Result.Succeed(result)); } + + /// + /// Remove a staff from room + /// + /// Id of the staff to be removed from room + /// Remove details + /// A StaffDto of the removed staff + [HttpPut("{staffId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task>> RemoveStaffFromRoom([FromRoute] Guid staffId, + [FromBody] RemoveStaffFromRoomRequest request) + { + var command = new RemoveStaffFromRoomCommand() + { + StaffId = staffId, + RoomId = request.RoomId, + }; + var result = await Mediator.Send(command); + return Ok(Result.Succeed(result)); + } } \ No newline at end of file diff --git a/src/Api/Controllers/UsersController.cs b/src/Api/Controllers/UsersController.cs index 1d51f7f0..f7d93173 100644 --- a/src/Api/Controllers/UsersController.cs +++ b/src/Api/Controllers/UsersController.cs @@ -1,8 +1,14 @@ +using Api.Controllers.Payload.Requests.Users; using Application.Common.Models; +using Application.Common.Models.Dtos.Physical; using Application.Identity; using Application.Users.Commands.AddUser; using Application.Users.Commands.DisableUser; +using Application.Users.Commands.EnableUser; +using Application.Users.Commands.UpdateUser; using Application.Users.Queries; +using Application.Users.Queries.GetAllUsersPaginated; +using Application.Users.Queries.GetUserById; using Application.Users.Queries.GetUsersByName; using Infrastructure.Identity.Authorization; using Microsoft.AspNetCore.Authorization; @@ -12,6 +18,49 @@ namespace Api.Controllers; public class UsersController : ApiControllerBase { + /// + /// Get a user by id + /// + /// Id of the user to be retrieved + /// A UserDto of the retrieved user + [HttpGet("{userId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task>> GetUserById([FromRoute] Guid userId) + { + var query = new GetUserByIdQuery + { + UserId = userId, + }; + var result = await Mediator.Send(query); + return Ok(Result.Succeed(result)); + } + + /// + /// Get all users paginated + /// + /// Get all users query parameters + /// A paginated list of UserDto + [HttpGet] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + public async Task>>> GetAllPaginated( + [FromQuery] GetAllUsersPaginatedQueryParameters queryParameters) + { + var query = new GetAllUsersPaginatedQuery() + { + DepartmentId = queryParameters.DepartmentId, + SearchTerm = queryParameters.SearchTerm, + Page = queryParameters.Page, + Size = queryParameters.Size, + SortBy = queryParameters.SortBy, + SortOrder = queryParameters.SortOrder, + }; + var result = await Mediator.Send(query); + return Ok(Result>.Succeed(result)); + } + [RequiresRole(IdentityData.Roles.Admin)] [HttpPost] [ProducesResponseType(StatusCodes.Status200OK)] @@ -25,20 +74,40 @@ public async Task>> AddUser([FromBody] AddUserComma return Ok(Result.Succeed(result)); } + // [RequiresRole(IdentityData.Roles.Admin)] + // [HttpGet] + // [ProducesResponseType(StatusCodes.Status200OK)] + // [ProducesResponseType(StatusCodes.Status403Forbidden)] + // public async Task>>> GetUsersByName(string? searchTerm, int? page, int? size) + // { + // var query = new GetUsersByNameQuery + // { + // SearchTerm = searchTerm, + // Page = page, + // Size = size + // }; + // var result = await Mediator.Send(query); + // return Ok(Result>.Succeed(result)); + // } + + /// + /// Disable a user + /// + /// Id of the user to be enabled + /// A UserDto of the enabled user [RequiresRole(IdentityData.Roles.Admin)] - [HttpGet] + [HttpPost("enable/{userId:guid}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status403Forbidden)] - public async Task>>> GetUsersByName(string? searchTerm, int? page, int? size) + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task>> EnableUser([FromRoute] Guid userId) { - var query = new GetUsersByNameQuery + var command = new EnableUserCommand() { - SearchTerm = searchTerm, - Page = page, - Size = size + UserId = userId }; - var result = await Mediator.Send(query); - return Ok(Result>.Succeed(result)); + var result = await Mediator.Send(command); + return Ok(Result.Succeed(result)); } [RequiresRole(IdentityData.Roles.Admin)] @@ -52,4 +121,31 @@ public async Task>> DisableUser([FromBody] DisableU var result = await Mediator.Send(command); return Ok(Result.Succeed(result)); } + + /// + /// Update a user + /// + /// Id of the user to be updated + /// Update user details + /// A UserDto of the updated user + [HttpPut("{userId:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + [ProducesResponseType(StatusCodes.Status409Conflict)] + public async Task>> Update([FromRoute] Guid userId, [FromBody] UpdateUserRequest request) + { + var command = new UpdateUserCommand() + { + UserId = userId, + Username = request.Username, + Email = request.Email, + FirstName = request.FirstName, + LastName = request.LastName, + Role = request.Role, + Position = request.Position, + }; + var result = await Mediator.Send(command); + return Ok(Result.Succeed(result)); + } } diff --git a/src/Application/Departments/Commands/UpdateDepartment/UpdateDepartmentCommand.cs b/src/Application/Departments/Commands/UpdateDepartment/UpdateDepartmentCommand.cs new file mode 100644 index 00000000..941879af --- /dev/null +++ b/src/Application/Departments/Commands/UpdateDepartment/UpdateDepartmentCommand.cs @@ -0,0 +1,10 @@ +using Application.Users.Queries; +using MediatR; + +namespace Application.Departments.Commands.UpdateDepartment; + +public record UpdateDepartmentCommand : IRequest +{ + public Guid DepartmentId { get; set; } + public string Name { get; init; } = null!; +} \ No newline at end of file diff --git a/src/Application/Departments/Queries/GetDepartmentById/GetDepartmentByIdQuery.cs b/src/Application/Departments/Queries/GetDepartmentById/GetDepartmentByIdQuery.cs new file mode 100644 index 00000000..fe0ec11a --- /dev/null +++ b/src/Application/Departments/Queries/GetDepartmentById/GetDepartmentByIdQuery.cs @@ -0,0 +1,9 @@ +using Application.Users.Queries; +using MediatR; + +namespace Application.Departments.Queries.GetDepartmentById; + +public record GetDepartmentByIdQuery : IRequest +{ + public Guid DepartmentId { get; init; } +} \ No newline at end of file diff --git a/src/Application/Documents/Commands/DeleteDocument/DeleteDocumentCommand.cs b/src/Application/Documents/Commands/DeleteDocument/DeleteDocumentCommand.cs new file mode 100644 index 00000000..eefecf87 --- /dev/null +++ b/src/Application/Documents/Commands/DeleteDocument/DeleteDocumentCommand.cs @@ -0,0 +1,9 @@ +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Documents.Commands.DeleteDocument; + +public record DeleteDocumentCommand : IRequest +{ + public Guid DocumentId { get; init; } +} \ No newline at end of file diff --git a/src/Application/Documents/Commands/UpdateDocument/UpdateDocumentCommand.cs b/src/Application/Documents/Commands/UpdateDocument/UpdateDocumentCommand.cs index 96e9dc8d..d7b06736 100644 --- a/src/Application/Documents/Commands/UpdateDocument/UpdateDocumentCommand.cs +++ b/src/Application/Documents/Commands/UpdateDocument/UpdateDocumentCommand.cs @@ -5,11 +5,8 @@ namespace Application.Documents.Commands.UpdateDocument; public record UpdateDocumentCommand : IRequest { - public Guid Id { get; set; } - public string? Title { get; set; } - public string? Description { get; set; } - public string? DocumentType { get; set; } - public Guid? Department { get; set; } - public Guid? Importer { get; set; } - public Guid? Folder { get; set; } + public Guid DocumentId { get; init; } + public string Title { get; init; } = null!; + public string? Description { get; init; } + public string DocumentType { get; init; } = null!; } \ No newline at end of file diff --git a/src/Application/Folders/Commands/EnableFolder/EnableFolderCommand.cs b/src/Application/Folders/Commands/EnableFolder/EnableFolderCommand.cs new file mode 100644 index 00000000..eb7f49f9 --- /dev/null +++ b/src/Application/Folders/Commands/EnableFolder/EnableFolderCommand.cs @@ -0,0 +1,9 @@ +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Folders.Commands.EnableFolder; + +public record EnableFolderCommand : IRequest +{ + public Guid FolderId { get; init; } +} diff --git a/src/Application/Folders/Commands/RemoveFolder/RemoveFolderCommand.cs b/src/Application/Folders/Commands/RemoveFolder/RemoveFolderCommand.cs new file mode 100644 index 00000000..91db8b5e --- /dev/null +++ b/src/Application/Folders/Commands/RemoveFolder/RemoveFolderCommand.cs @@ -0,0 +1,9 @@ +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Folders.Commands.RemoveFolder; + +public record RemoveFolderCommand : IRequest +{ + public Guid FolderId { get; init; } +} \ No newline at end of file diff --git a/src/Application/Folders/Commands/UpdateFolder/UpdateFolderCommand.cs b/src/Application/Folders/Commands/UpdateFolder/UpdateFolderCommand.cs new file mode 100644 index 00000000..30ebea09 --- /dev/null +++ b/src/Application/Folders/Commands/UpdateFolder/UpdateFolderCommand.cs @@ -0,0 +1,12 @@ +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Folders.Commands.UpdateFolder; + +public record UpdateFolderCommand : IRequest +{ + public Guid FolderId { get; init; } + public string Name { get; init; } = null!; + public string? Description { get; init; } + public int Capacity { get; init; } +} \ No newline at end of file diff --git a/src/Application/Folders/Queries/GetAllFoldersPaginated/GetAllFoldersPaginatedQuery.cs b/src/Application/Folders/Queries/GetAllFoldersPaginated/GetAllFoldersPaginatedQuery.cs new file mode 100644 index 00000000..ecd9fbb2 --- /dev/null +++ b/src/Application/Folders/Queries/GetAllFoldersPaginated/GetAllFoldersPaginatedQuery.cs @@ -0,0 +1,15 @@ +using Application.Common.Models; +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Folders.Queries.GetAllFoldersPaginated; + +public record GetAllFoldersPaginatedQuery : IRequest> +{ + public Guid? RoomId { get; init; } + public Guid? LockerId { get; init; } + public int? Page { get; init; } + public int? Size { get; init; } + public string? SortBy { get; init; } + public string? SortOrder { get; init; } +} \ No newline at end of file diff --git a/src/Application/Folders/Queries/GetFolderById/GetFolderByIdQuery.cs b/src/Application/Folders/Queries/GetFolderById/GetFolderByIdQuery.cs new file mode 100644 index 00000000..bf422997 --- /dev/null +++ b/src/Application/Folders/Queries/GetFolderById/GetFolderByIdQuery.cs @@ -0,0 +1,9 @@ +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Folders.Queries.GetFolderById; + +public record GetFolderByIdQuery : IRequest +{ + public Guid FolderId { get; init; } +} \ No newline at end of file diff --git a/src/Application/Lockers/Commands/RemoveLocker/RemoveLockerCommand.cs b/src/Application/Lockers/Commands/RemoveLocker/RemoveLockerCommand.cs new file mode 100644 index 00000000..412df4b7 --- /dev/null +++ b/src/Application/Lockers/Commands/RemoveLocker/RemoveLockerCommand.cs @@ -0,0 +1,9 @@ +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Lockers.Commands.RemoveLocker; + +public record RemoveLockerCommand : IRequest +{ + public Guid LockerId { get; init; } +} \ No newline at end of file diff --git a/src/Application/Lockers/Commands/UpdateLocker/UpdateLockerCommand.cs b/src/Application/Lockers/Commands/UpdateLocker/UpdateLockerCommand.cs new file mode 100644 index 00000000..540ceeef --- /dev/null +++ b/src/Application/Lockers/Commands/UpdateLocker/UpdateLockerCommand.cs @@ -0,0 +1,12 @@ +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Lockers.Commands.UpdateLocker; + +public record UpdateLockerCommand : IRequest +{ + public Guid LockerId { get; set; } + public string Name { get; set; } = null!; + public string? Description { get; set; } + public int Capacity { get; init; } +} \ No newline at end of file diff --git a/src/Application/Lockers/Queries/GetAllLockersPaginated/GetAllLockersPaginatedQuery.cs b/src/Application/Lockers/Queries/GetAllLockersPaginated/GetAllLockersPaginatedQuery.cs new file mode 100644 index 00000000..4e0e8eb7 --- /dev/null +++ b/src/Application/Lockers/Queries/GetAllLockersPaginated/GetAllLockersPaginatedQuery.cs @@ -0,0 +1,14 @@ +using Application.Common.Models; +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Lockers.Queries.GetAllLockersPaginated; + +public record GetAllLockersPaginatedQuery : IRequest> +{ + public Guid? RoomId { get; init; } + public int? Page { get; init; } + public int? Size { get; init; } + public string? SortBy { get; init; } + public string? SortOrder { get; init; } +} \ No newline at end of file diff --git a/src/Application/Lockers/Queries/GetLockerById/GetLockerByIdQuery.cs b/src/Application/Lockers/Queries/GetLockerById/GetLockerByIdQuery.cs new file mode 100644 index 00000000..1a592104 --- /dev/null +++ b/src/Application/Lockers/Queries/GetLockerById/GetLockerByIdQuery.cs @@ -0,0 +1,9 @@ +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Lockers.Queries.GetLockerById; + +public record GetLockerByIdQuery : IRequest +{ + public Guid LockerId { get; init; } +} \ No newline at end of file diff --git a/src/Application/Rooms/Commands/EnableRoom/EnableRoomCommand.cs b/src/Application/Rooms/Commands/EnableRoom/EnableRoomCommand.cs new file mode 100644 index 00000000..d89c52a5 --- /dev/null +++ b/src/Application/Rooms/Commands/EnableRoom/EnableRoomCommand.cs @@ -0,0 +1,9 @@ +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Rooms.Commands.EnableRoom; + +public record EnableRoomCommand : IRequest +{ + public Guid RoomId { get; init; } +} \ No newline at end of file diff --git a/src/Application/Rooms/Commands/UpdateRoom/UpdateRoomCommand.cs b/src/Application/Rooms/Commands/UpdateRoom/UpdateRoomCommand.cs new file mode 100644 index 00000000..2e603d9d --- /dev/null +++ b/src/Application/Rooms/Commands/UpdateRoom/UpdateRoomCommand.cs @@ -0,0 +1,12 @@ +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Rooms.Commands.UpdateRoom; + +public record UpdateRoomCommand : IRequest +{ + public Guid RoomId { get; init; } + public string Name { get; set; } = null!; + public string? Description { get; init; } + public int Capacity { get; init; } +} \ No newline at end of file diff --git a/src/Application/Rooms/Queries/GetAllRoomPaginated/GetAllRoomsPaginatedQuery.cs b/src/Application/Rooms/Queries/GetAllRoomPaginated/GetAllRoomsPaginatedQuery.cs new file mode 100644 index 00000000..c691570f --- /dev/null +++ b/src/Application/Rooms/Queries/GetAllRoomPaginated/GetAllRoomsPaginatedQuery.cs @@ -0,0 +1,13 @@ +using Application.Common.Models; +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Rooms.Queries.GetAllRoomPaginated; + +public record GetAllRoomsPaginatedQuery : IRequest> +{ + public int? Page { get; init; } + public int? Size { get; init; } + public string? SortBy { get; init; } + public string? SortOrder { get; init; } +} \ No newline at end of file diff --git a/src/Application/Rooms/Queries/GetRoomById/GetRoomByIdQuery.cs b/src/Application/Rooms/Queries/GetRoomById/GetRoomByIdQuery.cs new file mode 100644 index 00000000..638e9b51 --- /dev/null +++ b/src/Application/Rooms/Queries/GetRoomById/GetRoomByIdQuery.cs @@ -0,0 +1,9 @@ +using Application.Common.Models.Dtos.Physical; +using MediatR; + +namespace Application.Rooms.Queries.GetRoomById; + +public record GetRoomByIdQuery : IRequest +{ + public Guid RoomId { get; init; } +} \ No newline at end of file diff --git a/src/Application/Staffs/Commands/RemoveStaffFromRoom/RemoveStaffFromRoomCommand.cs b/src/Application/Staffs/Commands/RemoveStaffFromRoom/RemoveStaffFromRoomCommand.cs new file mode 100644 index 00000000..c25f18ca --- /dev/null +++ b/src/Application/Staffs/Commands/RemoveStaffFromRoom/RemoveStaffFromRoomCommand.cs @@ -0,0 +1,10 @@ +using Application.Users.Queries.Physical; +using MediatR; + +namespace Application.Staffs.Commands.RemoveStaffFromRoom; + +public record RemoveStaffFromRoomCommand : IRequest +{ + public Guid StaffId { get; init; } + public Guid RoomId { get; init; } +} \ No newline at end of file diff --git a/src/Application/Staffs/Queries/GetAllStaffsPaginated/GetAllStaffsPaginatedQuery.cs b/src/Application/Staffs/Queries/GetAllStaffsPaginated/GetAllStaffsPaginatedQuery.cs new file mode 100644 index 00000000..a640b907 --- /dev/null +++ b/src/Application/Staffs/Queries/GetAllStaffsPaginated/GetAllStaffsPaginatedQuery.cs @@ -0,0 +1,14 @@ +using Application.Common.Models; +using Application.Users.Queries.Physical; +using MediatR; + +namespace Application.Staffs.Queries.GetAllStaffsPaginated; + +public class GetAllStaffsPaginatedQuery : IRequest> +{ + public string? SearchTerm { get; set; } + public int? Page { get; set; } + public int? Size { get; set; } + public string? SortBy { get; set; } + public string? SortOrder { get; set; } +} \ No newline at end of file diff --git a/src/Application/Staffs/Queries/GetStaffById/GetStaffByIdQuery.cs b/src/Application/Staffs/Queries/GetStaffById/GetStaffByIdQuery.cs new file mode 100644 index 00000000..7efed7f2 --- /dev/null +++ b/src/Application/Staffs/Queries/GetStaffById/GetStaffByIdQuery.cs @@ -0,0 +1,9 @@ +using Application.Users.Queries.Physical; +using MediatR; + +namespace Application.Staffs.Queries.GetStaffById; + +public record GetStaffByIdQuery : IRequest +{ + public Guid StaffId { get; init; } +} \ No newline at end of file diff --git a/src/Application/Staffs/Queries/GetStaffByRoom/GetStaffByRoomQuery.cs b/src/Application/Staffs/Queries/GetStaffByRoom/GetStaffByRoomQuery.cs new file mode 100644 index 00000000..0d3d8a1f --- /dev/null +++ b/src/Application/Staffs/Queries/GetStaffByRoom/GetStaffByRoomQuery.cs @@ -0,0 +1,9 @@ +using Application.Users.Queries.Physical; +using MediatR; + +namespace Application.Staffs.Queries.GetStaffByRoom; + +public record GetStaffByRoomQuery : IRequest +{ + public Guid RoomId { get; init; } +} \ No newline at end of file diff --git a/src/Application/Users/Commands/EnableUser/EnableUserCommand.cs b/src/Application/Users/Commands/EnableUser/EnableUserCommand.cs new file mode 100644 index 00000000..047f13d5 --- /dev/null +++ b/src/Application/Users/Commands/EnableUser/EnableUserCommand.cs @@ -0,0 +1,9 @@ +using Application.Users.Queries; +using MediatR; + +namespace Application.Users.Commands.EnableUser; + +public record EnableUserCommand : IRequest +{ + public Guid UserId { get; init; } +} \ No newline at end of file diff --git a/src/Application/Users/Commands/UpdateUser/UpdateUserCommand.cs b/src/Application/Users/Commands/UpdateUser/UpdateUserCommand.cs new file mode 100644 index 00000000..0f3736ea --- /dev/null +++ b/src/Application/Users/Commands/UpdateUser/UpdateUserCommand.cs @@ -0,0 +1,15 @@ +using Application.Users.Queries; +using MediatR; + +namespace Application.Users.Commands.UpdateUser; + +public record UpdateUserCommand : IRequest +{ + public Guid UserId { get; init; } + public string Username { get; init; } = null!; + public string Email { get; init; } = null!; + public string? FirstName { get; init; } + public string? LastName { get; init; } + public string Role { get; init; } = null!; + public string? Position { get; init; } +} \ No newline at end of file diff --git a/src/Application/Users/Queries/GetAllUsersPaginated/GetAllUsersPaginatedQuery.cs b/src/Application/Users/Queries/GetAllUsersPaginated/GetAllUsersPaginatedQuery.cs new file mode 100644 index 00000000..0c3146c7 --- /dev/null +++ b/src/Application/Users/Queries/GetAllUsersPaginated/GetAllUsersPaginatedQuery.cs @@ -0,0 +1,14 @@ +using Application.Common.Models; +using MediatR; + +namespace Application.Users.Queries.GetAllUsersPaginated; + +public record GetAllUsersPaginatedQuery : IRequest> +{ + public Guid? DepartmentId { get; init; } + public string? SearchTerm { get; init; } + public int? Page { get; init; } + public int? Size { get; init; } + public string? SortBy { get; init; } + public string? SortOrder { get; init; } +} \ No newline at end of file diff --git a/src/Application/Users/Queries/GetUserById/GetUserByIdQuery.cs b/src/Application/Users/Queries/GetUserById/GetUserByIdQuery.cs new file mode 100644 index 00000000..9f2e60d7 --- /dev/null +++ b/src/Application/Users/Queries/GetUserById/GetUserByIdQuery.cs @@ -0,0 +1,8 @@ +using MediatR; + +namespace Application.Users.Queries.GetUserById; + +public record GetUserByIdQuery : IRequest +{ + public Guid UserId { get; init; } +} \ No newline at end of file