Merge branch 'develop' into work

This commit is contained in:
Kittapath 2023-07-13 15:18:50 +07:00
commit 94b1e3b848
49 changed files with 28066 additions and 335 deletions

View file

@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>3d68209a-41b1-4d00-914e-b895d74467c0</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerfileContext>.</DockerfileContext>
<RootNamespace>BMA.EHR.OrganizationEmployee.Service</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="6.32.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Sentry.AspNetCore" Version="3.33.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="9.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
</ItemGroup>
</Project>

View file

@ -36,7 +36,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BMA.EHR.API.Command\BMA.EHR.API.Command.csproj" />
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
</ItemGroup>

View file

@ -1,84 +0,0 @@
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Shared;
using System.Net;
namespace BMA.EHR.OrganizationEmployee.Service
{
public class ErrorHandlerMiddleware
{
#region " Fields "
private readonly RequestDelegate _next;
#endregion
#region " Constructor and Destructor "
public ErrorHandlerMiddleware(RequestDelegate next)
{
_next = next;
}
#endregion
#region " Methods "
public async Task Invoke(HttpContext context)
{
try
{
await _next(context);
var response = context.Response;
response.ContentType = "application/json";
var responseModel = new ResponseObject();
responseModel.Status = response.StatusCode;
if (responseModel.Status == (int)HttpStatusCode.Unauthorized)
{
responseModel.Message = GlobalMessages.NotAuthorized;
await response.WriteAsJsonAsync(responseModel);
}
if (responseModel.Status == (int)HttpStatusCode.Forbidden)
{
responseModel.Message = GlobalMessages.ForbiddenAccess;
await response.WriteAsJsonAsync(responseModel);
}
}
catch (Exception error)
{
var response = context.Response;
response.ContentType = "application/json";
var responseModel = new ResponseObject();
responseModel.Status = response.StatusCode;
var msg = error.Message;
var inner = error.InnerException;
while (inner != null)
{
msg += $" {inner.Message}\r\n";
inner = inner.InnerException;
}
responseModel.Result = msg;
switch (response.StatusCode)
{
case (int)HttpStatusCode.Unauthorized:
responseModel.Message = GlobalMessages.NotAuthorized;
break;
case (int)HttpStatusCode.Forbidden:
responseModel.Message = GlobalMessages.ForbiddenAccess;
break;
default:
responseModel.Status = (int)HttpStatusCode.InternalServerError;
responseModel.Message = GlobalMessages.ExceptionOccured;
break;
}
await response.WriteAsJsonAsync(responseModel);
}
}
#endregion
}
}

View file

@ -1,4 +1,5 @@
using BMA.EHR.Application;
using BMA.EHR.Domain.Middlewares;
using BMA.EHR.Infrastructure;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.OrganizationEmployee.Service;
@ -110,7 +111,7 @@ var app = builder.Build();
app.MapHealthChecks("/health");
//app.UseMiddleware<ErrorHandlerMiddleware>();
app.UseHttpsRedirection();
app.UseCors();
app.UseAuthentication();
@ -118,6 +119,7 @@ var app = builder.Build();
app.UseDefaultFiles();
app.UseStaticFiles();
app.MapControllers();
app.UseMiddleware<ErrorHandlerMiddleware>();
// apply migrations
await using var scope = app.Services.CreateAsyncScope();