Skip to content

Commit

Permalink
Blazor App Added
Browse files Browse the repository at this point in the history
  • Loading branch information
rahiyansafin committed May 5, 2023
1 parent 7442a88 commit 3422bb2
Show file tree
Hide file tree
Showing 54 changed files with 2,025 additions and 52 deletions.
20 changes: 20 additions & 0 deletions HR.LeaveManagement.API/Controllers/AuthController.cs
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 HR.LeaveManagement.API/Controllers/LeaveAllocationsController.cs
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 HR.LeaveManagement.API/Controllers/LeaveRequestsController.cs
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 HR.LeaveManagement.API/Controllers/LeaveTypesController.cs
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 HR.LeaveManagement.API/Controllers/WeatherForecastController.cs

This file was deleted.

2 changes: 2 additions & 0 deletions HR.LeaveManagement.API/HR.LeaveManagement.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

<ItemGroup>
<ProjectReference Include="..\HR.LeaveManagement.Application\HR.LeaveManagement.Application.csproj" />
<ProjectReference Include="..\HR.LeaveManagement.Infrastructure\HR.LeaveManagement.Infrastructure.csproj" />
<ProjectReference Include="..\HR.LeaveManagement.Persistence\HR.LeaveManagement.Persistence.csproj" />
</ItemGroup>

</Project>
11 changes: 6 additions & 5 deletions HR.LeaveManagement.API/Program.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
using HR.LeaveManagement.API.Middlewares;
using HR.LeaveManagement.Application;
using HR.LeaveManagement.Infrastructure;
using HR.LeaveManagement.Persistence;

using Serilog;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Host.UseSerilog((context, loggerConfig) => loggerConfig
.WriteTo.Console()
.ReadFrom.Configuration(context.Configuration));

//builder.Services.AddApplicationServices();
//builder.Services.AddInfrastructureServices(builder.Configuration);
//builder.Services.AddPersistenceServices(builder.Configuration);
//builder.Services.AddIdentityServices(builder.Configuration);
builder.Services.AddApplicationServices();
builder.Services.AddInfrastructureServices(builder.Configuration);
builder.Services.AddPersistenceServices(builder.Configuration);

builder.Services.AddControllers();

Expand Down
12 changes: 0 additions & 12 deletions HR.LeaveManagement.API/WeatherForecast.cs

This file was deleted.

2 changes: 1 addition & 1 deletion HR.LeaveManagement.API/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}
},
"ConnectionStrings": {
"HrDatabaseConnectionString": "Server=(localdb)\\mssqllocaldb;Database=db_hr_leavemanagement;Trusted_Connection=True;MultipleActiveResultSets=true"
"HrDatabaseConnectionString": "Server=LAPTOP-B438U61N\\SQLEXPRESS;Database=db_hr_leavemanagement;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"EmailSettings": {
"ApiKey": "SendGrid-Key",
Expand Down
Loading

0 comments on commit 3422bb2

Please sign in to comment.