-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7442a88
commit 3422bb2
Showing
54 changed files
with
2,025 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using HR.LeaveManagement.Application.Contracts.Identity; | ||
using HR.LeaveManagement.Application.Models.Identity; | ||
|
||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace HR.LeaveManagement.API.Controllers; | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
public class AuthController : ControllerBase | ||
{ | ||
private readonly IAuthService _authenticationService; | ||
|
||
public AuthController(IAuthService authenticationService) => _authenticationService = authenticationService; | ||
|
||
[HttpPost("login")] | ||
public async Task<ActionResult<AuthResponse>> Login(AuthRequest request) => Ok(await _authenticationService.Login(request)); | ||
|
||
[HttpPost("register")] | ||
public async Task<ActionResult<RegistrationResponse>> Register(RegistrationRequest request) => Ok(await _authenticationService.Register(request)); | ||
} |
70 changes: 70 additions & 0 deletions
70
HR.LeaveManagement.API/Controllers/LeaveAllocationsController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using HR.LeaveManagement.Application.Features.LeaveAllocation.Commands.CreateLeaveAllocation; | ||
using HR.LeaveManagement.Application.Features.LeaveAllocation.Commands.DeleteLeaveAllocation; | ||
using HR.LeaveManagement.Application.Features.LeaveAllocation.Commands.UpdateLeaveAllocation; | ||
using HR.LeaveManagement.Application.Features.LeaveAllocation.Queries.GetLeaveAllocationDetails; | ||
using HR.LeaveManagement.Application.Features.LeaveAllocation.Queries.GetLeaveAllocations; | ||
|
||
using MediatR; | ||
|
||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace HR.LeaveManagement.API.Controllers; | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
public class LeaveAllocationsController : ControllerBase | ||
{ | ||
private readonly IMediator _mediator; | ||
|
||
public LeaveAllocationsController(IMediator mediator) => _mediator = mediator; | ||
|
||
// GET: api/<LeaveAllocationsController> | ||
[HttpGet] | ||
public async Task<ActionResult<List<LeaveAllocationDto>>> Get(bool isLoggedInUser = false) | ||
{ | ||
var leaveAllocations = await _mediator.Send(new GetLeaveAllocationListQuery()); | ||
return Ok(leaveAllocations); | ||
} | ||
|
||
// GET api/<LeaveAllocationsController>/5 | ||
[HttpGet("{id}")] | ||
public async Task<ActionResult<LeaveAllocationDetailsDto>> Get(int id) | ||
{ | ||
var leaveAllocation = await _mediator.Send(new GetLeaveAllocationDetailQuery { Id = id }); | ||
return Ok(leaveAllocation); | ||
} | ||
|
||
// POST api/<LeaveAllocationsController> | ||
[HttpPost] | ||
[ProducesResponseType(201)] | ||
[ProducesResponseType(400)] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
public async Task<ActionResult> Post(CreateLeaveAllocationCommand leaveAllocation) | ||
{ | ||
var response = await _mediator.Send(leaveAllocation); | ||
return CreatedAtAction(nameof(Get), new { id = response }); | ||
} | ||
|
||
// PUT api/<LeaveAllocationsController>/5 | ||
[HttpPut] | ||
[ProducesResponseType(StatusCodes.Status204NoContent)] | ||
[ProducesResponseType(400)] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
[ProducesDefaultResponseType] | ||
public async Task<ActionResult> Put(UpdateLeaveAllocationCommand leaveAllocation) | ||
{ | ||
await _mediator.Send(leaveAllocation); | ||
return NoContent(); | ||
} | ||
|
||
// DELETE api/<LeaveAllocationsController>/5 | ||
[HttpDelete("{id}")] | ||
[ProducesResponseType(StatusCodes.Status204NoContent)] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
[ProducesDefaultResponseType] | ||
public async Task<ActionResult> Delete(int id) | ||
{ | ||
var command = new DeleteLeaveAllocationCommand { Id = id }; | ||
await _mediator.Send(command); | ||
return NoContent(); | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
HR.LeaveManagement.API/Controllers/LeaveRequestsController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using HR.LeaveManagement.Application.Features.LeaveRequest.Commands.CancelLeaveRequest; | ||
using HR.LeaveManagement.Application.Features.LeaveRequest.Commands.ChangeLeaveRequestApproval; | ||
using HR.LeaveManagement.Application.Features.LeaveRequest.Commands.CreateLeaveRequest; | ||
using HR.LeaveManagement.Application.Features.LeaveRequest.Commands.DeleteLeaveRequest; | ||
using HR.LeaveManagement.Application.Features.LeaveRequest.Commands.UpdateLeaveRequest; | ||
using HR.LeaveManagement.Application.Features.LeaveRequest.Queries.GetLeaveRequestDetail; | ||
using HR.LeaveManagement.Application.Features.LeaveRequest.Queries.GetLeaveRequestList; | ||
|
||
using MediatR; | ||
|
||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace HR.LeaveManagement.API.Controllers; | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
[Authorize] | ||
public class LeaveRequestsController : ControllerBase | ||
{ | ||
private readonly IMediator _mediator; | ||
|
||
public LeaveRequestsController(IMediator mediator) => _mediator = mediator; | ||
|
||
// GET: api/<LeaveRequestsController> | ||
[HttpGet] | ||
public async Task<ActionResult<List<LeaveRequestListDto>>> Get(bool isLoggedInUser = false) | ||
{ | ||
var leaveRequests = await _mediator.Send(new GetLeaveRequestListQuery()); | ||
return Ok(leaveRequests); | ||
} | ||
|
||
// GET api/<LeaveRequestsController>/5 | ||
[HttpGet("{id}")] | ||
public async Task<ActionResult<LeaveRequestDetailsDto>> Get(int id) | ||
{ | ||
var leaveRequest = await _mediator.Send(new GetLeaveRequestDetailQuery { Id = id }); | ||
return Ok(leaveRequest); | ||
} | ||
|
||
// POST api/<LeaveRequestsController> | ||
[HttpPost] | ||
[ProducesResponseType(201)] | ||
[ProducesResponseType(400)] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
public async Task<ActionResult> Post(CreateLeaveRequestCommand leaveRequest) | ||
{ | ||
var response = await _mediator.Send(leaveRequest); | ||
return CreatedAtAction(nameof(Get), new { id = response }); | ||
} | ||
|
||
// PUT api/<LeaveRequestsController>/5 | ||
[HttpPut] | ||
[ProducesResponseType(StatusCodes.Status204NoContent)] | ||
[ProducesResponseType(400)] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
[ProducesDefaultResponseType] | ||
public async Task<ActionResult> Put(UpdateLeaveRequestCommand leaveRequest) | ||
{ | ||
await _mediator.Send(leaveRequest); | ||
return NoContent(); | ||
} | ||
|
||
// PUT api/<LeaveRequestsController>/CancelRequest/ | ||
[HttpPut] | ||
[Route("CancelRequest")] | ||
[ProducesResponseType(StatusCodes.Status204NoContent)] | ||
[ProducesResponseType(400)] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
[ProducesDefaultResponseType] | ||
public async Task<ActionResult> CancelRequest(CancelLeaveRequestCommand cancelLeaveRequest) | ||
{ | ||
await _mediator.Send(cancelLeaveRequest); | ||
return NoContent(); | ||
} | ||
|
||
// PUT api/<LeaveRequestsController>/UpdateApproval/ | ||
[HttpPut] | ||
[Route("UpdateApproval")] | ||
[ProducesResponseType(StatusCodes.Status204NoContent)] | ||
[ProducesResponseType(400)] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
[ProducesDefaultResponseType] | ||
public async Task<ActionResult> UpdateApproval(ChangeLeaveRequestApprovalCommand updateApprovalRequest) | ||
{ | ||
await _mediator.Send(updateApprovalRequest); | ||
return NoContent(); | ||
} | ||
|
||
// DELETE api/<LeaveRequestsController>/5 | ||
[HttpDelete("{id}")] | ||
[ProducesResponseType(StatusCodes.Status204NoContent)] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
[ProducesDefaultResponseType] | ||
public async Task<ActionResult> Delete(int id) | ||
{ | ||
var command = new DeleteLeaveRequestCommand { Id = id }; | ||
await _mediator.Send(command); | ||
return NoContent(); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
HR.LeaveManagement.API/Controllers/LeaveTypesController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using HR.LeaveManagement.Application.Features.LeaveType.Commands.CreateLeaveType; | ||
using HR.LeaveManagement.Application.Features.LeaveType.Commands.DeleteLeaveType; | ||
using HR.LeaveManagement.Application.Features.LeaveType.Commands.UpdateLeaveType; | ||
using HR.LeaveManagement.Application.Features.LeaveType.Queries.GetAllLeaveTypes; | ||
using HR.LeaveManagement.Application.Features.LeaveType.Queries.GetLeaveTypeDetails; | ||
|
||
using MediatR; | ||
|
||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace HR.LeaveManagement.API.Controllers; | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
[Authorize] | ||
public class LeaveTypesController : ControllerBase | ||
{ | ||
private readonly IMediator _mediator; | ||
|
||
public LeaveTypesController(IMediator mediator) => _mediator = mediator; | ||
|
||
// GET: api/<LeaveTypesController> | ||
[HttpGet] | ||
public async Task<List<LeaveTypeDto>> Get() | ||
{ | ||
var leaveTypes = await _mediator.Send(new GetLeaveTypesQuery()); | ||
return leaveTypes; | ||
} | ||
|
||
// GET api/<LeaveTypesController>/5 | ||
[HttpGet("{id}")] | ||
public async Task<ActionResult<LeaveTypeDetailsDto>> Get(int id) | ||
{ | ||
var leaveType = await _mediator.Send(new GetLeaveTypeDetailsQuery(id)); | ||
return Ok(leaveType); | ||
} | ||
|
||
// POST api/<LeaveTypesController> | ||
[HttpPost] | ||
[ProducesResponseType(201)] | ||
[ProducesResponseType(400)] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
public async Task<ActionResult> Post(CreateLeaveTypeCommand leaveType) | ||
{ | ||
var response = await _mediator.Send(leaveType); | ||
return CreatedAtAction(nameof(Get), new { id = response }); | ||
} | ||
|
||
// PUT api/<LeaveTypesController> | ||
[HttpPut("{id}")] | ||
[ProducesResponseType(StatusCodes.Status204NoContent)] | ||
[ProducesResponseType(400)] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
[ProducesDefaultResponseType] | ||
public async Task<ActionResult> Put(UpdateLeaveTypeCommand leaveType) | ||
{ | ||
await _mediator.Send(leaveType); | ||
return NoContent(); | ||
} | ||
|
||
// DELETE api/<LeaveTypesController>/5 | ||
[HttpDelete("{id}")] | ||
[ProducesResponseType(StatusCodes.Status204NoContent)] | ||
[ProducesResponseType(StatusCodes.Status404NotFound)] | ||
[ProducesDefaultResponseType] | ||
public async Task<ActionResult> Delete(int id) | ||
{ | ||
var command = new DeleteLeaveTypeCommand { Id = id }; | ||
await _mediator.Send(command); | ||
return NoContent(); | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
HR.LeaveManagement.API/Controllers/WeatherForecastController.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.