Skip to content

Commit

Permalink
Merge pull request #1 from PhucNghi176/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
PhucNghi176 authored Jun 27, 2024
2 parents 26a6316 + d57f334 commit b52261e
Show file tree
Hide file tree
Showing 35 changed files with 339 additions and 308 deletions.
1 change: 1 addition & 0 deletions DeerCoffeeShop.API/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CLOUDINARY_URL=cloudinary://176963282532847:kONanxuhiEwEmJKFPC72M1a2rUs@dmiueqpah
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using DeerCoffeeShop.API.Controllers.ResponseTypes;
using DeerCoffeeShop.Application.Common.Pagination;
using DeerCoffeeShop.Application.EmployeeShift;
using DeerCoffeeShop.Application.EmployeeShift.AssignEmployee;
using DeerCoffeeShop.Application.EmployeeShift.CheckIn_Out.CheckIn;
using DeerCoffeeShop.Application.EmployeeShift.CheckIn_Out.CheckOut;
using DeerCoffeeShop.Application.EmployeeShift.Create;
using DeerCoffeeShop.Application.EmployeeShift.Delete;
using DeerCoffeeShop.Application.EmployeeShift.GetAll;
Expand Down Expand Up @@ -75,6 +75,37 @@ public async Task<IActionResult> GetEmployeeShiftInAWeekQuery([FromQuery] GetEmp
};
return Ok(respond);
}
[HttpGet("day")]
[ProducesResponseType(typeof(PagedResult<EmployeeShiftDto>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]

public async Task<ActionResult<JsonResponse<PagedResult<EmployeeShiftDto>>>> GetByDay
([FromQuery] GetEmployeeShiftByDayQuery query, CancellationToken cancellationToken)
{
var result = await _mediator.Send(query, cancellationToken);
var list = new List<object>();
foreach (var item in result.Data)
{

var testreturn = new
{
title = item.Employee.FullName ?? "Not Pick",
start = item.CheckIn,
end = item.CheckOut,
allDay = false,
resource = item
};
list.Add(testreturn);
}
var respond = new
{
Message = "Get successfully",
Data = list
};
return Ok(respond);
}
[HttpDelete]
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
Expand Down Expand Up @@ -106,23 +137,7 @@ public async Task<ActionResult<JsonResponse<PagedResult<EmployeeShiftDto>>>> Get
return Ok(respond);
}

[HttpGet("day")]
[ProducesResponseType(typeof(PagedResult<EmployeeShiftDto>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]

public async Task<ActionResult<JsonResponse<PagedResult<EmployeeShiftDto>>>> GetByDay
([FromQuery] GetEmployeeShiftByDayQuery query, CancellationToken cancellationToken)
{
var result = await _mediator.Send(query, cancellationToken);
var respond = new
{
Message = "Get successfully",
Data = result
};
return Ok(respond);
}

[HttpPost]
[Produces(MediaTypeNames.Application.Json)]
Expand All @@ -135,38 +150,22 @@ public async Task<ActionResult<JsonResponse<PagedResult<EmployeeShiftDto>>>> Get
public async Task<ActionResult<JsonResponse<string>>> Create([FromBody] CreateEmployeeShiftCommand command, CancellationToken cancellationToken)
{
var result = await _mediator.Send(command, cancellationToken);
return Ok(result);
var respond = new
{
Message = "Create successfully",
Data = result
};
return Ok(respond);
}

[HttpPut("assign-employee")]
[Produces(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(JsonResponse<string>), StatusCodes.Status201Created)]
[ProducesResponseType(typeof(JsonResponse<string>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<JsonResponse<string>>> Assign([FromBody] AssignEmployeeToEmployeeShiftCommand command, CancellationToken cancellationToken)
[HttpPost("CheckIn")]
public async Task<ActionResult<JsonResponse<string>>> CheckIn([FromForm] CheckInCommand command, CancellationToken cancellationToken)
{
var result = await _mediator.Send(command, cancellationToken);
return Ok(result);
}

//[HttpPut("employee-check-in")]
//[Produces(MediaTypeNames.Application.Json)]
//[ProducesResponseType(typeof(JsonResponse<string>), StatusCodes.Status201Created)]
//[ProducesResponseType(typeof(JsonResponse<string>), StatusCodes.Status200OK)]
//[ProducesResponseType(StatusCodes.Status401Unauthorized)]
//[ProducesResponseType(StatusCodes.Status400BadRequest)]
//[ProducesResponseType(StatusCodes.Status403Forbidden)]
//[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
//public async Task<ActionResult<JsonResponse<string>>> Update([FromBody] UpdateEmployeeShiftCommand command, CancellationToken cancellationToken)
//{
// var result = await _mediator.Send(command, cancellationToken);
// return Ok(result);
//}
[HttpGet("employee-check-in")]
public async Task<ActionResult<JsonResponse<string>>> CheckIn([FromQuery] CheckInCommand command, CancellationToken cancellationToken)
[HttpPost("CheckOut")]
public async Task<ActionResult<JsonResponse<string>>> CheckOut([FromForm] CheckOutCommand command, CancellationToken cancellationToken)
{
var result = await _mediator.Send(command, cancellationToken);
return Ok(result);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DeerCoffeeShop.API.Controllers.ResponseTypes;
using DeerCoffeeShop.Application.EmployeeShift.CheckIn_Out.CheckIn;
using DeerCoffeeShop.Application.FaceID.DetectFaceFromImage;
using DeerCoffeeShop.Application.FaceID.SaveImage;
using MediatR;
Expand All @@ -16,9 +17,9 @@ public async Task<IActionResult> SaveImage([FromForm] SaveImageCommand command)
return Ok(result);
}
[HttpPost("detect-image")]
public async Task<IActionResult> DetectFaceFromImage([FromForm]DetecFaceFromImageQuery query)
public async Task<IActionResult> DetectFaceFromImage([FromForm] CheckInCommand query)
{
var result = await _sender.Send(new DetecFaceFromImageQuery(query.Image));
return Ok(result);
var response = await _sender.Send(query);
return Ok(response);
}
}
4 changes: 2 additions & 2 deletions DeerCoffeeShop.API/DeerCoffeeShop.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ItemGroup>
<PackageReference Include="Asp.Versioning.Mvc" Version="8.1.0" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageReference Include="dotenv.net" Version="3.2.0" />
<PackageReference Include="IdentityModel" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6">
Expand All @@ -29,8 +30,7 @@
</ItemGroup>

<ItemGroup>
<Content Include="haarcascade_frontalface_default.xml"
CopyToOutputDirectory="PreserveNewest" />
<Content Include="haarcascade_frontalface_default.xml" CopyToOutputDirectory="PreserveNewest" />
<ProjectReference Include="..\DeerCoffeeShop.Application\DeerCoffeeShop.Application.csproj" />
<ProjectReference Include="..\DeerCoffeeShop.Domain\DeerCoffeeShop.Domain.csproj" />
<ProjectReference Include="..\DeerCoffeeShop.Infrastructure\DeerCoffeeShop.Infrastructure.csproj" />
Expand Down
5 changes: 5 additions & 0 deletions DeerCoffeeShop.API/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using CloudinaryDotNet;
using DeerCoffeeShop.API.Configuration;
using DeerCoffeeShop.API.Filters;
using DeerCoffeeShop.Application;

using DeerCoffeeShop.Domain.Entities;
using DeerCoffeeShop.Domain.Repositories;
using DeerCoffeeShop.Infrastructure;
using dotenv.net;
using Serilog;

// Create the builder
Expand All @@ -30,6 +32,9 @@
builder.Services.AddInfrastructure(builder.Configuration);
builder.Services.ConfigureSwagger();
builder.Services.ConfigurationCors();
DotEnv.Load(options: new DotEnvOptions(probeForEnv: true));
Cloudinary cloudinary = new(Environment.GetEnvironmentVariable("CLOUDINARY_URL"));
cloudinary.Api.Secure = true;
//allow all cors
builder.Services.AddCors(options =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="CloudinaryDotNet" Version="1.26.2" />
<PackageReference Include="FluentValidation" Version="11.9.2" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.2" />
<PackageReference Include="MailKit" Version="4.6.0" />
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit b52261e

Please sign in to comment.