forked from MDCPS/DamageAssessment_Backend
Compare commits
1 Commits
server-bra
...
Language-c
Author | SHA1 | Date | |
---|---|---|---|
4cf7d9f891 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,5 +0,0 @@
|
|||||||
################################################################################
|
|
||||||
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
/DamageAssesmentApi/nginx.conf
|
|
@ -1,25 +0,0 @@
|
|||||||
**/.classpath
|
|
||||||
**/.dockerignore
|
|
||||||
**/.env
|
|
||||||
**/.git
|
|
||||||
**/.gitignore
|
|
||||||
**/.project
|
|
||||||
**/.settings
|
|
||||||
**/.toolstarget
|
|
||||||
**/.vs
|
|
||||||
**/.vscode
|
|
||||||
**/*.*proj.user
|
|
||||||
**/*.dbmdl
|
|
||||||
**/*.jfm
|
|
||||||
**/azds.yaml
|
|
||||||
**/bin
|
|
||||||
**/charts
|
|
||||||
**/docker-compose*
|
|
||||||
**/Dockerfile*
|
|
||||||
**/node_modules
|
|
||||||
**/npm-debug.log
|
|
||||||
**/obj
|
|
||||||
**/secrets.dev.yaml
|
|
||||||
**/values.dev.yaml
|
|
||||||
LICENSE
|
|
||||||
README.md
|
|
@ -5,7 +5,7 @@ using Microsoft.OpenApi.Any;
|
|||||||
|
|
||||||
namespace DamageAssesment.Api.Answers.Controllers
|
namespace DamageAssesment.Api.Answers.Controllers
|
||||||
{
|
{
|
||||||
//[Route("api")]
|
[Route("api")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class AnswersController: ControllerBase
|
public class AnswersController: ControllerBase
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
|
||||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -14,7 +12,6 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.9" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.9" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
|
||||||
|
|
||||||
# Use the ASP.NET base image
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
|
||||||
WORKDIR /app
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
# Use the SDK image for building
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
# Copy the project file and restore dependencies
|
|
||||||
COPY ["DamageAssesment.Api.Answers/DamageAssesment.Api.Answers.csproj", "DamageAssesment.Api.Answers/"]
|
|
||||||
RUN dotnet restore "DamageAssesment.Api.Answers/DamageAssesment.Api.Answers.csproj"
|
|
||||||
|
|
||||||
# Copy the source code
|
|
||||||
COPY . .
|
|
||||||
WORKDIR "/src/DamageAssesment.Api.Answers"
|
|
||||||
|
|
||||||
# Build the application
|
|
||||||
RUN dotnet build "DamageAssesment.Api.Answers.csproj" -c Release -o /app/build
|
|
||||||
|
|
||||||
# Publish the application
|
|
||||||
FROM build AS publish
|
|
||||||
RUN dotnet publish "DamageAssesment.Api.Answers.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
||||||
|
|
||||||
# Set up the final image
|
|
||||||
FROM base AS final
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the published files
|
|
||||||
COPY --from=publish /app/publish .
|
|
||||||
|
|
||||||
## Set up the volume and copy the XML comments
|
|
||||||
#VOLUME /xmlcomments
|
|
||||||
#COPY ["DamageAssesment.Api.Answers.xml", "/xmlcomments/DamageAssesment.Api.Answers.xml"]
|
|
||||||
#
|
|
||||||
# Specify the entry point for the container
|
|
||||||
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Answers.dll"]
|
|
@ -2,8 +2,6 @@ using DamageAssesment.Api.Answers.Db;
|
|||||||
using DamageAssesment.Api.Answers.Interfaces;
|
using DamageAssesment.Api.Answers.Interfaces;
|
||||||
using DamageAssesment.Api.Answers.Providers;
|
using DamageAssesment.Api.Answers.Providers;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Microsoft.OpenApi.Models;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
@ -16,13 +14,10 @@ builder.Services.AddEndpointsApiExplorer();
|
|||||||
//builder.Services.AddSwaggerGen();
|
//builder.Services.AddSwaggerGen();
|
||||||
builder.Services.AddSwaggerGen(c =>
|
builder.Services.AddSwaggerGen(c =>
|
||||||
{
|
{
|
||||||
|
|
||||||
// Include XML comments from your assembly
|
// Include XML comments from your assembly
|
||||||
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||||
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
||||||
c.IncludeXmlComments(xmlPath);
|
c.IncludeXmlComments(xmlPath);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
builder.Services.AddScoped<IAnswersProvider, AnswersProvider>();
|
builder.Services.AddScoped<IAnswersProvider, AnswersProvider>();
|
||||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
|
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
|
||||||
@ -37,21 +32,8 @@ var app = builder.Build();
|
|||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
//using (var serviceScope = app.Services.CreateScope())
|
|
||||||
//{
|
|
||||||
// var services = serviceScope.ServiceProvider;
|
|
||||||
// var answerProvider = services.GetRequiredService<IAnswersProvider>();
|
|
||||||
// answerProvider.SeedData();
|
|
||||||
//}
|
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI(
|
app.UseSwaggerUI();
|
||||||
options =>
|
|
||||||
{
|
|
||||||
//switch for local environment
|
|
||||||
//options.SwaggerEndpoint("/swagger/v1/swagger.json", "");
|
|
||||||
options.SwaggerEndpoint("/answers/swagger/v1/swagger.json","" );
|
|
||||||
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
@ -7,7 +7,7 @@ using System.Net.Http.Headers;
|
|||||||
|
|
||||||
namespace DamageAssesment.Api.Attachments.Controllers
|
namespace DamageAssesment.Api.Attachments.Controllers
|
||||||
{
|
{
|
||||||
//[Route("api")]
|
[Route("api")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class AttachmentsController : ControllerBase
|
public class AttachmentsController : ControllerBase
|
||||||
{
|
{
|
||||||
|
@ -1 +0,0 @@
|
|||||||
sample
|
|
@ -5,8 +5,6 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
|
||||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -16,7 +14,6 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
|
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
|
||||||
# Use the ASP.NET base image
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
|
||||||
WORKDIR /app
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
# Use the SDK image for building
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
# Copy the project file and restore dependencies
|
|
||||||
COPY ["DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj", "DamageAssesment.Api.Attachments/"]
|
|
||||||
RUN dotnet restore "DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj"
|
|
||||||
|
|
||||||
# Copy the source code
|
|
||||||
COPY . .
|
|
||||||
WORKDIR "/src/DamageAssesment.Api.Attachments"
|
|
||||||
|
|
||||||
# Build the application
|
|
||||||
RUN dotnet build "DamageAssesment.Api.Attachments.csproj" -c Release -o /app/build
|
|
||||||
|
|
||||||
# Publish the application
|
|
||||||
FROM build AS publish
|
|
||||||
RUN dotnet publish "DamageAssesment.Api.Attachments.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
||||||
|
|
||||||
# Set up the final image
|
|
||||||
FROM base AS final
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the published files
|
|
||||||
COPY --from=publish /app/publish .
|
|
||||||
|
|
||||||
# Create directories for attachments and set permissions
|
|
||||||
RUN mkdir -p /app/DMS_Attachments/Active && \
|
|
||||||
mkdir -p /app/DMS_Attachments/Deleted && \
|
|
||||||
chown -R www-data:www-data /app/DMS_Attachments
|
|
||||||
|
|
||||||
# Update appsettings.json with the correct paths for attachments
|
|
||||||
RUN sed -i 's#"folderpath": "DMS_Attachments/Active"#"folderpath": "/app/DMS_Attachments/Active"#' appsettings.json && \
|
|
||||||
sed -i 's#"Deletepath": "DMS_Attachments/Deleted"#"Deletepath": "/app/DMS_Attachments/Deleted"#' appsettings.json
|
|
||||||
|
|
||||||
## Set up the volume and copy the XML comments
|
|
||||||
#VOLUME /xmlcomments
|
|
||||||
#COPY ["DamageAssesment.Api.Attachments/bin/Release/net6.0/DamageAssesment.Api.Attachments.xml", "/xmlcomments/"]
|
|
||||||
#
|
|
||||||
# Specify the entry point for the container
|
|
||||||
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Attachments.dll"]
|
|
@ -13,6 +13,5 @@ namespace DamageAssesment.Api.Attachments.Interfaces
|
|||||||
Task<(bool IsSuccess, int counter, string Path)> DeleteBulkAttachmentsAsync(int responseId, List<int> answerIds);
|
Task<(bool IsSuccess, int counter, string Path)> DeleteBulkAttachmentsAsync(int responseId, List<int> answerIds);
|
||||||
Task<(bool IsSuccess, int counter, string message)> GetAttachmentCounter();
|
Task<(bool IsSuccess, int counter, string message)> GetAttachmentCounter();
|
||||||
Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> GetAttachmentInfo(List<AnswerInfo> answers);
|
Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> GetAttachmentInfo(List<AnswerInfo> answers);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,7 @@ var app = builder.Build();
|
|||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI(options => {
|
app.UseSwaggerUI();
|
||||||
//switch for local environment
|
|
||||||
// options.SwaggerEndpoint("/swagger/v1/swagger.json", "");
|
|
||||||
options.SwaggerEndpoint("/attachments/swagger/v1/swagger.json", "");
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
|
|
||||||
namespace DamageAssesment.Api.Employees.Controllers
|
namespace DamageAssesment.Api.Employees.Controllers
|
||||||
{
|
{
|
||||||
//[Route("api")]
|
[Route("api")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class EmployeesController : ControllerBase
|
public class EmployeesController : ControllerBase
|
||||||
{
|
{
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
|
||||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -14,7 +12,6 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
|
||||||
|
|
||||||
# Use the ASP.NET base image
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
|
||||||
WORKDIR /app
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
# Use the SDK image for building
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
# Copy the project file and restore dependencies
|
|
||||||
COPY ["DamageAssesment.Api.Employees/DamageAssesment.Api.Employees.csproj", "DamageAssesment.Api.Employees/"]
|
|
||||||
RUN dotnet restore "DamageAssesment.Api.Employees/DamageAssesment.Api.Employees.csproj"
|
|
||||||
|
|
||||||
# Copy the source code
|
|
||||||
COPY . .
|
|
||||||
WORKDIR "/src/DamageAssesment.Api.Employees"
|
|
||||||
|
|
||||||
# Build the application
|
|
||||||
RUN dotnet build "DamageAssesment.Api.Employees.csproj" -c Release -o /app/build
|
|
||||||
|
|
||||||
# Publish the application
|
|
||||||
FROM build AS publish
|
|
||||||
RUN dotnet publish "DamageAssesment.Api.Employees.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
||||||
|
|
||||||
# Set up the final image
|
|
||||||
FROM base AS final
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the published files
|
|
||||||
COPY --from=publish /app/publish .
|
|
||||||
|
|
||||||
## Set up the volume and copy the XML comments
|
|
||||||
#VOLUME /xmlcomments
|
|
||||||
#COPY ["DamageAssesment.Api.Employees.xml", "/xmlcomments/DamageAssesment.Api.Employees.xml"]
|
|
||||||
|
|
||||||
# Specify the entry point for the container
|
|
||||||
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Employees.dll"]
|
|
@ -32,21 +32,15 @@ var app = builder.Build();
|
|||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI();
|
||||||
|
|
||||||
using (var serviceScope = app.Services.CreateScope())
|
using (var serviceScope = app.Services.CreateScope())
|
||||||
{
|
{
|
||||||
var services = serviceScope.ServiceProvider;
|
var services = serviceScope.ServiceProvider;
|
||||||
var employeeProvider = services.GetRequiredService<IEmployeesProvider>();
|
var employeesProvider = services.GetRequiredService<IEmployeesProvider>();
|
||||||
employeeProvider.SeedData();
|
employeesProvider.SeedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseSwagger();
|
|
||||||
app.UseSwaggerUI(options =>
|
|
||||||
{
|
|
||||||
//switch for local environment
|
|
||||||
// options.SwaggerEndpoint("/swagger/v1/swagger.json", "");
|
|
||||||
options.SwaggerEndpoint("/employees/swagger/v1/swagger.json", "");
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
@ -1,30 +1,4 @@
|
|||||||
{
|
{
|
||||||
"profiles": {
|
|
||||||
"DamageAssesment.Api.Employees": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
},
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"applicationUrl": "http://localhost:5135"
|
|
||||||
},
|
|
||||||
"IIS Express": {
|
|
||||||
"commandName": "IISExpress",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Docker": {
|
|
||||||
"commandName": "Docker",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
|
||||||
"publishAllPorts": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
"iisSettings": {
|
"iisSettings": {
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
@ -33,5 +7,25 @@
|
|||||||
"applicationUrl": "http://localhost:14425",
|
"applicationUrl": "http://localhost:14425",
|
||||||
"sslPort": 0
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"DamageAssesment.Api.Employees": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "http://localhost:5135",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ namespace DamageAssesment.Api.Employees.Providers
|
|||||||
this.EmployeeDbContext = EmployeeDbContext;
|
this.EmployeeDbContext = EmployeeDbContext;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
// SeedData();
|
// SeedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, IEnumerable<Models.Employee> Employees, string ErrorMessage)> GetEmployeesAsync()
|
public async Task<(bool IsSuccess, IEnumerable<Models.Employee> Employees, string ErrorMessage)> GetEmployeesAsync()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
@ -4,8 +4,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
|
|
||||||
namespace DamageAssesment.Api.Locations.Controllers
|
namespace DamageAssesment.Api.Locations.Controllers
|
||||||
{
|
{
|
||||||
[Route("Locations")]
|
[Route("api")]
|
||||||
//[Route("[controller]")]
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class LocationsController : ControllerBase
|
public class LocationsController : ControllerBase
|
||||||
{
|
{
|
||||||
@ -19,8 +18,7 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
/// Get all locations.
|
/// Get all locations.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
//[HttpGet("locations")]
|
[HttpGet("Locations")]
|
||||||
[HttpGet]
|
|
||||||
public async Task<ActionResult> GetLocationsAsync()
|
public async Task<ActionResult> GetLocationsAsync()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -29,14 +27,14 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
{
|
{
|
||||||
return Ok(result.locations);
|
return Ok(result.locations);
|
||||||
}
|
}
|
||||||
return NotFound();
|
return NoContent();
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get all locations based on locationdId.
|
/// Get all locations based on locationdId.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
[HttpGet("Locations/{id}")]
|
||||||
public async Task<ActionResult> GetLocationByIdAsync(string id)
|
public async Task<ActionResult> GetLocationByIdAsync(string id)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -52,12 +50,12 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
/// Update a Location.
|
/// Update a Location.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPut("{locations}")]
|
[HttpPut("Locations")]
|
||||||
public async Task<IActionResult> UpdateLocation(Models.Location location)
|
public async Task<IActionResult> UpdateLocation(Models.Location Location)
|
||||||
{
|
{
|
||||||
if (location != null)
|
if (Location != null)
|
||||||
{
|
{
|
||||||
var result = await this.LocationProvider.UpdateLocationAsync(location);
|
var result = await this.LocationProvider.UpdateLocationAsync(Location);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.ErrorMessage);
|
return Ok(result.ErrorMessage);
|
||||||
@ -70,7 +68,7 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
/// Save a new location.
|
/// Save a new location.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPost("{locations}")]
|
[HttpPost("Locations")]
|
||||||
public async Task<IActionResult> CreateLocation(Models.Location Location)
|
public async Task<IActionResult> CreateLocation(Models.Location Location)
|
||||||
{
|
{
|
||||||
if (Location != null)
|
if (Location != null)
|
||||||
@ -80,15 +78,15 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
{
|
{
|
||||||
return Ok(result.Question);
|
return Ok(result.Question);
|
||||||
}
|
}
|
||||||
return NotFound();
|
return BadRequest();
|
||||||
}
|
}
|
||||||
return CreatedAtRoute("DefaultApi", new { id = Location.Id }, Location);
|
return BadRequest();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete an existing location.
|
/// Delete an existing location.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("Locations/{id}")]
|
||||||
public async Task<IActionResult> DeleteLocation(string id)
|
public async Task<IActionResult> DeleteLocation(string id)
|
||||||
{
|
{
|
||||||
var result = await this.LocationProvider.DeleteLocationAsync(id);
|
var result = await this.LocationProvider.DeleteLocationAsync(id);
|
||||||
|
@ -3,8 +3,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
|
|
||||||
namespace DamageAssesment.Api.Locations.Controllers
|
namespace DamageAssesment.Api.Locations.Controllers
|
||||||
{
|
{
|
||||||
//[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
[Route("[controller]")]
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class RegionsController : ControllerBase
|
public class RegionsController : ControllerBase
|
||||||
{
|
{
|
||||||
@ -46,7 +45,7 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
/// POST request for creating a new region.
|
/// POST request for creating a new region.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPost("{region}")]
|
[HttpPost]
|
||||||
public async Task<ActionResult> PostRegionAsync(Models.Region region)
|
public async Task<ActionResult> PostRegionAsync(Models.Region region)
|
||||||
{
|
{
|
||||||
var result = await this.regionProvider.PostRegionAsync(region);
|
var result = await this.regionProvider.PostRegionAsync(region);
|
||||||
@ -60,7 +59,7 @@ namespace DamageAssesment.Api.Locations.Controllers
|
|||||||
/// PUT request for updating an existing region.
|
/// PUT request for updating an existing region.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPut("{region}")]
|
[HttpPut]
|
||||||
public async Task<ActionResult> PutRegionAsync(Models.Region region)
|
public async Task<ActionResult> PutRegionAsync(Models.Region region)
|
||||||
{
|
{
|
||||||
var result = await this.regionProvider.PutRegionAsync(region);
|
var result = await this.regionProvider.PutRegionAsync(region);
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
|
||||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -14,7 +12,6 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
|
||||||
|
|
||||||
# Use the ASP.NET base image
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
|
||||||
WORKDIR /app
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
# Use the SDK image for building
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
# Copy the project file and restore dependencies
|
|
||||||
COPY ["DamageAssesment.Api.Locations/DamageAssesment.Api.Locations.csproj", "DamageAssesment.Api.Locations/"]
|
|
||||||
RUN dotnet restore "DamageAssesment.Api.Locations/DamageAssesment.Api.Locations.csproj"
|
|
||||||
|
|
||||||
# Copy the source code
|
|
||||||
COPY . .
|
|
||||||
WORKDIR "/src/DamageAssesment.Api.Locations"
|
|
||||||
|
|
||||||
# Build the application
|
|
||||||
RUN dotnet build "DamageAssesment.Api.Locations.csproj" -c Release -o /app/build
|
|
||||||
|
|
||||||
# Publish the application
|
|
||||||
FROM build AS publish
|
|
||||||
RUN dotnet publish "DamageAssesment.Api.Locations.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
||||||
|
|
||||||
# Set up the final image
|
|
||||||
FROM base AS final
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the published files
|
|
||||||
COPY --from=publish /app/publish .
|
|
||||||
|
|
||||||
## Set up the volume and copy the XML comments
|
|
||||||
#VOLUME /xmlcomments
|
|
||||||
#COPY ["DamageAssesment.Api.Locations.xml", "/xmlcomments/DamageAssesment.Api.Locations.xml"]
|
|
||||||
|
|
||||||
# Specify the entry point for the container
|
|
||||||
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Locations.dll"]
|
|
@ -31,6 +31,9 @@ var app = builder.Build();
|
|||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI();
|
||||||
|
|
||||||
using (var serviceScope = app.Services.CreateScope())
|
using (var serviceScope = app.Services.CreateScope())
|
||||||
{
|
{
|
||||||
var services = serviceScope.ServiceProvider;
|
var services = serviceScope.ServiceProvider;
|
||||||
@ -39,17 +42,6 @@ if (app.Environment.IsDevelopment())
|
|||||||
locationProvider.SeedData();
|
locationProvider.SeedData();
|
||||||
regionProvider.SeedData();
|
regionProvider.SeedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
app.UseSwagger();
|
|
||||||
app.UseSwaggerUI(options =>
|
|
||||||
{
|
|
||||||
//switch for local environment
|
|
||||||
// options.SwaggerEndpoint("/swagger/v1/swagger.json","");
|
|
||||||
options.SwaggerEndpoint("locations/swagger/v1/swagger.json", "");
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
@ -1,30 +1,4 @@
|
|||||||
{
|
{
|
||||||
"profiles": {
|
|
||||||
"DamageAssesment.Api.Locations": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
},
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"applicationUrl": "http://localhost:5213"
|
|
||||||
},
|
|
||||||
"IIS Express": {
|
|
||||||
"commandName": "IISExpress",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Docker": {
|
|
||||||
"commandName": "Docker",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
|
||||||
"publishAllPorts": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
"iisSettings": {
|
"iisSettings": {
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
@ -33,5 +7,25 @@
|
|||||||
"applicationUrl": "http://localhost:20458",
|
"applicationUrl": "http://localhost:20458",
|
||||||
"sslPort": 0
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"DamageAssesment.Api.Locations": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "http://localhost:5213",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace DamageAssesment.Api.Locations.Providers
|
|||||||
this.locationDbContext = regionDbContext;
|
this.locationDbContext = regionDbContext;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
// SeedData();
|
//SeedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> GetRegionByIdAsync(string Id)
|
public async Task<(bool IsSuccess, Models.Region Region, string ErrorMessage)> GetRegionByIdAsync(string Id)
|
||||||
|
@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
|
|
||||||
namespace DamageAssesment.Api.Questions.Controllers
|
namespace DamageAssesment.Api.Questions.Controllers
|
||||||
{
|
{
|
||||||
//[Route("api")]
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class QuestionsController : ControllerBase
|
public class QuestionsController : ControllerBase
|
||||||
{
|
{
|
||||||
@ -17,16 +16,16 @@ namespace DamageAssesment.Api.Questions.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// GET request for retrieving questions, e.g api/fr/Questions (default returns all language).
|
/// GET request for retrieving questions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
// get all questions
|
// get all questions
|
||||||
[Route("{Language}/Questions")]
|
|
||||||
[Route("Questions")]
|
[Route("Questions")]
|
||||||
|
[Route("Questions/{language:alpha}")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> GetQuestionsAsync(string? Language)
|
public async Task<IActionResult> GetQuestionsAsync(string? language)
|
||||||
{
|
{
|
||||||
var result = await this.questionsProvider.GetQuestionsAsync(Language);
|
var result = await this.questionsProvider.GetQuestionsAsync(language);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.Questions);
|
return Ok(result.Questions);
|
||||||
@ -38,12 +37,12 @@ namespace DamageAssesment.Api.Questions.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// GET request for retrieving a question by ID.
|
/// GET request for retrieving a question by ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("{Language}/Questions/{id}")]
|
[Route("Questions/{id}/{language:alpha}")]
|
||||||
[Route("Questions/{id}")]
|
[Route("Questions/{id:int}")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> GetQuestionAsync(int id, string? Language)
|
public async Task<IActionResult> GetQuestionByIdAsync(string? language,int id)
|
||||||
{
|
{
|
||||||
var result = await this.questionsProvider.GetQuestionAsync(id,Language);
|
var result = await this.questionsProvider.GetQuestionAsync(id, language);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.Question);
|
return Ok(result.Question);
|
||||||
@ -56,12 +55,12 @@ namespace DamageAssesment.Api.Questions.Controllers
|
|||||||
/// GET request for retrieving survey questions based on a survey ID.
|
/// GET request for retrieving survey questions based on a survey ID.
|
||||||
/// Uri: {Optional language}/GetSurveyQuestions/{surveyId} :Default returns question in all languages
|
/// Uri: {Optional language}/GetSurveyQuestions/{surveyId} :Default returns question in all languages
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("{Language}/GetSurveyQuestions/{surveyId}")]
|
[Route("Questions/BySurvey/{surveyId:int}")]
|
||||||
[Route("GetSurveyQuestions/{surveyId}")]
|
[Route("Questions/BySurvey/{surveyId:int}/{language:alpha}")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> GetSurveyQuestions(int surveyId,string? Language)
|
public async Task<IActionResult> GetSurveyQuestions(int surveyId,string? language)
|
||||||
{
|
{
|
||||||
var result = await this.questionsProvider.GetSurveyQuestionAsync(surveyId, Language);
|
var result = await this.questionsProvider.GetSurveyQuestionAsync(surveyId, language);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.SurveyQuestions);
|
return Ok(result.SurveyQuestions);
|
||||||
@ -126,10 +125,11 @@ namespace DamageAssesment.Api.Questions.Controllers
|
|||||||
/// GET request for retrieving question categories.
|
/// GET request for retrieving question categories.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpGet("QuestionCategories")]
|
[HttpGet("Questions/Categories")]
|
||||||
public async Task<IActionResult> GetQuestionCategoriesAsync()
|
[HttpGet("Questions/Categories/{language:alpha}")]
|
||||||
|
public async Task<IActionResult> GetQuestionCategoriesAsync(string? language)
|
||||||
{
|
{
|
||||||
var result = await this.questionsProvider.GetQuestionCategoriesAsync();
|
var result = await this.questionsProvider.GetQuestionCategoriesAsync(language);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.QuestionCategories);
|
return Ok(result.QuestionCategories);
|
||||||
@ -140,10 +140,11 @@ namespace DamageAssesment.Api.Questions.Controllers
|
|||||||
/// GET request for retrieving a question category by ID.
|
/// GET request for retrieving a question category by ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpGet("QuestionCategories/{id}")]
|
[HttpGet("Questions/Categories/{id:int}")]
|
||||||
public async Task<IActionResult> GetQuestionCategoryAsync(int id)
|
[HttpGet("Questions/Categories/{id:int}/{language:alpha}")]
|
||||||
|
public async Task<IActionResult> GetQuestionCategoryAsync(int id,string? language)
|
||||||
{
|
{
|
||||||
var result = await this.questionsProvider.GetQuestionCategoryAsync(id);
|
var result = await this.questionsProvider.GetQuestionCategoryAsync(id, language);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.QuestionCategory);
|
return Ok(result.QuestionCategory);
|
||||||
@ -156,7 +157,7 @@ namespace DamageAssesment.Api.Questions.Controllers
|
|||||||
/// PUT request for updating a question category.
|
/// PUT request for updating a question category.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPut("QuestionCategories")]
|
[HttpPut("Questions/Categories")]
|
||||||
public async Task<IActionResult> UpdateQuestionCategory(Models.QuestionCategory questionCategory)
|
public async Task<IActionResult> UpdateQuestionCategory(Models.QuestionCategory questionCategory)
|
||||||
{
|
{
|
||||||
if (questionCategory != null)
|
if (questionCategory != null)
|
||||||
@ -177,7 +178,7 @@ namespace DamageAssesment.Api.Questions.Controllers
|
|||||||
/// POST request for creating a new question category.
|
/// POST request for creating a new question category.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpPost("QuestionCategories")]
|
[HttpPost("Questions/Categories")]
|
||||||
public async Task<IActionResult> CreateQuestionCategory(Models.QuestionCategory questionCategory)
|
public async Task<IActionResult> CreateQuestionCategory(Models.QuestionCategory questionCategory)
|
||||||
{
|
{
|
||||||
if (questionCategory != null)
|
if (questionCategory != null)
|
||||||
@ -195,7 +196,7 @@ namespace DamageAssesment.Api.Questions.Controllers
|
|||||||
/// DELETE request for deleting a question category based on ID.
|
/// DELETE request for deleting a question category based on ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpDelete("QuestionCategories/{id}")]
|
[HttpDelete("Questions/Categories/{id}")]
|
||||||
public async Task<IActionResult> DeleteQuestionCategory(int id)
|
public async Task<IActionResult> DeleteQuestionCategory(int id)
|
||||||
{
|
{
|
||||||
var result = await this.questionsProvider.DeleteQuestionCategoryAsync(id);
|
var result = await this.questionsProvider.DeleteQuestionCategoryAsync(id);
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
|
||||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -14,7 +12,6 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace DamageAssesment.Api.Questions.Db
|
||||||
|
{
|
||||||
|
public class CategoryTranslation
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[ForeignKey("QuestionCategory")]
|
||||||
|
public int CategoryId { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public string Language { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -7,8 +7,8 @@ namespace DamageAssesment.Api.Questions.Db
|
|||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string CategoryName { get; set; }
|
public string IconName { get; set; }
|
||||||
public string CategoryImage { get; set; }
|
public string IconLibrary { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ namespace DamageAssesment.Api.Questions.Db
|
|||||||
public DbSet<Db.QuestionType> QuestionTypes { get; set; }
|
public DbSet<Db.QuestionType> QuestionTypes { get; set; }
|
||||||
public DbSet<Db.QuestionsTranslation> QuestionsTranslations { get; set; }
|
public DbSet<Db.QuestionsTranslation> QuestionsTranslations { get; set; }
|
||||||
public DbSet<Db.QuestionCategory> QuestionCategories { get; set; }
|
public DbSet<Db.QuestionCategory> QuestionCategories { get; set; }
|
||||||
|
public DbSet<Db.CategoryTranslation> CategoryTranslations { get; set; }
|
||||||
public QuestionDbContext(DbContextOptions options) : base(options)
|
public QuestionDbContext(DbContextOptions options) : base(options)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -29,6 +30,9 @@ namespace DamageAssesment.Api.Questions.Db
|
|||||||
modelBuilder.Entity<QuestionCategory>()
|
modelBuilder.Entity<QuestionCategory>()
|
||||||
.Property(item => item.Id)
|
.Property(item => item.Id)
|
||||||
.ValueGeneratedOnAdd();
|
.ValueGeneratedOnAdd();
|
||||||
|
modelBuilder.Entity<CategoryTranslation>()
|
||||||
|
.Property(item => item.Id)
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
|
||||||
# Use the ASP.NET base image
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
|
||||||
WORKDIR /app
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
# Use the SDK image for building
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
# Copy the project file and restore dependencies
|
|
||||||
COPY ["DamageAssesment.Api.Questions/DamageAssesment.Api.Questions.csproj", "DamageAssesment.Api.Questions/"]
|
|
||||||
RUN dotnet restore "DamageAssesment.Api.Questions/DamageAssesment.Api.Questions.csproj"
|
|
||||||
|
|
||||||
# Copy the source code
|
|
||||||
COPY . .
|
|
||||||
WORKDIR "/src/DamageAssesment.Api.Questions"
|
|
||||||
|
|
||||||
# Build the application
|
|
||||||
RUN dotnet build "DamageAssesment.Api.Questions.csproj" -c Release -o /app/build
|
|
||||||
|
|
||||||
# Publish the application
|
|
||||||
FROM build AS publish
|
|
||||||
RUN dotnet publish "DamageAssesment.Api.Questions.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
||||||
|
|
||||||
# Set up the final image
|
|
||||||
FROM base AS final
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the published files
|
|
||||||
COPY --from=publish /app/publish .
|
|
||||||
|
|
||||||
## Set up the volume and copy the XML comments
|
|
||||||
#VOLUME /xmlcomments
|
|
||||||
#COPY ["DamageAssesment.Api.Questions.xml", "/xmlcomments/DamageAssesment.Api.Questions.xml"]
|
|
||||||
|
|
||||||
# Specify the entry point for the container
|
|
||||||
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Questions.dll"]
|
|
@ -4,6 +4,5 @@
|
|||||||
{
|
{
|
||||||
Task<(bool IsSuccess, Db.QuestionType QuestionType, string ErrorMessage)> GetQuestionTypeAsync(int Id);
|
Task<(bool IsSuccess, Db.QuestionType QuestionType, string ErrorMessage)> GetQuestionTypeAsync(int Id);
|
||||||
Task<(bool IsSuccess, IEnumerable<Db.QuestionType> QuestionTypes, string ErrorMessage)> GetQuestionTypesAsync();
|
Task<(bool IsSuccess, IEnumerable<Db.QuestionType> QuestionTypes, string ErrorMessage)> GetQuestionTypesAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,19 @@ namespace DamageAssesment.Api.Questions.Interfaces
|
|||||||
{
|
{
|
||||||
public interface IQuestionsProvider : IQuestionTypesProvider
|
public interface IQuestionsProvider : IQuestionTypesProvider
|
||||||
{
|
{
|
||||||
Task<(bool IsSuccess, Models.Question Question, string ErrorMessage)> GetQuestionAsync(int Id, string Language);
|
Task<(bool IsSuccess, Models.MultiLanQuestion Question, string ErrorMessage)> GetQuestionAsync(int id, string language);
|
||||||
Task<(bool IsSuccess, IEnumerable<Models.Question> Questions, string ErrorMessage)> GetQuestionsAsync(string Language);
|
Task<(bool IsSuccess, IEnumerable<Models.MultiLanQuestion> Questions, string ErrorMessage)> GetQuestionsAsync(string language);
|
||||||
Task<(bool IsSuccess, List<SurveyQuestions> SurveyQuestions, string ErrorMessage)> GetSurveyQuestionAsync(int surveyId,string Language);
|
Task<(bool IsSuccess, List<SurveyQuestions> SurveyQuestions, string ErrorMessage)> GetSurveyQuestionAsync(int surveyId,string language);
|
||||||
Task<(bool IsSuccess, Models.Question Question, string ErrorMessage)> PostQuestionAsync(Models.Question Question);
|
Task<(bool IsSuccess, Models.MultiLanQuestion Question, string ErrorMessage)> PostQuestionAsync(Models.Question Question);
|
||||||
Task<(bool IsSuccess, Models.Question Question, string ErrorMessage)> UpdateQuestionAsync(Models.Question Question);
|
Task<(bool IsSuccess, Models.MultiLanQuestion Question, string ErrorMessage)> UpdateQuestionAsync(Models.Question Question);
|
||||||
Task<(bool IsSuccess, Models.Question Question, string ErrorMessage)> DeleteQuestionAsync(int Id);
|
Task<(bool IsSuccess, Models.MultiLanQuestion Question, string ErrorMessage)> DeleteQuestionAsync(int id);
|
||||||
|
|
||||||
|
|
||||||
Task<(bool IsSuccess, IEnumerable<Models.QuestionCategory> QuestionCategories, string ErrorMessage)> GetQuestionCategoriesAsync();
|
Task<(bool IsSuccess, IEnumerable<Models.MultiLanQuestionCategory> QuestionCategories, string ErrorMessage)> GetQuestionCategoriesAsync(string? language);
|
||||||
Task<(bool IsSuccess, Models.QuestionCategory QuestionCategory, string ErrorMessage)> GetQuestionCategoryAsync(int Id);
|
Task<(bool IsSuccess, Models.MultiLanQuestionCategory QuestionCategory, string ErrorMessage)> GetQuestionCategoryAsync(int id, string? language);
|
||||||
Task<(bool IsSuccess, Models.QuestionCategory QuestionCategory, string ErrorMessage)> PostQuestionCategoryAsync(Models.QuestionCategory QuestionCategory);
|
Task<(bool IsSuccess, Models.MultiLanQuestionCategory QuestionCategory, string ErrorMessage)> PostQuestionCategoryAsync(Models.QuestionCategory QuestionCategory);
|
||||||
Task<(bool IsSuccess, Models.QuestionCategory QuestionCategory, string ErrorMessage)> UpdateQuestionCategoryAsync(Models.QuestionCategory QuestionCategory);
|
Task<(bool IsSuccess, Models.MultiLanQuestionCategory QuestionCategory, string ErrorMessage)> UpdateQuestionCategoryAsync(Models.QuestionCategory QuestionCategory);
|
||||||
Task<(bool IsSuccess, Models.QuestionCategory QuestionCategory, string ErrorMessage)> DeleteQuestionCategoryAsync(int Id);
|
Task<(bool IsSuccess, Models.MultiLanQuestionCategory QuestionCategory, string ErrorMessage)> DeleteQuestionCategoryAsync(int id);
|
||||||
void SeedData();
|
void SeedData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
namespace DamageAssesment.Api.Questions.Models
|
||||||
|
{
|
||||||
|
public class CategoryTranslation
|
||||||
|
{
|
||||||
|
public string Title { get; set; }
|
||||||
|
public string Language { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -2,11 +2,17 @@
|
|||||||
|
|
||||||
namespace DamageAssesment.Api.Questions.Models
|
namespace DamageAssesment.Api.Questions.Models
|
||||||
{
|
{
|
||||||
public class Question
|
public class MultiLanQuestion: BaseQuestion
|
||||||
|
{
|
||||||
|
public MultiLanguage Questions { get; set; }
|
||||||
|
}
|
||||||
|
public class Question: BaseQuestion
|
||||||
|
{
|
||||||
|
public List<QuestionsTranslation> Questions { get; set; }
|
||||||
|
}
|
||||||
|
public class BaseQuestion
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public List<QuestionsTranslation> Questions { get; set; }
|
|
||||||
|
|
||||||
//public int QuestionTypeID { get; set; }
|
//public int QuestionTypeID { get; set; }
|
||||||
|
|
||||||
public string TypeText { get; set; } = string.Empty;
|
public string TypeText { get; set; } = string.Empty;
|
||||||
|
@ -1,9 +1,17 @@
|
|||||||
namespace DamageAssesment.Api.Questions.Models
|
namespace DamageAssesment.Api.Questions.Models
|
||||||
{
|
{
|
||||||
public class QuestionCategory
|
public class MultiLanQuestionCategory : BaseQuestionCategory
|
||||||
|
{
|
||||||
|
public object Titles { get; set; }
|
||||||
|
}
|
||||||
|
public class QuestionCategory : BaseQuestionCategory
|
||||||
|
{
|
||||||
|
public List<CategoryTranslation> Categories { get; set; }
|
||||||
|
}
|
||||||
|
public class BaseQuestionCategory
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string CategoryName { get; set; }
|
public string IconName { get; set; }
|
||||||
public string CategoryImage { get; set; }
|
public string IconLibrary { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,4 +5,8 @@
|
|||||||
public string QuestionText { get; set; }
|
public string QuestionText { get; set; }
|
||||||
public string Language { get; set; } = "En";
|
public string Language { get; set; } = "En";
|
||||||
}
|
}
|
||||||
|
public class MultiLanguage
|
||||||
|
{
|
||||||
|
public object questionText { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
public class SurveyQuestions
|
public class SurveyQuestions
|
||||||
{
|
{
|
||||||
public int CategoryId { get; set; }
|
public int CategoryId { get; set; }
|
||||||
public string CategoryName { get; set; }
|
public string IconName { get; set; }
|
||||||
public string CategoryImage { get; set; }
|
public string IconLibrary { get; set; }
|
||||||
public List<Question> Questions { get; set; }
|
public List<MultiLanQuestion> Questions { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,15 @@ namespace DamageAssesment.Api.Questions.Profiles
|
|||||||
{
|
{
|
||||||
CreateMap<Db.Question, Models.Question>().ForMember(dest => dest.TypeText,
|
CreateMap<Db.Question, Models.Question>().ForMember(dest => dest.TypeText,
|
||||||
opt => opt.MapFrom(src => src.QuestionType.TypeText));
|
opt => opt.MapFrom(src => src.QuestionType.TypeText));
|
||||||
|
CreateMap<Db.Question, Models.MultiLanQuestion>().ForMember(dest => dest.TypeText,
|
||||||
|
opt => opt.MapFrom(src => src.QuestionType.TypeText));
|
||||||
CreateMap<Models.QuestionCategory, Db.QuestionCategory>();
|
CreateMap<Models.QuestionCategory, Db.QuestionCategory>();
|
||||||
CreateMap<Db.QuestionCategory, Models.QuestionCategory>();
|
CreateMap<Db.QuestionCategory, Models.MultiLanQuestionCategory>();
|
||||||
CreateMap<Models.Question, Db.Question>();
|
CreateMap<Models.Question, Db.Question>();
|
||||||
CreateMap<Db.QuestionsTranslation, Models.QuestionsTranslation>();
|
CreateMap<Db.QuestionsTranslation, Models.QuestionsTranslation>();
|
||||||
CreateMap<Models.QuestionsTranslation, Db.QuestionsTranslation>();
|
CreateMap<Models.QuestionsTranslation, Db.QuestionsTranslation>();
|
||||||
|
CreateMap<Db.CategoryTranslation, Models.CategoryTranslation>();
|
||||||
|
CreateMap<Models.CategoryTranslation, Db.CategoryTranslation>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,20 +35,15 @@ var app = builder.Build();
|
|||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI();
|
||||||
|
|
||||||
using (var serviceScope = app.Services.CreateScope())
|
using (var serviceScope = app.Services.CreateScope())
|
||||||
{
|
{
|
||||||
var services = serviceScope.ServiceProvider;
|
var services = serviceScope.ServiceProvider;
|
||||||
var questionProvider = services.GetRequiredService<IQuestionsProvider>();
|
var questionProvider = services.GetRequiredService<IQuestionsProvider>();
|
||||||
questionProvider.SeedData();
|
questionProvider.SeedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseSwagger();
|
|
||||||
app.UseSwaggerUI(options => {
|
|
||||||
//switch for local environment
|
|
||||||
// options.SwaggerEndpoint("/swagger/v1/swagger.json", "");
|
|
||||||
options.SwaggerEndpoint("/questions/swagger/v1/swagger.json", "");
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
@ -1,30 +1,4 @@
|
|||||||
{
|
{
|
||||||
"profiles": {
|
|
||||||
"DamageAssesment.Api.Questions": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
},
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"applicationUrl": "http://localhost:5133"
|
|
||||||
},
|
|
||||||
"IIS Express": {
|
|
||||||
"commandName": "IISExpress",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Docker": {
|
|
||||||
"commandName": "Docker",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
|
||||||
"publishAllPorts": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
"iisSettings": {
|
"iisSettings": {
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
@ -33,5 +7,25 @@
|
|||||||
"applicationUrl": "http://localhost:60754",
|
"applicationUrl": "http://localhost:60754",
|
||||||
"sslPort": 0
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"DamageAssesment.Api.Questions": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "http://localhost:5133",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ using DamageAssesment.Api.Questions.Models;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace DamageAssesment.Api.Questions.Providers
|
namespace DamageAssesment.Api.Questions.Providers
|
||||||
{
|
{
|
||||||
@ -21,7 +23,7 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
this.questionDbContext = questionDbContext;
|
this.questionDbContext = questionDbContext;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
// SeedData();
|
SeedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SeedData()
|
public void SeedData()
|
||||||
@ -57,16 +59,89 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
|
|
||||||
if (!questionDbContext.QuestionCategories.Any())
|
if (!questionDbContext.QuestionCategories.Any())
|
||||||
{
|
{
|
||||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 1, CategoryName = "Flooding", CategoryImage= "https://example.com/images/img1.png" });
|
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 1, IconName = "Flooding", IconLibrary= "https://example.com/images/img1.png" });
|
||||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 2, CategoryName = "Electrical", CategoryImage = "https://example.com/images/img2.png" });
|
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 2, IconName = "Electrical", IconLibrary = "https://example.com/images/img2.png" });
|
||||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 3, CategoryName = "Structural", CategoryImage = "https://example.com/images/img3.png" });
|
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 3, IconName = "Structural", IconLibrary = "https://example.com/images/img3.png" });
|
||||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 4, CategoryName = "Utility", CategoryImage = "https://example.com/images/img4.png" });
|
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 4, IconName = "Utility", IconLibrary = "https://example.com/images/img4.png" });
|
||||||
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 5, CategoryName = "Debris", CategoryImage = "https://example.com/images/img5.png" });
|
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { Id = 5, IconName = "Debris", IconLibrary = "https://example.com/images/img5.png" });
|
||||||
|
questionDbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!questionDbContext.CategoryTranslations.Any())
|
||||||
|
{
|
||||||
|
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 1, CategoryId = 1, Title = "Flooding", Language = "en" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 2, CategoryId = 2, Title = "Electrical", Language = "en" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 3, CategoryId = 3, Title = "Structural", Language = "en" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 4, CategoryId = 4, Title = "Utility", Language = "en" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 5, CategoryId = 5, Title = "Debris", Language = "en" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 6, CategoryId = 1, Title = "Inondation", Language = "fr" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 7, CategoryId = 2, Title = "Électrique", Language = "fr" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 8, CategoryId = 3, Title = "De construction", Language = "fr" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 9, CategoryId = 4, Title = "Utilitaire", Language = "fr" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 10, CategoryId = 5, Title = "Débris", Language = "fr" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 11, CategoryId = 1, Title = "Inundación", Language = "es" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 12, CategoryId = 2, Title = "Eléctrica", Language = "es" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 13, CategoryId = 3, Title = "Estructural", Language = "es" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 14, CategoryId = 4, Title = "Utilidad", Language = "es" });
|
||||||
|
questionDbContext.CategoryTranslations.Add(new Db.CategoryTranslation() { Id = 15, CategoryId = 5, Title = "Escombros", Language = "es" });
|
||||||
questionDbContext.SaveChanges();
|
questionDbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, IEnumerable<Models.Question> Questions, string ErrorMessage)> GetQuestionsAsync(string Language)
|
public List<Models.CategoryTranslation> GetCategoryTranslations(int id, string? language)
|
||||||
|
{
|
||||||
|
List<Models.CategoryTranslation> categoryTranslations = new List<Models.CategoryTranslation>();
|
||||||
|
if (string.IsNullOrEmpty(language))
|
||||||
|
{
|
||||||
|
categoryTranslations = mapper.Map<List<Db.CategoryTranslation>, List<Models.CategoryTranslation>>(
|
||||||
|
questionDbContext.CategoryTranslations.AsNoTracking().Where(a => a.CategoryId == id).ToList());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
categoryTranslations = mapper.Map<List<Db.CategoryTranslation>, List<Models.CategoryTranslation>>(
|
||||||
|
questionDbContext.CategoryTranslations.AsNoTracking().Where(a => a.CategoryId == id && a.Language == language).ToList());
|
||||||
|
}
|
||||||
|
return categoryTranslations;
|
||||||
|
}
|
||||||
|
public object CreateCategoryMultiLanguageObject(List<Models.CategoryTranslation> categoryTranslations)
|
||||||
|
{
|
||||||
|
object MultiLanguage = new object();
|
||||||
|
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||||||
|
foreach (Models.CategoryTranslation item in categoryTranslations)
|
||||||
|
{
|
||||||
|
dict.Add(item.Language, item.Title);
|
||||||
|
}
|
||||||
|
MultiLanguage = dict;
|
||||||
|
return MultiLanguage;
|
||||||
|
}
|
||||||
|
public List<Models.QuestionsTranslation> GetQuestionsTranslations(int id, string? language)
|
||||||
|
{
|
||||||
|
List<Models.QuestionsTranslation> QuestionTranslations;
|
||||||
|
if (string.IsNullOrEmpty(language))
|
||||||
|
{
|
||||||
|
QuestionTranslations = mapper.Map<List<Db.QuestionsTranslation>, List<Models.QuestionsTranslation>>(
|
||||||
|
questionDbContext.QuestionsTranslations.AsNoTracking().Where(a => a.QuestionId == id).ToList());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QuestionTranslations = mapper.Map<List<Db.QuestionsTranslation>, List<Models.QuestionsTranslation>>(
|
||||||
|
questionDbContext.QuestionsTranslations.AsNoTracking().Where(a => a.QuestionId == id && a.Language == language).ToList());
|
||||||
|
}
|
||||||
|
return QuestionTranslations;
|
||||||
|
}
|
||||||
|
public MultiLanguage CreateMultiLanguageObject(List<Models.QuestionsTranslation> questions)
|
||||||
|
{
|
||||||
|
MultiLanguage MultiLanguage = new MultiLanguage();
|
||||||
|
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||||||
|
foreach (Models.QuestionsTranslation item in questions)
|
||||||
|
{
|
||||||
|
dict.Add(item.Language, item.QuestionText);
|
||||||
|
}
|
||||||
|
MultiLanguage.questionText = dict;
|
||||||
|
return MultiLanguage;
|
||||||
|
}
|
||||||
|
public async Task<(bool IsSuccess, IEnumerable<Models.MultiLanQuestion> Questions, string ErrorMessage)> GetQuestionsAsync(string language)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -76,21 +151,10 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
{
|
{
|
||||||
|
|
||||||
//logger?.LogInformation($"{question} customer(s) found");
|
//logger?.LogInformation($"{question} customer(s) found");
|
||||||
var result = mapper.Map<IEnumerable<Db.Question>, IEnumerable<Models.Question>>(questions);
|
var result = mapper.Map<IEnumerable<Db.Question>, IEnumerable<Models.MultiLanQuestion>>(questions);
|
||||||
|
|
||||||
|
|
||||||
foreach (var question in result)
|
foreach (var question in result)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(Language))
|
question.Questions = CreateMultiLanguageObject(GetQuestionsTranslations(question.Id, language));
|
||||||
{
|
|
||||||
question.Questions = mapper.Map<List<Db.QuestionsTranslation>, List<Models.QuestionsTranslation>>(
|
|
||||||
questionDbContext.QuestionsTranslations.Where(a => a.QuestionId == question.Id).ToList());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
question.Questions = mapper.Map<List<Db.QuestionsTranslation>, List<Models.QuestionsTranslation>>(
|
|
||||||
questionDbContext.QuestionsTranslations.Where(a => a.QuestionId == question.Id && a.Language == Language).ToList());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return (true, result, null);
|
return (true, result, null);
|
||||||
}
|
}
|
||||||
@ -102,27 +166,17 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
return (false, null, ex.Message);
|
return (false, null, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess, Models.Question Question, string ErrorMessage)> GetQuestionAsync(int Id, string Language)
|
public async Task<(bool IsSuccess, Models.MultiLanQuestion Question, string ErrorMessage)> GetQuestionAsync(int id, string language)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger?.LogInformation("Query Question");
|
logger?.LogInformation("Query Question");
|
||||||
var question = await questionDbContext.Questions.Include("QuestionType").AsNoTracking().FirstOrDefaultAsync(q => q.Id == Id);
|
var question = await questionDbContext.Questions.Include("QuestionType").AsNoTracking().FirstOrDefaultAsync(q => q.Id == id);
|
||||||
if (question != null)
|
if (question != null)
|
||||||
{
|
{
|
||||||
logger?.LogInformation($"{question} customer(s) found");
|
logger?.LogInformation($"{question} customer(s) found");
|
||||||
var result = mapper.Map<Db.Question, Models.Question>(question);
|
var result = mapper.Map<Db.Question, Models.MultiLanQuestion>(question);
|
||||||
|
result.Questions = CreateMultiLanguageObject(GetQuestionsTranslations(id, language));
|
||||||
if (string.IsNullOrEmpty(Language))
|
|
||||||
{
|
|
||||||
result.Questions = mapper.Map<List<Db.QuestionsTranslation>, List<Models.QuestionsTranslation>>(
|
|
||||||
questionDbContext.QuestionsTranslations.Where(a => a.QuestionId == result.Id).ToList());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result.Questions = mapper.Map<List<Db.QuestionsTranslation>, List<Models.QuestionsTranslation>>(
|
|
||||||
questionDbContext.QuestionsTranslations.Where(a => a.QuestionId == result.Id && a.Language == Language).ToList());
|
|
||||||
}
|
|
||||||
return (true, result, null);
|
return (true, result, null);
|
||||||
}
|
}
|
||||||
return (false, null, "Not found");
|
return (false, null, "Not found");
|
||||||
@ -133,27 +187,15 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
return (false, null, ex.Message);
|
return (false, null, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public List<Models.Question> GetSurveyQuestion(List<Models.Question> questions, string Language)
|
public List<Models.MultiLanQuestion> GetSurveyQuestion(List<Models.MultiLanQuestion> questions, string language)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(Language))
|
foreach (var item in questions)
|
||||||
{
|
{
|
||||||
foreach (var item in questions)
|
item.Questions = CreateMultiLanguageObject(GetQuestionsTranslations(item.Id, language));
|
||||||
{
|
|
||||||
item.Questions = mapper.Map<List<Db.QuestionsTranslation>, List<Models.QuestionsTranslation>>(
|
|
||||||
questionDbContext.QuestionsTranslations.Where(a => a.QuestionId == item.Id).ToList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (var item in questions)
|
|
||||||
{
|
|
||||||
item.Questions = mapper.Map<List<Db.QuestionsTranslation>, List<Models.QuestionsTranslation>>(
|
|
||||||
questionDbContext.QuestionsTranslations.Where(a => a.QuestionId == item.Id && a.Language == Language).ToList());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return questions;
|
return questions;
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess, List<SurveyQuestions> SurveyQuestions, string ErrorMessage)> GetSurveyQuestionAsync(int SurveyId, string Language)
|
public async Task<(bool IsSuccess, List<SurveyQuestions> SurveyQuestions, string ErrorMessage)> GetSurveyQuestionAsync(int SurveyId, string language)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -170,9 +212,9 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
surveyQuestionsList.Add(new SurveyQuestions()
|
surveyQuestionsList.Add(new SurveyQuestions()
|
||||||
{
|
{
|
||||||
CategoryId = item.Id,
|
CategoryId = item.Id,
|
||||||
CategoryImage = item.CategoryImage,
|
IconLibrary = item.IconLibrary,
|
||||||
CategoryName = item.CategoryName,
|
IconName = item.IconName,
|
||||||
Questions = GetSurveyQuestion(mapper.Map<List<Db.Question>, List<Models.Question>>(questions.Where(a => a.CategoryId == item.Id).ToList()), Language)
|
Questions = GetSurveyQuestion(mapper.Map<List<Db.Question>, List<Models.MultiLanQuestion>>(questions.Where(a => a.CategoryId == item.Id).ToList()), language)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +229,7 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
return (false, null, ex.Message);
|
return (false, null, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess, Models.Question Question, string ErrorMessage)> PostQuestionAsync(Models.Question Question)
|
public async Task<(bool IsSuccess, Models.MultiLanQuestion Question, string ErrorMessage)> PostQuestionAsync(Models.Question Question)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -200,7 +242,9 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
questionDbContext.QuestionsTranslations.AddRange(dbquestiontranslation);
|
questionDbContext.QuestionsTranslations.AddRange(dbquestiontranslation);
|
||||||
questionDbContext.SaveChanges();
|
questionDbContext.SaveChanges();
|
||||||
Question.Id = dbquestion.Id;
|
Question.Id = dbquestion.Id;
|
||||||
return (true, Question, null);
|
var result = mapper.Map<Db.Question, Models.MultiLanQuestion>(dbquestion);
|
||||||
|
result.Questions = CreateMultiLanguageObject(GetQuestionsTranslations(result.Id,""));
|
||||||
|
return (true, result, null);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -208,7 +252,7 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
return (false, null, ex.Message);
|
return (false, null, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess, Models.Question Question, string ErrorMessage)> UpdateQuestionAsync(Models.Question Question)
|
public async Task<(bool IsSuccess, Models.MultiLanQuestion Question, string ErrorMessage)> UpdateQuestionAsync(Models.Question Question)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -222,7 +266,9 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
dbquestiontranslation.ForEach(i => i.QuestionId = dbquestion.Id);
|
dbquestiontranslation.ForEach(i => i.QuestionId = dbquestion.Id);
|
||||||
questionDbContext.QuestionsTranslations.AddRange(dbquestiontranslation);
|
questionDbContext.QuestionsTranslations.AddRange(dbquestiontranslation);
|
||||||
questionDbContext.SaveChanges();
|
questionDbContext.SaveChanges();
|
||||||
return (true, Question, null);
|
var result = mapper.Map<Db.Question, Models.MultiLanQuestion>(dbquestion);
|
||||||
|
result.Questions = CreateMultiLanguageObject(GetQuestionsTranslations(result.Id, ""));
|
||||||
|
return (true, result, null);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -231,21 +277,23 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
return (false, null, ex.Message);
|
return (false, null, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess, Models.Question Question, string ErrorMessage)> DeleteQuestionAsync(int Id)
|
public async Task<(bool IsSuccess, Models.MultiLanQuestion Question, string ErrorMessage)> DeleteQuestionAsync(int id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var question = await questionDbContext.Questions.Where(x => x.Id == Id).FirstOrDefaultAsync();
|
var question = await questionDbContext.Questions.Where(x => x.Id == id).FirstOrDefaultAsync();
|
||||||
|
|
||||||
if (question != null)
|
if (question != null)
|
||||||
{
|
{
|
||||||
|
var result = mapper.Map<Db.Question, Models.MultiLanQuestion>(question);
|
||||||
|
result.Questions = CreateMultiLanguageObject(GetQuestionsTranslations(result.Id, ""));
|
||||||
questionDbContext.Questions.Remove(question);
|
questionDbContext.Questions.Remove(question);
|
||||||
questionDbContext.SaveChanges();
|
questionDbContext.SaveChanges();
|
||||||
return (true, mapper.Map<Db.Question, Models.Question>(question), $"QuestionID {Id} deleted Successfuly");
|
return (true, result, $"QuestionID {id} deleted Successfuly");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger?.LogInformation($"QuestionID: {Id} Not found");
|
logger?.LogInformation($"QuestionID: {id} Not found");
|
||||||
return (false, null, "Not Found");
|
return (false, null, "Not Found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,7 +306,7 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
|
|
||||||
//Question Category Logic
|
//Question Category Logic
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, IEnumerable<Models.QuestionCategory> QuestionCategories, string ErrorMessage)> GetQuestionCategoriesAsync()
|
public async Task<(bool IsSuccess, IEnumerable<Models.MultiLanQuestionCategory> QuestionCategories, string ErrorMessage)> GetQuestionCategoriesAsync(string? language)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -267,7 +315,11 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
if (questionCategories != null)
|
if (questionCategories != null)
|
||||||
{
|
{
|
||||||
//logger?.LogInformation($"{question} customer(s) found");
|
//logger?.LogInformation($"{question} customer(s) found");
|
||||||
var result = mapper.Map<IEnumerable<Db.QuestionCategory>, IEnumerable<Models.QuestionCategory>>(questionCategories);
|
var result = mapper.Map<IEnumerable<Db.QuestionCategory>, IEnumerable<Models.MultiLanQuestionCategory>>(questionCategories);
|
||||||
|
foreach (var category in result)
|
||||||
|
{
|
||||||
|
category.Titles = CreateCategoryMultiLanguageObject(GetCategoryTranslations(category.Id, language));
|
||||||
|
}
|
||||||
return (true, result, null);
|
return (true, result, null);
|
||||||
}
|
}
|
||||||
return (false, null, "Not found");
|
return (false, null, "Not found");
|
||||||
@ -278,16 +330,17 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
return (false, null, ex.Message);
|
return (false, null, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess, Models.QuestionCategory QuestionCategory, string ErrorMessage)> GetQuestionCategoryAsync(int Id)
|
public async Task<(bool IsSuccess, Models.MultiLanQuestionCategory QuestionCategory, string ErrorMessage)> GetQuestionCategoryAsync(int id, string? language)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger?.LogInformation("Query Question");
|
logger?.LogInformation("Query Question");
|
||||||
var questioncategory = await questionDbContext.QuestionCategories.AsNoTracking().FirstOrDefaultAsync(q => q.Id == Id);
|
var questioncategory = await questionDbContext.QuestionCategories.AsNoTracking().FirstOrDefaultAsync(q => q.Id == id);
|
||||||
if (questioncategory != null)
|
if (questioncategory != null)
|
||||||
{
|
{
|
||||||
logger?.LogInformation($"{questioncategory} customer(s) found");
|
logger?.LogInformation($"{questioncategory} customer(s) found");
|
||||||
var result = mapper.Map<Db.QuestionCategory, Models.QuestionCategory>(questioncategory);
|
var result = mapper.Map<Db.QuestionCategory, Models.MultiLanQuestionCategory>(questioncategory);
|
||||||
|
result.Titles = CreateCategoryMultiLanguageObject(GetCategoryTranslations(result.Id, language));
|
||||||
return (true, result, null);
|
return (true, result, null);
|
||||||
}
|
}
|
||||||
return (false, null, "Not found");
|
return (false, null, "Not found");
|
||||||
@ -298,17 +351,23 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
return (false, null, ex.Message);
|
return (false, null, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess, Models.QuestionCategory QuestionCategory, string ErrorMessage)> PostQuestionCategoryAsync(Models.QuestionCategory QuestionCategory)
|
public async Task<(bool IsSuccess, Models.MultiLanQuestionCategory QuestionCategory, string ErrorMessage)> PostQuestionCategoryAsync(Models.QuestionCategory QuestionCategory)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger?.LogInformation("Query Question");
|
logger?.LogInformation("Query Question");
|
||||||
var dbQuestionCategory = mapper.Map<Models.QuestionCategory, Db.QuestionCategory>(QuestionCategory);
|
var dbQuestionCategory = mapper.Map<Models.QuestionCategory, Db.QuestionCategory>(QuestionCategory);
|
||||||
|
var dbCategorytranslations = mapper.Map<List<Models.CategoryTranslation>, List<Db.CategoryTranslation>>(QuestionCategory.Categories);
|
||||||
// Question.QuestionType = GetQuestionType(Question.QuestionTypeId);
|
// Question.QuestionType = GetQuestionType(Question.QuestionTypeId);
|
||||||
questionDbContext.QuestionCategories.Add(dbQuestionCategory);
|
questionDbContext.QuestionCategories.Add(dbQuestionCategory);
|
||||||
questionDbContext.SaveChanges();
|
questionDbContext.SaveChanges();
|
||||||
QuestionCategory.Id = dbQuestionCategory.Id;
|
QuestionCategory.Id = dbQuestionCategory.Id;
|
||||||
return (true, QuestionCategory, null);
|
dbCategorytranslations.ForEach(i => i.CategoryId = QuestionCategory.Id);
|
||||||
|
questionDbContext.CategoryTranslations.AddRange(dbCategorytranslations);
|
||||||
|
questionDbContext.SaveChanges();
|
||||||
|
var result = mapper.Map<Db.QuestionCategory, Models.MultiLanQuestionCategory>(dbQuestionCategory);
|
||||||
|
result.Titles = CreateCategoryMultiLanguageObject(GetCategoryTranslations(result.Id, ""));
|
||||||
|
return (true, result, null);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -316,15 +375,23 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
return (false, null, ex.Message);
|
return (false, null, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess, Models.QuestionCategory QuestionCategory, string ErrorMessage)> UpdateQuestionCategoryAsync(Models.QuestionCategory QuestionCategory)
|
public async Task<(bool IsSuccess, Models.MultiLanQuestionCategory QuestionCategory, string ErrorMessage)> UpdateQuestionCategoryAsync(Models.QuestionCategory QuestionCategory)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbQuestionCategory = mapper.Map<Models.QuestionCategory, Db.QuestionCategory>(QuestionCategory);
|
var dbQuestionCategory = mapper.Map<Models.QuestionCategory, Db.QuestionCategory>(QuestionCategory);
|
||||||
|
var dbCategorytranslations = mapper.Map<List<Models.CategoryTranslation>, List<Db.CategoryTranslation>>(QuestionCategory.Categories);
|
||||||
questionDbContext.Entry(dbQuestionCategory).State = EntityState.Modified;
|
questionDbContext.Entry(dbQuestionCategory).State = EntityState.Modified;
|
||||||
|
QuestionCategory.Id = dbQuestionCategory.Id;
|
||||||
|
var oldcategories = questionDbContext.CategoryTranslations.Where(a => a.CategoryId == dbQuestionCategory.Id).ToList();
|
||||||
|
if (oldcategories != null)
|
||||||
|
questionDbContext.CategoryTranslations.RemoveRange(oldcategories);
|
||||||
|
dbCategorytranslations.ForEach(i => i.CategoryId = QuestionCategory.Id);
|
||||||
|
questionDbContext.CategoryTranslations.AddRange(dbCategorytranslations);
|
||||||
questionDbContext.SaveChanges();
|
questionDbContext.SaveChanges();
|
||||||
return (true, QuestionCategory, null);
|
var result = mapper.Map<Db.QuestionCategory, Models.MultiLanQuestionCategory>(dbQuestionCategory);
|
||||||
|
result.Titles = CreateCategoryMultiLanguageObject(GetCategoryTranslations(result.Id, ""));
|
||||||
|
return (true, result, null);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -333,18 +400,20 @@ namespace DamageAssesment.Api.Questions.Providers
|
|||||||
return (false, null, ex.Message);
|
return (false, null, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess, Models.QuestionCategory QuestionCategory, string ErrorMessage)> DeleteQuestionCategoryAsync(int Id)
|
public async Task<(bool IsSuccess, Models.MultiLanQuestionCategory QuestionCategory, string ErrorMessage)> DeleteQuestionCategoryAsync(int Id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var questioncategory = await questionDbContext.QuestionCategories.Where(x => x.Id == Id).FirstOrDefaultAsync();
|
var questioncategory = await questionDbContext.QuestionCategories.Where(x => x.Id == Id).FirstOrDefaultAsync();
|
||||||
if (questioncategory != null)
|
if (questioncategory != null)
|
||||||
{
|
{
|
||||||
|
var result = mapper.Map<Db.QuestionCategory, Models.MultiLanQuestionCategory>(questioncategory);
|
||||||
|
result.Titles = CreateCategoryMultiLanguageObject(GetCategoryTranslations(result.Id, ""));
|
||||||
var question = await questionDbContext.Questions.Where(x => x.Id == Id).ToListAsync();
|
var question = await questionDbContext.Questions.Where(x => x.Id == Id).ToListAsync();
|
||||||
questionDbContext.Questions.RemoveRange(question);
|
questionDbContext.Questions.RemoveRange(question);
|
||||||
questionDbContext.QuestionCategories.Remove(questioncategory);
|
questionDbContext.QuestionCategories.Remove(questioncategory);
|
||||||
questionDbContext.SaveChanges();
|
questionDbContext.SaveChanges();
|
||||||
return (true, mapper.Map<Db.QuestionCategory, Models.QuestionCategory>(questioncategory), $"QuestionID {Id} deleted Successfuly");
|
return (true, result, $"QuestionID {Id} deleted Successfuly");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -8,42 +8,42 @@ namespace DamageAssesment.Api.Questions.Test
|
|||||||
{
|
{
|
||||||
public class CategoryMockData
|
public class CategoryMockData
|
||||||
{
|
{
|
||||||
public static async Task<(bool, IEnumerable<Questions.Models.QuestionCategory>, string)> getOkResponse()
|
public static async Task<(bool, IEnumerable<Questions.Models.MultiLanQuestionCategory>, string)> getOkResponse()
|
||||||
{
|
{
|
||||||
IEnumerable<Questions.Models.QuestionCategory> list = new List<Questions.Models.QuestionCategory>();
|
IEnumerable<Questions.Models.MultiLanQuestionCategory> list = new List<Questions.Models.MultiLanQuestionCategory>();
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
list.Append(new Questions.Models.QuestionCategory { Id = i, CategoryImage = "img"+i,CategoryName="Category "+i });
|
list.Append(new Questions.Models.MultiLanQuestionCategory { Id = i, IconLibrary = "img"+i,IconName="Category "+i });
|
||||||
}
|
}
|
||||||
return (true, list, null);
|
return (true, list, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<(bool, Questions.Models.QuestionCategory, string)> getOkResponse(int Id)
|
public static async Task<(bool, Questions.Models.MultiLanQuestionCategory, string)> getOkResponse(int Id)
|
||||||
{
|
{
|
||||||
var Questions = await getOkResponse();
|
var Questions = await getOkResponse();
|
||||||
var Question = Questions.Item2.FirstOrDefault(s => s.Id == Id);
|
var Question = Questions.Item2.FirstOrDefault(s => s.Id == Id);
|
||||||
return (true, Question, null);
|
return (true, Question, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<(bool, Questions.Models.QuestionCategory, string)> getBadRequestResponse()
|
public static async Task<(bool, Questions.Models.MultiLanQuestionCategory, string)> getBadRequestResponse()
|
||||||
{
|
{
|
||||||
return (false, null, "Bad Request");
|
return (false, null, "Bad Request");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<(bool, Questions.Models.QuestionCategory, string)> getNotFoundResponse()
|
public static async Task<(bool, Questions.Models.MultiLanQuestionCategory, string)> getNotFoundResponse()
|
||||||
{
|
{
|
||||||
return (false, null, "Not Found");
|
return (false, null, "Not Found");
|
||||||
}
|
}
|
||||||
public static async Task<(bool, IEnumerable<Questions.Models.QuestionCategory>, string)> getNoContentResponse()
|
public static async Task<(bool, IEnumerable<Questions.Models.MultiLanQuestionCategory>, string)> getNoContentResponse()
|
||||||
{
|
{
|
||||||
IEnumerable<Questions.Models.QuestionCategory> list = new List<Questions.Models.QuestionCategory>();
|
IEnumerable<Questions.Models.MultiLanQuestionCategory> list = new List<Questions.Models.MultiLanQuestionCategory>();
|
||||||
return (false, list, null);
|
return (false, list, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<Questions.Models.QuestionCategory> getInputQuestionCategoryData()
|
public static async Task<Questions.Models.QuestionCategory> getInputQuestionCategoryData()
|
||||||
{
|
{
|
||||||
return new Questions.Models.QuestionCategory { Id = 1, CategoryName = "Category 1",CategoryImage="img 1" };
|
return new Questions.Models.QuestionCategory { Id = 1, IconName = "Category 1",IconLibrary="img 1" };
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,13 @@ namespace DamageAssesment.Api.Questions.Test
|
|||||||
public class MockData
|
public class MockData
|
||||||
{
|
{
|
||||||
|
|
||||||
public static async Task<(bool, IEnumerable<Questions.Models.Question>, string)> getOkResponse()
|
public static async Task<(bool, IEnumerable<Questions.Models.MultiLanQuestion>, string)> getOkResponse()
|
||||||
{
|
{
|
||||||
IEnumerable<Questions.Models.Question> list = new List<Questions.Models.Question>();
|
IEnumerable<Questions.Models.MultiLanQuestion> list = new List<Questions.Models.MultiLanQuestion>();
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
list.Append(new Questions.Models.Question { Id = i, TypeText = "Text" + i, SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId=i });
|
list.Append(new Questions.Models.MultiLanQuestion { Id = i, TypeText = "Text" + i, SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId=i });
|
||||||
}
|
}
|
||||||
return (true, list, null);
|
return (true, list, null);
|
||||||
}
|
}
|
||||||
@ -23,38 +23,38 @@ namespace DamageAssesment.Api.Questions.Test
|
|||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
List<Models.Question> question = new List<Models.Question>();
|
List<Models.MultiLanQuestion> question = new List<Models.MultiLanQuestion>();
|
||||||
question.Add(new Models.Question { Id = i, TypeText = "Text" + i, SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId = i });
|
question.Add(new Models.MultiLanQuestion { Id = i, TypeText = "Text" + i, SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId = i });
|
||||||
list.Append(new Questions.Models.SurveyQuestions
|
list.Append(new Questions.Models.SurveyQuestions
|
||||||
{
|
{
|
||||||
CategoryId = i,
|
CategoryId = i,
|
||||||
CategoryImage = "img" + i,
|
IconLibrary = "img" + i,
|
||||||
CategoryName = "Category " + i,
|
IconName = "Category " + i,
|
||||||
Questions = question
|
Questions = question
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return (true, list, null);
|
return (true, list, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<(bool, Questions.Models.Question, string)> getOkResponse(int Id)
|
public static async Task<(bool, Questions.Models.MultiLanQuestion, string)> getOkResponse(int Id)
|
||||||
{
|
{
|
||||||
var Questions = await getOkResponse();
|
var Questions = await getOkResponse();
|
||||||
var Question = Questions.Item2.FirstOrDefault(s => s.Id == Id);
|
var Question = Questions.Item2.FirstOrDefault(s => s.Id == Id);
|
||||||
return (true, Question, null);
|
return (true, Question, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<(bool, Questions.Models.Question, string)> getBadRequestResponse()
|
public static async Task<(bool, Questions.Models.MultiLanQuestion, string)> getBadRequestResponse()
|
||||||
{
|
{
|
||||||
return (false, null, "Bad Request");
|
return (false, null, "Bad Request");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<(bool, Questions.Models.Question, string)> getNotFoundResponse()
|
public static async Task<(bool, Questions.Models.MultiLanQuestion, string)> getNotFoundResponse()
|
||||||
{
|
{
|
||||||
return (false, null, "Not Found");
|
return (false, null, "Not Found");
|
||||||
}
|
}
|
||||||
public static async Task<(bool, IEnumerable<Questions.Models.Question>, string)> getNoContentResponse()
|
public static async Task<(bool, IEnumerable<Questions.Models.MultiLanQuestion>, string)> getNoContentResponse()
|
||||||
{
|
{
|
||||||
IEnumerable<Questions.Models.Question> list = new List<Questions.Models.Question>();
|
IEnumerable<Questions.Models.MultiLanQuestion> list = new List<Questions.Models.MultiLanQuestion>();
|
||||||
return (false, list, null);
|
return (false, list, null);
|
||||||
}
|
}
|
||||||
public static async Task<(bool, List<Questions.Models.SurveyQuestions>, string)> getNoSurveyContentResponse()
|
public static async Task<(bool, List<Questions.Models.SurveyQuestions>, string)> getNoSurveyContentResponse()
|
||||||
|
@ -42,7 +42,7 @@ namespace DamageAssesment.Api.Questions.Test
|
|||||||
mockQuestionService.Setup(service => service.GetQuestionAsync(1,null)).ReturnsAsync(mockResponse);
|
mockQuestionService.Setup(service => service.GetQuestionAsync(1,null)).ReturnsAsync(mockResponse);
|
||||||
|
|
||||||
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
|
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
|
||||||
var result = (OkObjectResult)await QuestionProvider.GetQuestionAsync(1,null);
|
var result = (OkObjectResult)await QuestionProvider.GetQuestionByIdAsync(1,null);
|
||||||
|
|
||||||
Assert.Equal(200, result.StatusCode);
|
Assert.Equal(200, result.StatusCode);
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ namespace DamageAssesment.Api.Questions.Test
|
|||||||
mockQuestionService.Setup(service => service.GetQuestionAsync(99,null)).ReturnsAsync(mockResponse);
|
mockQuestionService.Setup(service => service.GetQuestionAsync(99,null)).ReturnsAsync(mockResponse);
|
||||||
|
|
||||||
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
|
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
|
||||||
var result = (NotFoundResult)await QuestionProvider.GetQuestionAsync(99,null);
|
var result = (NotFoundResult)await QuestionProvider.GetQuestionByIdAsync(99,null);
|
||||||
Assert.Equal(404, result.StatusCode);
|
Assert.Equal(404, result.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,10 +188,10 @@ namespace DamageAssesment.Api.Questions.Test
|
|||||||
{
|
{
|
||||||
var mockQuestionService = new Mock<IQuestionsProvider>();
|
var mockQuestionService = new Mock<IQuestionsProvider>();
|
||||||
var mockResponse = await CategoryMockData.getOkResponse();
|
var mockResponse = await CategoryMockData.getOkResponse();
|
||||||
mockQuestionService.Setup(service => service.GetQuestionCategoriesAsync()).ReturnsAsync(mockResponse);
|
mockQuestionService.Setup(service => service.GetQuestionCategoriesAsync("en")).ReturnsAsync(mockResponse);
|
||||||
|
|
||||||
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
|
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
|
||||||
var result = (OkObjectResult)await QuestionProvider.GetQuestionCategoriesAsync();
|
var result = (OkObjectResult)await QuestionProvider.GetQuestionCategoriesAsync("en");
|
||||||
|
|
||||||
Assert.Equal(200, result.StatusCode);
|
Assert.Equal(200, result.StatusCode);
|
||||||
}
|
}
|
||||||
@ -201,10 +201,10 @@ namespace DamageAssesment.Api.Questions.Test
|
|||||||
{
|
{
|
||||||
var mockQuestionService = new Mock<IQuestionsProvider>();
|
var mockQuestionService = new Mock<IQuestionsProvider>();
|
||||||
var mockResponse = await CategoryMockData.getNoContentResponse();
|
var mockResponse = await CategoryMockData.getNoContentResponse();
|
||||||
mockQuestionService.Setup(service => service.GetQuestionCategoriesAsync()).ReturnsAsync(mockResponse);
|
mockQuestionService.Setup(service => service.GetQuestionCategoriesAsync("en")).ReturnsAsync(mockResponse);
|
||||||
|
|
||||||
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
|
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
|
||||||
var result = (NoContentResult)await QuestionProvider.GetQuestionCategoriesAsync();
|
var result = (NoContentResult)await QuestionProvider.GetQuestionCategoriesAsync("en");
|
||||||
|
|
||||||
Assert.Equal(204, result.StatusCode);
|
Assert.Equal(204, result.StatusCode);
|
||||||
}
|
}
|
||||||
@ -214,10 +214,10 @@ namespace DamageAssesment.Api.Questions.Test
|
|||||||
{
|
{
|
||||||
var mockQuestionService = new Mock<IQuestionsProvider>();
|
var mockQuestionService = new Mock<IQuestionsProvider>();
|
||||||
var mockResponse = await CategoryMockData.getOkResponse(1);
|
var mockResponse = await CategoryMockData.getOkResponse(1);
|
||||||
mockQuestionService.Setup(service => service.GetQuestionCategoryAsync(1)).ReturnsAsync(mockResponse);
|
mockQuestionService.Setup(service => service.GetQuestionCategoryAsync(1, "en")).ReturnsAsync(mockResponse);
|
||||||
|
|
||||||
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
|
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
|
||||||
var result = (OkObjectResult)await QuestionProvider.GetQuestionCategoryAsync(1);
|
var result = (OkObjectResult)await QuestionProvider.GetQuestionCategoryAsync(1, "en");
|
||||||
|
|
||||||
Assert.Equal(200, result.StatusCode);
|
Assert.Equal(200, result.StatusCode);
|
||||||
}
|
}
|
||||||
@ -227,10 +227,10 @@ namespace DamageAssesment.Api.Questions.Test
|
|||||||
{
|
{
|
||||||
var mockQuestionService = new Mock<IQuestionsProvider>();
|
var mockQuestionService = new Mock<IQuestionsProvider>();
|
||||||
var mockResponse = await CategoryMockData.getNotFoundResponse();
|
var mockResponse = await CategoryMockData.getNotFoundResponse();
|
||||||
mockQuestionService.Setup(service => service.GetQuestionCategoryAsync(99)).ReturnsAsync(mockResponse);
|
mockQuestionService.Setup(service => service.GetQuestionCategoryAsync(99, "en")).ReturnsAsync(mockResponse);
|
||||||
|
|
||||||
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
|
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
|
||||||
var result = (NotFoundResult)await QuestionProvider.GetQuestionCategoryAsync(99);
|
var result = (NotFoundResult)await QuestionProvider.GetQuestionCategoryAsync(99, "en");
|
||||||
Assert.Equal(404, result.StatusCode);
|
Assert.Equal(404, result.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ using Microsoft.Extensions.Configuration;
|
|||||||
|
|
||||||
namespace DamageAssesment.Api.SurveyResponses.Controllers
|
namespace DamageAssesment.Api.SurveyResponses.Controllers
|
||||||
{
|
{
|
||||||
[Route("Responses")]
|
[Route("api")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class SurveyResponsesController : ControllerBase
|
public class SurveyResponsesController : ControllerBase
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// GET request for retrieving survey responses.
|
/// GET request for retrieving survey responses.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet("SurveyResponses")]
|
||||||
public async Task<ActionResult> GetSurveyResponsesAsync()
|
public async Task<ActionResult> GetSurveyResponsesAsync()
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetSurveyResponsesAsync();
|
var result = await this.surveyResponseProvider.GetSurveyResponsesAsync();
|
||||||
@ -38,7 +38,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// GET request for retrieving survey responses by survey ID.
|
/// GET request for retrieving survey responses by survey ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpGet("surveys/{surveyId}")]
|
[HttpGet("SurveyResponses/{surveyId}")]
|
||||||
public async Task<ActionResult> GetSurveyResponsesAsync(int surveyId)
|
public async Task<ActionResult> GetSurveyResponsesAsync(int surveyId)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAsync(surveyId);
|
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAsync(surveyId);
|
||||||
@ -54,7 +54,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// <param name="surveyId">The ID of the survey for which responses are to be retrieved.</param>
|
/// <param name="surveyId">The ID of the survey for which responses are to be retrieved.</param>
|
||||||
/// <param name="locationId">The ID of the location for which responses are to be retrieved.</param>
|
/// <param name="locationId">The ID of the location for which responses are to be retrieved.</param>
|
||||||
|
|
||||||
[HttpGet("{surveyId}/{locationId}")]
|
[HttpGet("Responses/{surveyId}/{locationId}")]
|
||||||
public async Task<ActionResult> GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, string locationId)
|
public async Task<ActionResult> GetSurveyResponsesBySurveyAndLocationAsync(int surveyId, string locationId)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(surveyId, locationId);
|
var result = await this.surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(surveyId, locationId);
|
||||||
@ -72,7 +72,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// <param name="questionId">The ID of the question for which responses are to be retrieved.</param>
|
/// <param name="questionId">The ID of the question for which responses are to be retrieved.</param>
|
||||||
/// <param name="answer">The answer for which responses are to be retrieved.</param>
|
/// <param name="answer">The answer for which responses are to be retrieved.</param>
|
||||||
|
|
||||||
[HttpGet("ByAnswers/{surveyId}/{questionId}/{answer}")]
|
[HttpGet("ResponsesByAnswer/{surveyId}/{questionId}/{answer}")]
|
||||||
public async Task<ActionResult> GetSurveyResponsesByAnswerAsyncAsync(int surveyId, int questionId, string answer)
|
public async Task<ActionResult> GetSurveyResponsesByAnswerAsyncAsync(int surveyId, int questionId, string answer)
|
||||||
{
|
{
|
||||||
var result = await surveyResponseProvider.GetResponsesByAnswerAsync(surveyId, questionId, answer);
|
var result = await surveyResponseProvider.GetResponsesByAnswerAsync(surveyId, questionId, answer);
|
||||||
@ -88,7 +88,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="surveyId">The ID of the survey for which answers are to be retrieved.</param>
|
/// <param name="surveyId">The ID of the survey for which answers are to be retrieved.</param>
|
||||||
|
|
||||||
[HttpGet("ByRegion/{surveyId}")]
|
[HttpGet("AnswersByRegion/{surveyId}")]
|
||||||
public async Task<ActionResult> GetAnswersByRegionAsync(int surveyId)
|
public async Task<ActionResult> GetAnswersByRegionAsync(int surveyId)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetAnswersByRegionAsync(surveyId);
|
var result = await this.surveyResponseProvider.GetAnswersByRegionAsync(surveyId);
|
||||||
@ -103,7 +103,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="surveyId">The ID of the survey for which responses are to be retrieved.</param>
|
/// <param name="surveyId">The ID of the survey for which responses are to be retrieved.</param>
|
||||||
|
|
||||||
[HttpGet("ByMaintenanceCenter/{surveyId}")]
|
[HttpGet("AnswersByMaintenanceCenter/{surveyId}")]
|
||||||
public async Task<ActionResult> GetAnswersByMaintenaceCentersync(int surveyId)
|
public async Task<ActionResult> GetAnswersByMaintenaceCentersync(int surveyId)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.GetSurveyResponsesByMaintenanceCenterAsync(surveyId);
|
var result = await this.surveyResponseProvider.GetSurveyResponsesByMaintenanceCenterAsync(surveyId);
|
||||||
@ -134,7 +134,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="surveyResponse">The survey response object to be created.</param>
|
/// <param name="surveyResponse">The survey response object to be created.</param>
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost("SurveyResponses")]
|
||||||
public async Task<ActionResult> PostSurveysAsync(Models.SurveyResponse surveyResponse)
|
public async Task<ActionResult> PostSurveysAsync(Models.SurveyResponse surveyResponse)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.PostSurveyResponseAsync(surveyResponse);
|
var result = await this.surveyResponseProvider.PostSurveyResponseAsync(surveyResponse);
|
||||||
@ -150,7 +150,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// <param name="Id">The ID of the survey response to be updated.</param>
|
/// <param name="Id">The ID of the survey response to be updated.</param>
|
||||||
/// <param name="surveyResponse">The updated survey response object.</param>
|
/// <param name="surveyResponse">The updated survey response object.</param>
|
||||||
|
|
||||||
[HttpPut("{Id}")]
|
[HttpPut("SurveyResponses/{Id}")]
|
||||||
public async Task<ActionResult> PutSurveyResponseAsync(int Id, Models.SurveyResponse surveyResponse)
|
public async Task<ActionResult> PutSurveyResponseAsync(int Id, Models.SurveyResponse surveyResponse)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.PutSurveyResponseAsync(Id, surveyResponse);
|
var result = await this.surveyResponseProvider.PutSurveyResponseAsync(Id, surveyResponse);
|
||||||
@ -167,7 +167,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// DELETE request for deleting an existing survey response.
|
/// DELETE request for deleting an existing survey response.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[HttpDelete("{Id}")]
|
[HttpDelete("SurveyResponses/{Id}")]
|
||||||
public async Task<ActionResult> DeleteSurveyResponseAsync(int Id)
|
public async Task<ActionResult> DeleteSurveyResponseAsync(int Id)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.DeleteSurveyResponseAsync(Id);
|
var result = await this.surveyResponseProvider.DeleteSurveyResponseAsync(Id);
|
||||||
@ -182,7 +182,7 @@ namespace DamageAssesment.Api.SurveyResponses.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request">The answers to be submitted for the survey.</param>
|
/// <param name="request">The answers to be submitted for the survey.</param>
|
||||||
|
|
||||||
[HttpPost("Answers")]
|
[HttpPost("SurveyResponses/Answers")]
|
||||||
public async Task<ActionResult> PostSurveyAnswersAsync(Request request)
|
public async Task<ActionResult> PostSurveyAnswersAsync(Request request)
|
||||||
{
|
{
|
||||||
var result = await this.surveyResponseProvider.PostSurveyAnswersAsync(request);
|
var result = await this.surveyResponseProvider.PostSurveyAnswersAsync(request);
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
|
||||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -15,7 +13,6 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.5" />
|
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
|
||||||
|
|
||||||
# Use the ASP.NET base image
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
|
||||||
WORKDIR /app
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
# Use the SDK image for building
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
|
||||||
WORKDIR /src
|
|
||||||
|
|
||||||
# Copy the project file and restore dependencies
|
|
||||||
COPY ["DamageAssesment.Api.SurveyResponses/DamageAssesment.Api.SurveyResponses.csproj", "DamageAssesment.Api.SurveyResponses/"]
|
|
||||||
RUN dotnet restore "DamageAssesment.Api.SurveyResponses/DamageAssesment.Api.SurveyResponses.csproj"
|
|
||||||
|
|
||||||
# Copy the source code
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Change the working directory to the project directory
|
|
||||||
WORKDIR "/src/DamageAssesment.Api.SurveyResponses"
|
|
||||||
|
|
||||||
# Build the application
|
|
||||||
RUN dotnet build "DamageAssesment.Api.SurveyResponses.csproj" -c Release -o /app/build
|
|
||||||
|
|
||||||
# Publish the application
|
|
||||||
FROM build AS publish
|
|
||||||
RUN dotnet publish "DamageAssesment.Api.SurveyResponses.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
||||||
|
|
||||||
# Set up the final image
|
|
||||||
FROM base AS final
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy the published files from the publish stage
|
|
||||||
COPY --from=publish /app/publish .
|
|
||||||
|
|
||||||
## Set up the volume and copy the XML comments
|
|
||||||
#VOLUME /xmlcomments
|
|
||||||
#COPY ["DamageAssesment.Api.SurveyResponses.xml", "/xmlcomments/DamageAssesment.Api.SurveyResponses.xml"]
|
|
||||||
#
|
|
||||||
# Specify the entry point for the container
|
|
||||||
ENTRYPOINT ["dotnet", "DamageAssesment.Api.SurveyResponses.dll"]
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace DamageAssesment.Api.SurveyResponses.Models
|
|
||||||
{
|
|
||||||
public class QuestionRequest
|
|
||||||
{
|
|
||||||
public int QuestionId { get; set; }
|
|
||||||
public string AnswerText { get; set; }
|
|
||||||
public string Comment { get; set; }
|
|
||||||
public List<FileModel> PostedFiles { get; set; } = new List<FileModel>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -52,12 +52,7 @@ var app = builder.Build();
|
|||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI(options => {
|
app.UseSwaggerUI();
|
||||||
//switch for local environment
|
|
||||||
// options.SwaggerEndpoint("/swagger/v1/swagger.json", "");
|
|
||||||
options.SwaggerEndpoint("/surveyresponses/swagger/v1/swagger.json", "");
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
@ -1,30 +1,4 @@
|
|||||||
{
|
{
|
||||||
"profiles": {
|
|
||||||
"DamageAssesment.Api.SurveyResponses": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
},
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"applicationUrl": "http://localhost:5104"
|
|
||||||
},
|
|
||||||
"IIS Express": {
|
|
||||||
"commandName": "IISExpress",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Docker": {
|
|
||||||
"commandName": "Docker",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
|
||||||
"publishAllPorts": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
"iisSettings": {
|
"iisSettings": {
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
@ -33,5 +7,25 @@
|
|||||||
"applicationUrl": "http://localhost:58856",
|
"applicationUrl": "http://localhost:58856",
|
||||||
"sslPort": 0
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"DamageAssesment.Api.SurveyResponses": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "http://localhost:5104",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ namespace DamageAssesment.Api.SurveyResponses.Providers
|
|||||||
this.questionServiceProvider = questionServiceProvider;
|
this.questionServiceProvider = questionServiceProvider;
|
||||||
this.surveyServiceProvider = surveyServiceProvider;
|
this.surveyServiceProvider = surveyServiceProvider;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
|
|
||||||
//seedData();
|
//seedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,13 +6,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
|
|
||||||
"EndPointSettings": {
|
"EndPointSettings": {
|
||||||
"AnswerUrlBase": "http://damageassesment.api.answers:80",
|
"AnswerUrlBase": "http://localhost:5200",
|
||||||
"LocationUrlBase": "http://damageassesment.api.locations:80",
|
"LocationUrlBase": "http://localhost:5213",
|
||||||
"QuestionUrlBase": "http://damageassesment.api.questions:80",
|
"RegionUrlBase": "http://localhost:5211",
|
||||||
"EmployeeUrlBase": "http://damageassesment.api.employees:80",
|
"QuestionUrlBase": "http://localhost:5133",
|
||||||
"AttachmentUrlBase": "http://damageassesment.api.attachments:80",
|
"EmployeeUrlBase": "http://localhost:5135",
|
||||||
"SurveyUrlBase": "http://damageassesment.api.survey:80"
|
"AttachmentUrlBase": "http://localhost:5243",
|
||||||
}
|
"SurveyUrlBase": "http://localhost:5009"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DamageAssesment.Api.Surveys\DamageAssesment.Api.Surveys.csproj" />
|
<ProjectReference Include="..\DamageAssesment.Api.Surveys\DamageAssesment.Api.Survey.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -9,37 +9,37 @@ namespace DamageAssesment.Api.Survey.Test
|
|||||||
{
|
{
|
||||||
public class MockData
|
public class MockData
|
||||||
{
|
{
|
||||||
public static async Task<(bool, IEnumerable<Surveys.Models.Survey>, string)> getOkResponse()
|
public static async Task<(bool, IEnumerable<Surveys.Models.MultiLanSurvey>, string)> getOkResponse()
|
||||||
{
|
{
|
||||||
IEnumerable<Surveys.Models.Survey> list = new List<Surveys.Models.Survey>();
|
IEnumerable<Surveys.Models.MultiLanSurvey> list = new List<Surveys.Models.MultiLanSurvey>();
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
list.Append(new Surveys.Models.Survey { Id = i, /*Title = "Survey Title - " + i */});
|
list.Append(new Surveys.Models.MultiLanSurvey { Id = i, /*Title = "Survey Title - " + i */});
|
||||||
}
|
}
|
||||||
return (true, list, null);
|
return (true, list, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static async Task<(bool, Surveys.Models.Survey, string)> getOkResponse( int Id)
|
public static async Task<(bool, Surveys.Models.MultiLanSurvey, string)> getOkResponse( int Id)
|
||||||
{
|
{
|
||||||
var surveys = await getOkResponse();
|
var surveys = await getOkResponse();
|
||||||
var survey = surveys.Item2.FirstOrDefault(s => s.Id == Id);
|
var survey = surveys.Item2.FirstOrDefault(s => s.Id == Id);
|
||||||
return (true, survey, null);
|
return (true, survey, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<(bool, Surveys.Models.Survey, string)> getBadRequestResponse()
|
public static async Task<(bool, Surveys.Models.MultiLanSurvey, string)> getBadRequestResponse()
|
||||||
{
|
{
|
||||||
return (false, null,"Bad Request");
|
return (false, null,"Bad Request");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<(bool, Surveys.Models.Survey, string)> getNotFoundResponse()
|
public static async Task<(bool, Surveys.Models.MultiLanSurvey, string)> getNotFoundResponse()
|
||||||
{
|
{
|
||||||
return (false, null, "Not Found");
|
return (false, null, "Not Found");
|
||||||
}
|
}
|
||||||
public static async Task<(bool, IEnumerable<Surveys.Models.Survey>, string)> getNoContentResponse()
|
public static async Task<(bool, IEnumerable<Surveys.Models.MultiLanSurvey>, string)> getNoContentResponse()
|
||||||
{
|
{
|
||||||
IEnumerable<Surveys.Models.Survey> list = new List<Surveys.Models.Survey>();
|
IEnumerable<Surveys.Models.MultiLanSurvey> list = new List<Surveys.Models.MultiLanSurvey>();
|
||||||
return (false, list, null);
|
return (false, list, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
|
|
||||||
namespace DamageAssesment.Api.Surveys.Controllers
|
namespace DamageAssesment.Api.Surveys.Controllers
|
||||||
{
|
{
|
||||||
//[Route("api")]
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class SurveysController : ControllerBase
|
public class SurveysController : ControllerBase
|
||||||
{
|
{
|
||||||
@ -13,15 +12,12 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
|||||||
{
|
{
|
||||||
this.surveyProvider = surveyProvider;
|
this.surveyProvider = surveyProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// GET request for retrieving surveys
|
/// GET request for retrieving surveys.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
|
||||||
/// This endpoint retrieves surveys. You can use it to get all surveys or surveys for a specific language(optional).
|
|
||||||
/// </remarks>
|
|
||||||
[Route("Surveys")]
|
[Route("Surveys")]
|
||||||
[Route("{language}/Surveys")]
|
[Route("Surveys/{language:alpha}")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult> GetSurveysAsync(string? language)
|
public async Task<ActionResult> GetSurveysAsync(string? language)
|
||||||
{
|
{
|
||||||
@ -36,12 +32,12 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// GET request for retrieving surveys by ID.
|
/// GET request for retrieving surveys by ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("Surveys/{Id}")]
|
[Route("Surveys/{id:int}")]
|
||||||
[Route("{language}/Surveys/{Id}")]
|
[Route("Surveys/{id:int}/{language:alpha}")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult> GetSurveysAsync(int Id, string? language)
|
public async Task<ActionResult> GetSurveysAsync(int id, string? language)
|
||||||
{
|
{
|
||||||
var result = await this.surveyProvider.GetSurveysAsync(Id, language);
|
var result = await this.surveyProvider.GetSurveysAsync(id, language);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.Surveys);
|
return Ok(result.Surveys);
|
||||||
@ -67,10 +63,10 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
|
|
||||||
[HttpPut("Surveys/{Id}")]
|
[HttpPut("Surveys/{id}")]
|
||||||
public async Task<ActionResult> PutSurveysAsync(int Id, Models.Survey survey)
|
public async Task<ActionResult> PutSurveysAsync(int id, Models.Survey survey)
|
||||||
{
|
{
|
||||||
var result = await this.surveyProvider.PutSurveyAsync(Id, survey);
|
var result = await this.surveyProvider.PutSurveyAsync(id, survey);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.Survey);
|
return Ok(result.Survey);
|
||||||
@ -84,10 +80,10 @@ namespace DamageAssesment.Api.Surveys.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// DELETE request for deleting a survey by ID.
|
/// DELETE request for deleting a survey by ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpDelete("Surveys/{Id}")]
|
[HttpDelete("Surveys/{id}")]
|
||||||
public async Task<ActionResult> DeleteSurveysAsync(int Id)
|
public async Task<ActionResult> DeleteSurveysAsync(int id)
|
||||||
{
|
{
|
||||||
var result = await this.surveyProvider.DeleteSurveyAsync(Id);
|
var result = await this.surveyProvider.DeleteSurveyAsync(id);
|
||||||
if (result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
return Ok(result.Survey);
|
return Ok(result.Survey);
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
|
||||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -14,7 +12,6 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
@ -1,25 +0,0 @@
|
|||||||
##See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
|
||||||
|
|
||||||
# Use the ASP.NET runtime image as the base image
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
|
||||||
WORKDIR /app
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
# Use the .NET SDK image for the build stage
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
|
||||||
WORKDIR /src
|
|
||||||
COPY ["DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj", "DamageAssesment.Api.Surveys/"]
|
|
||||||
RUN dotnet restore "DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj"
|
|
||||||
COPY . .
|
|
||||||
WORKDIR "/src/DamageAssesment.Api.Surveys"
|
|
||||||
RUN dotnet build "DamageAssesment.Api.Survey.csproj" -c Release -o /app/build
|
|
||||||
|
|
||||||
# Publish the application
|
|
||||||
FROM build AS publish
|
|
||||||
RUN dotnet publish "DamageAssesment.Api.Survey.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
||||||
|
|
||||||
# Use the ASP.NET runtime image again for the final stage
|
|
||||||
FROM base AS final
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=publish /app/publish .
|
|
||||||
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Survey.dll"]
|
|
@ -2,11 +2,11 @@
|
|||||||
{
|
{
|
||||||
public interface ISurveyProvider
|
public interface ISurveyProvider
|
||||||
{
|
{
|
||||||
Task<(bool IsSuccess, IEnumerable< Models.Survey> Surveys, string ErrorMessage)> GetSurveysAsync(string Language);
|
Task<(bool IsSuccess, IEnumerable< Models.MultiLanSurvey> Surveys, string ErrorMessage)> GetSurveysAsync(string language);
|
||||||
Task<(bool IsSuccess, Models.Survey Surveys, string ErrorMessage)> GetSurveysAsync(int Id, string Language);
|
Task<(bool IsSuccess, Models.MultiLanSurvey Surveys, string ErrorMessage)> GetSurveysAsync(int id, string language);
|
||||||
Task<(bool IsSuccess, Models.Survey Survey, string ErrorMessage)> PostSurveyAsync(Models.Survey Survey);
|
Task<(bool IsSuccess, Models.MultiLanSurvey Survey, string ErrorMessage)> PostSurveyAsync(Models.Survey Survey);
|
||||||
Task<(bool IsSuccess, Models.Survey Survey, string ErrorMessage)> PutSurveyAsync(int Id,Models.Survey Survey);
|
Task<(bool IsSuccess, Models.MultiLanSurvey Survey, string ErrorMessage)> PutSurveyAsync(int id, Models.Survey Survey);
|
||||||
Task<(bool IsSuccess, Models.Survey Survey, string ErrorMessage)> DeleteSurveyAsync(int Id);
|
Task<(bool IsSuccess, Models.MultiLanSurvey Survey, string ErrorMessage)> DeleteSurveyAsync(int id);
|
||||||
void seedData();
|
void seedData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,21 @@
|
|||||||
|
|
||||||
namespace DamageAssesment.Api.Surveys.Models
|
namespace DamageAssesment.Api.Surveys.Models
|
||||||
{
|
{
|
||||||
public class Survey
|
public class MultiLanSurvey : BaseSurvey
|
||||||
|
{
|
||||||
|
public object Titles { get; set; }
|
||||||
|
}
|
||||||
|
public class Survey : BaseSurvey
|
||||||
|
{
|
||||||
|
public IEnumerable<SurveyTranslation> Titles { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
public class BaseSurvey
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public bool IsEnabled { get; set; }
|
public bool IsEnabled { get; set; }
|
||||||
public DateTime StartDate { get; set; }
|
public DateTime StartDate { get; set; }
|
||||||
public DateTime EndDate { get; set; }
|
public DateTime EndDate { get; set; }
|
||||||
public DateTime CreatedDate { get; set; }
|
public DateTime CreatedDate { get; set; }
|
||||||
public IEnumerable<SurveyTranslation> Titles { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
public class SurveysProfile:AutoMapper.Profile
|
public class SurveysProfile:AutoMapper.Profile
|
||||||
{
|
{
|
||||||
public SurveysProfile() {
|
public SurveysProfile() {
|
||||||
CreateMap<Db.Survey, Models.Survey>();
|
CreateMap<Db.Survey, Models.MultiLanSurvey>();
|
||||||
CreateMap<Models.Survey, Db.Survey>();
|
CreateMap<Models.Survey, Db.Survey>();
|
||||||
|
CreateMap<Db.SurveyTranslation, Models.SurveyTranslation>();
|
||||||
|
CreateMap<Models.SurveyTranslation, Db.SurveyTranslation>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@ -53,12 +52,6 @@ var app = builder.Build();
|
|||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI(options => {
|
|
||||||
//switch for local environment
|
|
||||||
// options.SwaggerEndpoint("/swagger/v1/swagger.json", "");
|
|
||||||
options.SwaggerEndpoint("/surveys/swagger/v1/swagger.json", "");
|
|
||||||
|
|
||||||
});
|
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
|
|
||||||
using (var serviceScope = app.Services.CreateScope())
|
using (var serviceScope = app.Services.CreateScope())
|
||||||
|
@ -1,30 +1,4 @@
|
|||||||
{
|
{
|
||||||
"profiles": {
|
|
||||||
"DamageAssesment.Api.Surveys": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
},
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"applicationUrl": "http://localhost:5009"
|
|
||||||
},
|
|
||||||
"IIS Express": {
|
|
||||||
"commandName": "IISExpress",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Docker": {
|
|
||||||
"commandName": "Docker",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
|
||||||
"publishAllPorts": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
"iisSettings": {
|
"iisSettings": {
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
@ -33,5 +7,25 @@
|
|||||||
"applicationUrl": "http://localhost:51498",
|
"applicationUrl": "http://localhost:51498",
|
||||||
"sslPort": 0
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"DamageAssesment.Api.Surveys": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "http://localhost:5009",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,60 +49,57 @@ namespace DamageAssesment.Api.Surveys.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, IEnumerable<Models.Survey> Surveys, string ErrorMessage)> GetSurveysAsync(string Language)
|
public IEnumerable<Models.SurveyTranslation> GetSurveyTranslations(int id, IEnumerable<Models.SurveyTranslation> SurveyTranslation,string? language)
|
||||||
{
|
{
|
||||||
IEnumerable<Models.Survey> surveysList = null;
|
if (SurveyTranslation == null)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(language))
|
||||||
|
{
|
||||||
|
SurveyTranslation = mapper.Map<IEnumerable<Db.SurveyTranslation>, IEnumerable<Models.SurveyTranslation>>(
|
||||||
|
surveyDbContext.SurveysTranslation.Where(a => a.SurveyId == id).ToList());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SurveyTranslation = mapper.Map<IEnumerable<Db.SurveyTranslation>, IEnumerable<Models.SurveyTranslation>>(
|
||||||
|
surveyDbContext.SurveysTranslation.Where(a => a.SurveyId == id && a.Language == language).ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SurveyTranslation;
|
||||||
|
}
|
||||||
|
public object CreateMultiLanguageObject(IEnumerable<Models.SurveyTranslation> surveyTranslations)
|
||||||
|
{
|
||||||
|
object MultiLanguage = new object();
|
||||||
|
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||||||
|
foreach (Models.SurveyTranslation item in surveyTranslations)
|
||||||
|
{
|
||||||
|
dict.Add(item.Language, item.Title);
|
||||||
|
}
|
||||||
|
MultiLanguage = dict;
|
||||||
|
return MultiLanguage;
|
||||||
|
}
|
||||||
|
public async Task<(bool IsSuccess, IEnumerable<Models.MultiLanSurvey> Surveys, string ErrorMessage)> GetSurveysAsync(string language)
|
||||||
|
{
|
||||||
|
IEnumerable<Models.MultiLanSurvey> surveysList = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger?.LogInformation("Get all Surveys from DB");
|
logger?.LogInformation("Gell all Surveys from DB");
|
||||||
var surveys = await surveyDbContext.Surveys.Where(s => s.IsEnabled == true).ToListAsync();
|
var surveys = await surveyDbContext.Surveys.Where(s => s.IsEnabled == true).ToListAsync();
|
||||||
var surveyTranslations = await surveyDbContext.SurveysTranslation.ToListAsync();
|
//var surveyTranslations = await surveyDbContext.SurveysTranslation.ToListAsync();
|
||||||
|
|
||||||
if (surveys != null)
|
if (surveys != null)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(Language))
|
surveysList = from s in surveys
|
||||||
{
|
select new
|
||||||
surveysList = from s in surveys
|
Models.MultiLanSurvey
|
||||||
select new
|
{
|
||||||
Models.Survey
|
Id = s.Id,
|
||||||
{
|
StartDate = s.StartDate,
|
||||||
Id = s.Id,
|
EndDate = s.EndDate,
|
||||||
StartDate = s.StartDate,
|
IsEnabled = s.IsEnabled,
|
||||||
EndDate = s.EndDate,
|
CreatedDate = s.CreatedDate,
|
||||||
IsEnabled = s.IsEnabled,
|
Titles = CreateMultiLanguageObject(GetSurveyTranslations(s.Id,null, language))
|
||||||
CreatedDate = s.CreatedDate,
|
|
||||||
Titles = from t in surveyTranslations
|
|
||||||
where t.SurveyId == s.Id
|
|
||||||
select new Models.SurveyTranslation
|
|
||||||
{
|
|
||||||
Title = t.Title,
|
|
||||||
Language = t.Language
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
surveysList = from s in surveys
|
|
||||||
select new
|
|
||||||
Models.Survey
|
|
||||||
{
|
|
||||||
Id = s.Id,
|
|
||||||
StartDate = s.StartDate,
|
|
||||||
EndDate = s.EndDate,
|
|
||||||
IsEnabled = s.IsEnabled,
|
|
||||||
CreatedDate = s.CreatedDate,
|
|
||||||
Titles = from t in surveyTranslations
|
|
||||||
where t.SurveyId == s.Id
|
|
||||||
&& t.Language == Language
|
|
||||||
select new Models.SurveyTranslation
|
|
||||||
{
|
|
||||||
Title = t.Title,
|
|
||||||
Language = t.Language
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
logger?.LogInformation($"{surveys.Count} Items(s) found");
|
logger?.LogInformation($"{surveys.Count} Items(s) found");
|
||||||
return (true, surveysList, null);
|
return (true, surveysList, null);
|
||||||
@ -115,55 +112,27 @@ namespace DamageAssesment.Api.Surveys.Providers
|
|||||||
return (false, null, ex.Message);
|
return (false, null, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess, Models.Survey Surveys, string ErrorMessage)> GetSurveysAsync(int Id, string Language)
|
public async Task<(bool IsSuccess, Models.MultiLanSurvey Surveys, string ErrorMessage)> GetSurveysAsync(int id, string language)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger?.LogInformation("Query Survey");
|
logger?.LogInformation("Query Survey");
|
||||||
var survey = await surveyDbContext.Surveys.SingleOrDefaultAsync(s => s.Id == Id && s.IsEnabled == true);
|
var survey = await surveyDbContext.Surveys.SingleOrDefaultAsync(s => s.Id == id && s.IsEnabled == true);
|
||||||
if (survey != null)
|
if (survey != null)
|
||||||
{
|
{
|
||||||
Models.Survey result = null;
|
Models.MultiLanSurvey result = null;
|
||||||
var surveyTranslations = await surveyDbContext.SurveysTranslation.Where(s => s.SurveyId == survey.Id).ToListAsync();
|
var surveyTranslations = await surveyDbContext.SurveysTranslation.Where(s => s.SurveyId == survey.Id).ToListAsync();
|
||||||
|
result = new Models.MultiLanSurvey
|
||||||
if (string.IsNullOrEmpty(Language))
|
|
||||||
{
|
{
|
||||||
result = new Models.Survey
|
Id = survey.Id,
|
||||||
{
|
StartDate = survey.StartDate,
|
||||||
Id = survey.Id,
|
EndDate = survey.EndDate,
|
||||||
StartDate = survey.StartDate,
|
IsEnabled = survey.IsEnabled,
|
||||||
EndDate = survey.EndDate,
|
CreatedDate = survey.CreatedDate,
|
||||||
IsEnabled = survey.IsEnabled,
|
Titles = CreateMultiLanguageObject(GetSurveyTranslations(survey.Id,null, language))
|
||||||
CreatedDate = survey.CreatedDate,
|
|
||||||
Titles = from t in surveyTranslations
|
|
||||||
select new Models.SurveyTranslation
|
|
||||||
{
|
|
||||||
Title = t.Title,
|
|
||||||
Language = t.Language
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
logger?.LogInformation($"Survey Id: {id} found");
|
||||||
else
|
|
||||||
{
|
|
||||||
result = new Models.Survey
|
|
||||||
{
|
|
||||||
Id = survey.Id,
|
|
||||||
StartDate = survey.StartDate,
|
|
||||||
EndDate = survey.EndDate,
|
|
||||||
IsEnabled = survey.IsEnabled,
|
|
||||||
CreatedDate = survey.CreatedDate,
|
|
||||||
Titles = from t in surveyTranslations
|
|
||||||
where t.Language == Language
|
|
||||||
select new Models.SurveyTranslation
|
|
||||||
{
|
|
||||||
Title = t.Title,
|
|
||||||
Language = t.Language
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
logger?.LogInformation($"Survey Id: {Id} found");
|
|
||||||
return (true, result, null);
|
return (true, result, null);
|
||||||
}
|
}
|
||||||
return (false, null, "Not found");
|
return (false, null, "Not found");
|
||||||
@ -175,7 +144,7 @@ namespace DamageAssesment.Api.Surveys.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, Models.Survey Survey, string ErrorMessage)> PostSurveyAsync(Models.Survey survey)
|
public async Task<(bool IsSuccess, Models.MultiLanSurvey Survey, string ErrorMessage)> PostSurveyAsync(Models.Survey survey)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -192,8 +161,9 @@ namespace DamageAssesment.Api.Surveys.Providers
|
|||||||
surveyDbContext.SurveysTranslation.Add(new Db.SurveyTranslation {SurveyId = _survey.Id, Language = title.Language, Title = title.Title });
|
surveyDbContext.SurveysTranslation.Add(new Db.SurveyTranslation {SurveyId = _survey.Id, Language = title.Language, Title = title.Title });
|
||||||
}
|
}
|
||||||
await surveyDbContext.SaveChangesAsync();
|
await surveyDbContext.SaveChangesAsync();
|
||||||
survey.Id = _survey.Id;
|
var result = mapper.Map<Db.Survey, Models.MultiLanSurvey>(_survey);
|
||||||
return (true,survey, "Successful");
|
result.Titles = CreateMultiLanguageObject(GetSurveyTranslations(_survey.Id, survey.Titles, ""));
|
||||||
|
return (true, result, "Successful");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -208,7 +178,7 @@ namespace DamageAssesment.Api.Surveys.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, Models.Survey Survey, string ErrorMessage)> PutSurveyAsync(int Id, Models.Survey survey)
|
public async Task<(bool IsSuccess, Models.MultiLanSurvey Survey, string ErrorMessage)> PutSurveyAsync(int Id, Models.Survey survey)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -236,21 +206,8 @@ namespace DamageAssesment.Api.Surveys.Providers
|
|||||||
surveyDbContext.SurveysTranslation.AddRange(listSurveyTranslation);
|
surveyDbContext.SurveysTranslation.AddRange(listSurveyTranslation);
|
||||||
await surveyDbContext.SaveChangesAsync();
|
await surveyDbContext.SaveChangesAsync();
|
||||||
|
|
||||||
var result = new Models.Survey
|
var result = mapper.Map<Db.Survey, Models.MultiLanSurvey>(_survey);
|
||||||
{
|
result.Titles = CreateMultiLanguageObject(GetSurveyTranslations(_survey.Id, survey.Titles, ""));
|
||||||
Id = Id,
|
|
||||||
StartDate = survey.StartDate,
|
|
||||||
EndDate = survey.EndDate,
|
|
||||||
IsEnabled = survey.IsEnabled,
|
|
||||||
CreatedDate = survey.CreatedDate,
|
|
||||||
Titles = from t in listSurveyTranslation
|
|
||||||
select new Models.SurveyTranslation
|
|
||||||
{
|
|
||||||
Title = t.Title,
|
|
||||||
Language = t.Language
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
return (true, result, "Successful");
|
return (true, result, "Successful");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -272,7 +229,7 @@ namespace DamageAssesment.Api.Surveys.Providers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, Models.Survey Survey, string ErrorMessage)> DeleteSurveyAsync(int Id)
|
public async Task<(bool IsSuccess, Models.MultiLanSurvey Survey, string ErrorMessage)> DeleteSurveyAsync(int Id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -280,9 +237,11 @@ namespace DamageAssesment.Api.Surveys.Providers
|
|||||||
|
|
||||||
if (survey != null)
|
if (survey != null)
|
||||||
{
|
{
|
||||||
|
var result = mapper.Map<Db.Survey, Models.MultiLanSurvey>(survey);
|
||||||
|
result.Titles = CreateMultiLanguageObject(GetSurveyTranslations(survey.Id, null, ""));
|
||||||
surveyDbContext.Surveys.Remove(survey);
|
surveyDbContext.Surveys.Remove(survey);
|
||||||
await surveyDbContext.SaveChangesAsync();
|
await surveyDbContext.SaveChangesAsync();
|
||||||
return (true, mapper.Map<Db.Survey, Models.Survey>(survey), $"Survey Id: {Id} deleted Successfuly");
|
return (true, result, $"Survey Id: {Id} deleted Successfuly");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
namespace DamageAssesment.Api.UsersAccess.Bases
|
|
||||||
{
|
|
||||||
public class ServiceProviderBase
|
|
||||||
{
|
|
||||||
protected readonly IConfiguration configuration;
|
|
||||||
protected readonly HttpClient httpClient;
|
|
||||||
protected private readonly ILogger<ServiceProviderBase> logger;
|
|
||||||
protected string ressource;
|
|
||||||
protected string urlBase;
|
|
||||||
|
|
||||||
|
|
||||||
public ServiceProviderBase(IConfiguration configuration, HttpClient httpClient, ILogger<ServiceProviderBase> logger, string ressource, string urlBase)
|
|
||||||
{
|
|
||||||
this.configuration = configuration;
|
|
||||||
this.httpClient = httpClient;
|
|
||||||
this.logger = logger;
|
|
||||||
this.ressource = ressource;
|
|
||||||
this.urlBase = urlBase;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,97 +0,0 @@
|
|||||||
using DamageAssesment.Api.UsersAccess.Interfaces;
|
|
||||||
using DamageAssesment.Api.UsersAccess.Models;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Controllers
|
|
||||||
{
|
|
||||||
[Route("api")]
|
|
||||||
[ApiController]
|
|
||||||
public class UsersAccessController : ControllerBase
|
|
||||||
{
|
|
||||||
private IUsersAccessProvider userAccessProvider;
|
|
||||||
|
|
||||||
public UsersAccessController(IUsersAccessProvider userAccessProvider)
|
|
||||||
{
|
|
||||||
this.userAccessProvider = userAccessProvider;
|
|
||||||
}
|
|
||||||
[HttpPost("authenticate")]
|
|
||||||
public async Task<ActionResult> AuthenticateAsync(UserCredentials userCredentials)
|
|
||||||
{
|
|
||||||
var result = await userAccessProvider.AuthenticateAsync(userCredentials);
|
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
|
||||||
return Ok(result.TokenResponse);
|
|
||||||
}
|
|
||||||
return Unauthorized(result.ErrorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("refreshToken")]
|
|
||||||
public async Task<ActionResult> RefreshTokenAsync(TokenResponse tokenResponse)
|
|
||||||
{
|
|
||||||
var result = await userAccessProvider.RefreshTokenAsync(tokenResponse);
|
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
|
||||||
return Ok(result.TokenResponse);
|
|
||||||
}
|
|
||||||
return Unauthorized(result.ErrorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("users")]
|
|
||||||
public async Task<ActionResult> GetUsersAsync()
|
|
||||||
{
|
|
||||||
var result = await userAccessProvider.GetUsersAsync();
|
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
|
||||||
return Ok(result.Users);
|
|
||||||
}
|
|
||||||
return NoContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("users/{Id}")]
|
|
||||||
public async Task<ActionResult> GetUsersAsync(int Id)
|
|
||||||
{
|
|
||||||
var result = await userAccessProvider.GetUsersAsync(Id);
|
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
|
||||||
return Ok(result.User);
|
|
||||||
}
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("users")]
|
|
||||||
public async Task<ActionResult> PostUserAsync(User user)
|
|
||||||
{
|
|
||||||
var result = await userAccessProvider.PostUserAsync(user);
|
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
|
||||||
return Ok(result.User);
|
|
||||||
}
|
|
||||||
return BadRequest(result.ErrorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPut("users/{Id}")]
|
|
||||||
public async Task<ActionResult> PutUserAsync(int Id, User user)
|
|
||||||
{
|
|
||||||
var result = await userAccessProvider.PutUserAsync(Id, user);
|
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
|
||||||
return Ok(result.User);
|
|
||||||
}
|
|
||||||
if (result.ErrorMessage == "Not Found")
|
|
||||||
return NotFound(result.ErrorMessage);
|
|
||||||
|
|
||||||
return BadRequest(result.ErrorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpDelete("users/{Id}")]
|
|
||||||
public async Task<ActionResult> DeleteSurveysAsync(int Id)
|
|
||||||
{
|
|
||||||
var result = await userAccessProvider.DeleteUserAsync(Id);
|
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
|
||||||
return Ok(result.User);
|
|
||||||
}
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<<<<<<<< HEAD:DamageAssesmentApi/DamageAssesment.Api.UsersAccess/DamageAssesment.Api.UsersAccess.csproj
|
|
||||||
========
|
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
|
||||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
|
||||||
>>>>>>>> origin/server-branch:DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
|
||||||
<<<<<<<< HEAD:DamageAssesmentApi/DamageAssesment.Api.UsersAccess/DamageAssesment.Api.UsersAccess.csproj
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.10" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
|
||||||
========
|
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
|
||||||
>>>>>>>> origin/server-branch:DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj
|
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,21 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Db
|
|
||||||
{
|
|
||||||
public class Role
|
|
||||||
{
|
|
||||||
[Key]
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[StringLength(100)]
|
|
||||||
[Required]
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
// add a status field
|
|
||||||
|
|
||||||
[StringLength(100)]
|
|
||||||
public string? Description { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Db
|
|
||||||
{
|
|
||||||
public class Token
|
|
||||||
{
|
|
||||||
[Key]
|
|
||||||
public string Id { get; set; }
|
|
||||||
[Required]
|
|
||||||
[ForeignKey("User")]
|
|
||||||
public int UserId { get; set; }
|
|
||||||
public string? RefreshToken { get; set; }
|
|
||||||
public bool? IsActive { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Db
|
|
||||||
{
|
|
||||||
public class User
|
|
||||||
{
|
|
||||||
[Key]
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey("Employee")]
|
|
||||||
public string EmployeeId { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey("Role")]
|
|
||||||
[Required]
|
|
||||||
public int RoleId { get; set; }
|
|
||||||
[Required]
|
|
||||||
public bool? IsActive { get; set; } = true;
|
|
||||||
|
|
||||||
[Required]
|
|
||||||
public DateTime? CreateDate { get; set; } = DateTime.Now;
|
|
||||||
|
|
||||||
public DateTime? UpdateDate { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Db
|
|
||||||
{
|
|
||||||
public class UsersAccessDbContext:DbContext
|
|
||||||
{
|
|
||||||
public DbSet<Db.User> Users { get; set; }
|
|
||||||
public DbSet<Db.Role> Roles { get; set; }
|
|
||||||
public DbSet<Db.Token> Tokens { get; set; }
|
|
||||||
public UsersAccessDbContext(DbContextOptions options) : base(options)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
using DamageAssesment.Api.UsersAccess.Models;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Interfaces
|
|
||||||
{
|
|
||||||
public interface IEmployeeServiceProvider
|
|
||||||
{
|
|
||||||
Task<List<Employee>> getEmployeesAsync();
|
|
||||||
Task<Employee> getEmployeeAsync(string employeeID);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
namespace DamageAssesment.Api.UsersAccess.Interfaces
|
|
||||||
{
|
|
||||||
public interface IRoleProvider
|
|
||||||
{
|
|
||||||
Task<(bool IsSuccess, IEnumerable< Models.Role> Roles, string ErrorMessage)> GetRolesAsync();
|
|
||||||
Task<(bool IsSuccess, Models.Role Roles, string ErrorMessage)> GetRolesAsync(int Id);
|
|
||||||
Task<(bool IsSuccess, Models.Role Role, string ErrorMessage)> PostRoleAsync(Models.Role Role);
|
|
||||||
Task<(bool IsSuccess, Models.Role Role, string ErrorMessage)> PutRoleAsync(int Id,Models.Role Role);
|
|
||||||
Task<(bool IsSuccess, Models.Role Role, string ErrorMessage)> DeleteRoleAsync(int Id);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
using DamageAssesment.Api.UsersAccess.Models;
|
|
||||||
using System.Security.Claims;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Interfaces
|
|
||||||
{
|
|
||||||
public interface ITokenServiceProvider
|
|
||||||
{
|
|
||||||
Task<string> GenerateToken(User user);
|
|
||||||
Task<TokenResponse> TokenAuthenticate(User user, Claim[] claims);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using DamageAssesment.Api.UsersAccess.Models;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Interfaces
|
|
||||||
{
|
|
||||||
public interface IUsersAccessProvider
|
|
||||||
{
|
|
||||||
public Task<(bool IsSuccess, IEnumerable< Models.User> Users, string ErrorMessage)> GetUsersAsync();
|
|
||||||
public Task<(bool IsSuccess, Models.User User, string ErrorMessage)> GetUsersAsync(int Id);
|
|
||||||
public Task<(bool IsSuccess, Models.User User, string ErrorMessage)> PostUserAsync(Models.User User);
|
|
||||||
public Task<(bool IsSuccess, Models.User User, string ErrorMessage)> PutUserAsync(int Id,Models.User User);
|
|
||||||
public Task<(bool IsSuccess, Models.User User, string ErrorMessage)> DeleteUserAsync(int Id);
|
|
||||||
public Task<(bool IsSuccess, IEnumerable<Models.Role> Roles, string ErrorMessage)> GetRolesAsync();
|
|
||||||
public Task<(bool IsSuccess, Models.TokenResponse TokenResponse, string ErrorMessage)> AuthenticateAsync(UserCredentials userCredentials);
|
|
||||||
public Task<(bool IsSuccess, Models.TokenResponse TokenResponse, string ErrorMessage)>RefreshTokenAsync(TokenResponse tokenResponse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Models
|
|
||||||
{
|
|
||||||
public class Employee
|
|
||||||
{
|
|
||||||
public string Id { get; set; }
|
|
||||||
|
|
||||||
[StringLength(50)]
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
public DateTime BirthDate { get; set; }
|
|
||||||
|
|
||||||
[StringLength(50)]
|
|
||||||
public string OfficePhoneNumber { get; set; }
|
|
||||||
|
|
||||||
[StringLength(50)]
|
|
||||||
public string Email { get; set; }
|
|
||||||
public bool IsActive { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Models
|
|
||||||
{
|
|
||||||
|
|
||||||
public class JwtSettings
|
|
||||||
{
|
|
||||||
public string securitykey { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Models
|
|
||||||
{
|
|
||||||
public class Role {
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string? Description { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
namespace DamageAssesment.Api.UsersAccess.Models
|
|
||||||
{
|
|
||||||
public class Token
|
|
||||||
{
|
|
||||||
public string Id { get; set; }
|
|
||||||
public int UserId { get; set; }
|
|
||||||
public string? RefreshToken { get; set; }
|
|
||||||
public bool? IsActive { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
namespace DamageAssesment.Api.UsersAccess.Models
|
|
||||||
{
|
|
||||||
public class TokenResponse
|
|
||||||
{
|
|
||||||
public string? jwttoken { get; set; }
|
|
||||||
public string? refreshtoken { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
namespace DamageAssesment.Api.UsersAccess.Models
|
|
||||||
{
|
|
||||||
public class User
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string EmployeeId { get; set; }
|
|
||||||
public int RoleId { get; set; }
|
|
||||||
public bool? IsActive { get; set; }
|
|
||||||
public DateTime? CreateDate { get; set; }
|
|
||||||
public DateTime? UpdateDate { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
public class UserCredentials
|
|
||||||
{
|
|
||||||
public string? username { get; set; }
|
|
||||||
// public string? password { get; set; }
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
namespace DamageAssesment.Api.UsersAccess.Profiles
|
|
||||||
{
|
|
||||||
public class UsersAccessProfile : AutoMapper.Profile
|
|
||||||
{
|
|
||||||
public UsersAccessProfile()
|
|
||||||
{
|
|
||||||
CreateMap<Db.User, Models.User>();
|
|
||||||
CreateMap<Models.User, Db.User>();
|
|
||||||
|
|
||||||
CreateMap<Db.Role, Models.Role>();
|
|
||||||
CreateMap<Models.Role, Db.Role>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
using DamageAssesment.Api.UsersAccess.Db;
|
|
||||||
using DamageAssesment.Api.UsersAccess.Interfaces;
|
|
||||||
using DamageAssesment.Api.UsersAccess.Providers;
|
|
||||||
using DamageAssesment.Api.UsersAccess.Models;
|
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
using System.Text;
|
|
||||||
using Polly;
|
|
||||||
using DamageAssesment.Api.SurveyResponses.Providers;
|
|
||||||
|
|
||||||
const int maxApiCallRetries = 3;
|
|
||||||
const int intervalToRetry = 2; //2 seconds
|
|
||||||
const int maxRetryForCircuitBraker = 5;
|
|
||||||
const int intervalForCircuitBraker = 5; //5 seconds
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
|
||||||
|
|
||||||
// Add services to the container.
|
|
||||||
var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey");
|
|
||||||
builder.Services.AddAuthentication(item =>
|
|
||||||
{
|
|
||||||
item.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
|
||||||
item.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
|
||||||
}).AddJwtBearer(item =>
|
|
||||||
{
|
|
||||||
item.RequireHttpsMetadata = true;
|
|
||||||
item.SaveToken = true;
|
|
||||||
item.TokenValidationParameters = new TokenValidationParameters()
|
|
||||||
{
|
|
||||||
ValidateIssuerSigningKey = true,
|
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(authkey)),
|
|
||||||
ValidateIssuer = false,
|
|
||||||
ValidateAudience = false,
|
|
||||||
ClockSkew = TimeSpan.Zero
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
var _jwtsettings = builder.Configuration.GetSection("JwtSettings");
|
|
||||||
builder.Services.Configure<JwtSettings>(_jwtsettings);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddHttpClient<IEmployeeServiceProvider, EmployeeServiceProvider>().
|
|
||||||
AddTransientHttpErrorPolicy(policy => policy.WaitAndRetryAsync(maxApiCallRetries, _ => TimeSpan.FromSeconds(intervalToRetry))).
|
|
||||||
AddTransientHttpErrorPolicy(policy => policy.CircuitBreakerAsync(maxRetryForCircuitBraker, TimeSpan.FromSeconds(intervalForCircuitBraker)));
|
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
||||||
builder.Services.AddScoped<IUsersAccessProvider, UsersAccessProvider>();
|
|
||||||
builder.Services.AddScoped<ITokenServiceProvider, TokenServiceProvider>();
|
|
||||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
|
||||||
builder.Services.AddSwaggerGen();
|
|
||||||
builder.Services.AddDbContext<UsersAccessDbContext>(option =>
|
|
||||||
{
|
|
||||||
option.UseInMemoryDatabase("UsersAccess");
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var app = builder.Build();
|
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
|
||||||
if (app.Environment.IsDevelopment())
|
|
||||||
{
|
|
||||||
app.UseSwagger();
|
|
||||||
app.UseSwaggerUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
app.UseAuthentication();
|
|
||||||
app.UseAuthorization();
|
|
||||||
|
|
||||||
app.MapControllers();
|
|
||||||
|
|
||||||
app.Run();
|
|
@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:28382",
|
|
||||||
"sslPort": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
|
||||||
"DamageAssesment.Api.Users": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"applicationUrl": "http://localhost:5027",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"IIS Express": {
|
|
||||||
"commandName": "IISExpress",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"launchUrl": "swagger",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
using DamageAssesment.Api.UsersAccess.Bases;
|
|
||||||
using DamageAssesment.Api.UsersAccess.Interfaces;
|
|
||||||
using DamageAssesment.Api.UsersAccess.Models;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.SurveyResponses.Providers
|
|
||||||
{
|
|
||||||
public class EmployeeServiceProvider :ServiceProviderBase, IEmployeeServiceProvider
|
|
||||||
{
|
|
||||||
public EmployeeServiceProvider(IConfiguration configuration, HttpClient httpClient, ILogger<EmployeeServiceProvider> logger) : base(configuration, httpClient, logger, "/api/Employees", configuration.GetValue<string>("EndPointSettings:EmployeeUrlBase"))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<List<Employee>> getEmployeesAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
httpClient.BaseAddress = new Uri(urlBase);
|
|
||||||
var response = await httpClient.GetAsync(ressource);
|
|
||||||
response.EnsureSuccessStatusCode();
|
|
||||||
var responseString = await response.Content.ReadAsStringAsync();
|
|
||||||
var employees = JsonConvert.DeserializeObject<List<Employee>>(responseString);
|
|
||||||
|
|
||||||
if (employees == null || !employees.Any())
|
|
||||||
return null;
|
|
||||||
else return employees;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logger?.LogError($"Exception Found : {ex.Message} - Ref: EmployeeServiceProvider.getEmployeesAsync()");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Employee> getEmployeeAsync(string employeeID)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
httpClient.BaseAddress = new Uri(urlBase);
|
|
||||||
//ressource = ressource + "/" + employeeID;
|
|
||||||
var response = await httpClient.GetAsync("/api/Employees/"+ employeeID);
|
|
||||||
response.EnsureSuccessStatusCode();
|
|
||||||
var responseString = await response.Content.ReadAsStringAsync();
|
|
||||||
var employee = JsonConvert.DeserializeObject<Employee>(responseString);
|
|
||||||
|
|
||||||
if (employee == null )
|
|
||||||
return null;
|
|
||||||
else return employee;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logger?.LogError($"Exception Found : {ex.Message} - Ref: EmployeeServiceProvider.getEmployeeAsync()");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
using System.IdentityModel.Tokens.Jwt;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
using DamageAssesment.Api.UsersAccess.Db;
|
|
||||||
using DamageAssesment.Api.UsersAccess.Interfaces;
|
|
||||||
using DamageAssesment.Api.UsersAccess.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
|
|
||||||
public class TokenServiceProvider : ITokenServiceProvider
|
|
||||||
{
|
|
||||||
private readonly UsersAccessDbContext usersAccessDbContext;
|
|
||||||
private readonly JwtSettings jwtSettings;
|
|
||||||
public TokenServiceProvider(IOptions<JwtSettings> options,UsersAccessDbContext usersAccessDbContext)
|
|
||||||
{
|
|
||||||
this.usersAccessDbContext = usersAccessDbContext;
|
|
||||||
this.jwtSettings = options.Value;
|
|
||||||
}
|
|
||||||
public async Task<string> GenerateToken(DamageAssesment.Api.UsersAccess.Models.User user)
|
|
||||||
{
|
|
||||||
var randomnumber = new byte[32];
|
|
||||||
using (var ramdomnumbergenerator = RandomNumberGenerator.Create())
|
|
||||||
{
|
|
||||||
ramdomnumbergenerator.GetBytes(randomnumber);
|
|
||||||
string refreshtoken = Convert.ToBase64String(randomnumber);
|
|
||||||
var token = await usersAccessDbContext.Tokens.FirstOrDefaultAsync(item => item.UserId == user.Id);
|
|
||||||
if (token != null)
|
|
||||||
{
|
|
||||||
token.RefreshToken = refreshtoken;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
usersAccessDbContext.Tokens.Add(new DamageAssesment.Api.UsersAccess.Db.Token()
|
|
||||||
{
|
|
||||||
Id = new Random().Next().ToString(),
|
|
||||||
UserId = user.Id,
|
|
||||||
RefreshToken = refreshtoken,
|
|
||||||
IsActive = true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
await usersAccessDbContext.SaveChangesAsync();
|
|
||||||
|
|
||||||
return refreshtoken;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<TokenResponse> TokenAuthenticate(DamageAssesment.Api.UsersAccess.Models.User user, Claim[] claims)
|
|
||||||
{
|
|
||||||
var token = new JwtSecurityToken(claims: claims, expires: DateTime.Now.AddSeconds(20),
|
|
||||||
signingCredentials: new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings.securitykey)), SecurityAlgorithms.HmacSha256)
|
|
||||||
);
|
|
||||||
var jwttoken = new JwtSecurityTokenHandler().WriteToken(token);
|
|
||||||
return new TokenResponse() { jwttoken = jwttoken, refreshtoken = await GenerateToken(user) };
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,341 +0,0 @@
|
|||||||
using AutoMapper;
|
|
||||||
using DamageAssesment.Api.UsersAccess.Db;
|
|
||||||
using DamageAssesment.Api.UsersAccess.Interfaces;
|
|
||||||
using DamageAssesment.Api.UsersAccess.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
using System.Data;
|
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Providers
|
|
||||||
{
|
|
||||||
public class UsersAccessProvider : IUsersAccessProvider
|
|
||||||
{
|
|
||||||
private readonly UsersAccessDbContext userAccessDbContext;
|
|
||||||
private readonly ILogger<UsersAccessProvider> logger;
|
|
||||||
private readonly IMapper mapper;
|
|
||||||
private readonly IEmployeeServiceProvider employeeServiceProvider;
|
|
||||||
private readonly JwtSettings jwtSettings;
|
|
||||||
private readonly ITokenServiceProvider tokenServiceProvider;
|
|
||||||
|
|
||||||
public UsersAccessProvider(IOptions<JwtSettings> options, ITokenServiceProvider tokenServiceProvider, UsersAccessDbContext userAccessDbContext, IEmployeeServiceProvider employeeServiceProvider, ILogger<UsersAccessProvider> logger, IMapper mapper)
|
|
||||||
{
|
|
||||||
this.userAccessDbContext = userAccessDbContext;
|
|
||||||
this.employeeServiceProvider = employeeServiceProvider;
|
|
||||||
this.logger = logger;
|
|
||||||
this.mapper = mapper;
|
|
||||||
jwtSettings = options.Value;
|
|
||||||
this.tokenServiceProvider = tokenServiceProvider;
|
|
||||||
seedData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void seedData()
|
|
||||||
{
|
|
||||||
if (!userAccessDbContext.Users.Any())
|
|
||||||
{
|
|
||||||
userAccessDbContext.Users.Add(new Db.User { Id = 1, EmployeeId = "Emp1", RoleId = 1 });
|
|
||||||
userAccessDbContext.Users.Add(new Db.User { Id = 2, EmployeeId = "Emp2", RoleId = 2 });
|
|
||||||
userAccessDbContext.Users.Add(new Db.User { Id = 3, EmployeeId = "Emp3", RoleId = 3 });
|
|
||||||
userAccessDbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!userAccessDbContext.Roles.Any())
|
|
||||||
{
|
|
||||||
userAccessDbContext.Roles.Add(new Db.Role { Id = 1, Name = "admin" });
|
|
||||||
userAccessDbContext.Roles.Add(new Db.Role { Id = 2, Name = "user" });
|
|
||||||
userAccessDbContext.Roles.Add(new Db.Role { Id = 3, Name = "survey" });
|
|
||||||
userAccessDbContext.Roles.Add(new Db.Role { Id = 4, Name = "report" });
|
|
||||||
userAccessDbContext.Roles.Add(new Db.Role { Id = 5, Name = "document" });
|
|
||||||
userAccessDbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, IEnumerable<Models.User> Users, string ErrorMessage)> GetUsersAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
logger?.LogInformation("Gell all Users from DB");
|
|
||||||
var users = await userAccessDbContext.Users.ToListAsync();
|
|
||||||
if (users != null)
|
|
||||||
{
|
|
||||||
logger?.LogInformation($"{users.Count} Items(s) found");
|
|
||||||
var result = mapper.Map<IEnumerable<Db.User>, IEnumerable<Models.User>>(users);
|
|
||||||
return (true, result, null);
|
|
||||||
}
|
|
||||||
return (false, null, "Not found");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logger?.LogError(ex.ToString());
|
|
||||||
return (false, null, ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, Models.User User, string ErrorMessage)> GetUsersAsync(int Id)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
logger?.LogInformation("Querying Users table");
|
|
||||||
var user = await userAccessDbContext.Users.SingleOrDefaultAsync(s => s.Id == Id);
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
logger?.LogInformation($"User Id: {Id} found");
|
|
||||||
var result = mapper.Map<Db.User, Models.User>(user);
|
|
||||||
return (true, result, null);
|
|
||||||
}
|
|
||||||
return (false, null, "Not found");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logger?.LogError(ex.ToString());
|
|
||||||
return (false, null, ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, Models.User User, string ErrorMessage)> PostUserAsync(Models.User user)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
var users = await userAccessDbContext.Users.ToListAsync();
|
|
||||||
int count = users.Where(u => u.EmployeeId == user.EmployeeId).Count();
|
|
||||||
if (count == 0)
|
|
||||||
{
|
|
||||||
user.Id = users.Count + 1;
|
|
||||||
userAccessDbContext.Users.Add(mapper.Map<Models.User, Db.User>(user));
|
|
||||||
await userAccessDbContext.SaveChangesAsync();
|
|
||||||
return (true, user, "Successful");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger?.LogInformation($"Employee Id: {user.EmployeeId} is already exist");
|
|
||||||
return (false, null, $"Employee Id: {user.EmployeeId} is already exist");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger?.LogInformation($"Employee Id: {user.EmployeeId} cannot be added");
|
|
||||||
return (false, null, $"Employee Id: {user.EmployeeId} cannot be added");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logger?.LogError(ex.ToString());
|
|
||||||
return (false, null, ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, Models.User User, string ErrorMessage)> PutUserAsync(int Id, Models.User user)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
var _user = await userAccessDbContext.Users.Where(s => s.Id == Id).SingleOrDefaultAsync();
|
|
||||||
|
|
||||||
if (_user != null)
|
|
||||||
{
|
|
||||||
int count = userAccessDbContext.Users.Where(u => u.Id != user.Id && u.EmployeeId == user.EmployeeId).Count();
|
|
||||||
if (count == 0)
|
|
||||||
{
|
|
||||||
_user.EmployeeId = user.EmployeeId;
|
|
||||||
_user.RoleId = user.RoleId;
|
|
||||||
_user.IsActive = user.IsActive;
|
|
||||||
_user.UpdateDate = DateTime.Now;
|
|
||||||
await userAccessDbContext.SaveChangesAsync();
|
|
||||||
|
|
||||||
|
|
||||||
logger?.LogInformation($"Employee Id: {user.EmployeeId} updated successfuly");
|
|
||||||
return (true, mapper.Map<Db.User, Models.User>(_user), $"Employee Id: {_user.EmployeeId} updated successfuly");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger?.LogInformation($"Employee Id: {user.EmployeeId} is already exist");
|
|
||||||
return (false, null, $"Employee Id: {user.EmployeeId} is already exist");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger?.LogInformation($"User Id : {Id} Not found");
|
|
||||||
return (false, null, "Not Found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger?.LogInformation($"User Id: {Id} Bad Request");
|
|
||||||
return (false, null, "Bad request");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logger?.LogError(ex.ToString());
|
|
||||||
return (false, null, ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, Models.User User, string ErrorMessage)> DeleteUserAsync(int Id)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var user = await userAccessDbContext.Users.Where(x => x.Id == Id).SingleOrDefaultAsync();
|
|
||||||
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
userAccessDbContext.Users.Remove(user);
|
|
||||||
await userAccessDbContext.SaveChangesAsync();
|
|
||||||
logger?.LogInformation($"User Id: {Id} deleted Successfuly");
|
|
||||||
return (true, mapper.Map<Db.User, Models.User>(user), $"User Id: {Id} deleted Successfuly");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger?.LogInformation($"User Id : {Id} Not found");
|
|
||||||
return (false, null, "Not Found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logger?.LogError(ex.ToString());
|
|
||||||
return (false, null, ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, TokenResponse TokenResponse, string ErrorMessage)> AuthenticateAsync(UserCredentials userCredentials)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (userCredentials != null)
|
|
||||||
{
|
|
||||||
//implementation for dadeschools authentication
|
|
||||||
|
|
||||||
var employee = await employeeServiceProvider.getEmployeeAsync(userCredentials.username);
|
|
||||||
|
|
||||||
if (employee != null)
|
|
||||||
{
|
|
||||||
var result = await GetUsersAsync();
|
|
||||||
|
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
|
||||||
var user = result.Users.Where(x => x.IsActive == true && x.EmployeeId.ToLower().Equals(userCredentials.username.ToLower())).SingleOrDefault();
|
|
||||||
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
|
|
||||||
var r = await GetRolesAsync();
|
|
||||||
var role = r.Roles.Where(x => x.Id == user.RoleId).SingleOrDefault();
|
|
||||||
|
|
||||||
var authClaims = new List<Claim> {
|
|
||||||
new Claim(ClaimTypes.Name, user.EmployeeId),
|
|
||||||
new Claim(ClaimTypes.Role, role.Name),
|
|
||||||
new Claim(JwtRegisteredClaimNames.Jti,Guid.NewGuid().ToString())
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Generate Token
|
|
||||||
var tokenhandler = new JwtSecurityTokenHandler();
|
|
||||||
var tokenkey = Encoding.UTF8.GetBytes(jwtSettings.securitykey);
|
|
||||||
var tokendesc = new SecurityTokenDescriptor
|
|
||||||
{
|
|
||||||
Audience = "",
|
|
||||||
NotBefore = DateTime.Now,
|
|
||||||
Subject = new ClaimsIdentity(authClaims),
|
|
||||||
Expires = DateTime.Now.AddMinutes(30),
|
|
||||||
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(tokenkey), SecurityAlgorithms.HmacSha256)
|
|
||||||
};
|
|
||||||
var token = tokenhandler.CreateToken(tokendesc);
|
|
||||||
string finaltoken = tokenhandler.WriteToken(token);
|
|
||||||
|
|
||||||
var response = new TokenResponse() { jwttoken = finaltoken, refreshtoken = await tokenServiceProvider.GenerateToken(user) };
|
|
||||||
|
|
||||||
|
|
||||||
return (true, response, "Authentication success and token issued.");
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (false, null, "user inactive or not exist.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (false, null, "users list empty.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (false, null, "Employee not exist.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (false, null, "Credentials are required to authenticate.");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public async Task<(bool IsSuccess, IEnumerable<Models.Role> Roles, string ErrorMessage)> GetRolesAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
logger?.LogInformation("Gell all Roles from DB");
|
|
||||||
var roles = await userAccessDbContext.Roles.ToListAsync();
|
|
||||||
if (roles != null)
|
|
||||||
{
|
|
||||||
logger?.LogInformation($"{roles.Count} Items(s) found");
|
|
||||||
var result = mapper.Map<IEnumerable<Db.Role>, IEnumerable<Models.Role>>(roles);
|
|
||||||
return (true, result, null);
|
|
||||||
}
|
|
||||||
return (false, null, "Not found");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
logger?.LogError(ex.ToString());
|
|
||||||
return (false, null, ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<(bool IsSuccess, Models.TokenResponse TokenResponse, string ErrorMessage)> RefreshTokenAsync(TokenResponse tokenResponse)
|
|
||||||
{
|
|
||||||
//Generate token
|
|
||||||
var tokenhandler = new JwtSecurityTokenHandler();
|
|
||||||
var tokenkey = Encoding.UTF8.GetBytes(this.jwtSettings.securitykey);
|
|
||||||
SecurityToken securityToken;
|
|
||||||
var principal = tokenhandler.ValidateToken(tokenResponse.jwttoken, new TokenValidationParameters
|
|
||||||
{
|
|
||||||
ValidateIssuerSigningKey = true,
|
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(tokenkey),
|
|
||||||
ValidateIssuer = false,
|
|
||||||
ValidateAudience = false,
|
|
||||||
|
|
||||||
}, out securityToken);
|
|
||||||
|
|
||||||
var token = securityToken as JwtSecurityToken;
|
|
||||||
if (token != null && !token.Header.Alg.Equals(SecurityAlgorithms.HmacSha256))
|
|
||||||
{
|
|
||||||
return (false, null, "Unauthorized");
|
|
||||||
}
|
|
||||||
var username = principal.Identity?.Name;
|
|
||||||
|
|
||||||
var tokens = await userAccessDbContext.Tokens.ToListAsync();
|
|
||||||
var users = await userAccessDbContext.Users.ToListAsync();
|
|
||||||
|
|
||||||
var user = (from u in users
|
|
||||||
join t in tokens
|
|
||||||
on u.Id equals t.UserId
|
|
||||||
where u.EmployeeId == username
|
|
||||||
&& t.RefreshToken == tokenResponse.refreshtoken
|
|
||||||
select u).FirstOrDefault();
|
|
||||||
|
|
||||||
if (user == null)
|
|
||||||
return (false, null, "Invalid Token Response object provided");
|
|
||||||
|
|
||||||
var _user = mapper.Map<Db.User, Models.User>(user);
|
|
||||||
var response = tokenServiceProvider.TokenAuthenticate(_user, principal.Claims.ToArray()).Result;
|
|
||||||
return (true, response, "Token authenticated and refreshed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"JwtSettings": {
|
|
||||||
"securitykey": "bWlhbWkgZGFkZSBzY2hvb2xzIHNlY3JldCBrZXk="
|
|
||||||
},
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"EndPointSettings": {
|
|
||||||
"EmployeeUrlBase": "http://localhost:5135"
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*"
|
|
||||||
}
|
|
@ -9,13 +9,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Answers
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Attachments", "DamageAssesment.Api.Attachments\DamageAssesment.Api.Attachments.csproj", "{FF619F3A-D1BB-4934-A0E1-6EF7D0DAACD6}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Attachments", "DamageAssesment.Api.Attachments\DamageAssesment.Api.Attachments.csproj", "{FF619F3A-D1BB-4934-A0E1-6EF7D0DAACD6}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4CB40DC2-D9D2-4384-A7A6-9968F5C777A2}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
ReadMe.txt = ReadMe.txt
|
||||||
|
ReadMe4Dev.txt = ReadMe4Dev.txt
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Locations", "DamageAssesment.Api.Locations\DamageAssesment.Api.Locations.csproj", "{746C67BF-9949-4361-B5D2-358C7607750E}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Locations", "DamageAssesment.Api.Locations\DamageAssesment.Api.Locations.csproj", "{746C67BF-9949-4361-B5D2-358C7607750E}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.SurveyResponses", "DamageAssesment.Api.SurveyResponses\DamageAssesment.Api.SurveyResponses.csproj", "{D11808FE-AD1C-4BA6-87FD-9D18B2DC81F2}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.SurveyResponses", "DamageAssesment.Api.SurveyResponses\DamageAssesment.Api.SurveyResponses.csproj", "{D11808FE-AD1C-4BA6-87FD-9D18B2DC81F2}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Questions.Test", "DamageAssesment.Api.QuestionsTest\DamageAssesment.Api.Questions.Test.csproj", "{35CD9231-034D-4999-BCFC-1786DD007ED2}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Questions.Test", "DamageAssesment.Api.QuestionsTest\DamageAssesment.Api.Questions.Test.csproj", "{35CD9231-034D-4999-BCFC-1786DD007ED2}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Surveys.Test", "DamageAssesment.Api.Surveys.Test\DamageAssesment.Api.Surveys.Test.csproj", "{ADFB79E3-83C9-454F-A070-49D167BD28CC}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Survey.Test", "DamageAssesment.Api.Surveys.Test\DamageAssesment.Api.Survey.Test.csproj", "{ADFB79E3-83C9-454F-A070-49D167BD28CC}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.SurveyResponses.Test", "DamageAssesment.SurveyResponses.Test\DamageAssesment.Api.SurveyResponses.Test.csproj", "{6F4B9C9D-CE5D-421A-876F-57D0FEDF8049}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.SurveyResponses.Test", "DamageAssesment.SurveyResponses.Test\DamageAssesment.Api.SurveyResponses.Test.csproj", "{6F4B9C9D-CE5D-421A-876F-57D0FEDF8049}"
|
||||||
EndProject
|
EndProject
|
||||||
@ -23,7 +29,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Attachm
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Locations.Test", "DamageAssesment.Api.Locations.Test\DamageAssesment.Api.Locations.Test.csproj", "{DA68AE47-6825-41ED-9107-5151822FB083}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Locations.Test", "DamageAssesment.Api.Locations.Test\DamageAssesment.Api.Locations.Test.csproj", "{DA68AE47-6825-41ED-9107-5151822FB083}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Surveys", "DamageAssesment.Api.Surveys\DamageAssesment.Api.Surveys.csproj", "{55481AED-6801-47DB-A176-A6FA92002081}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Survey", "DamageAssesment.Api.Surveys\DamageAssesment.Api.Survey.csproj", "{55481AED-6801-47DB-A176-A6FA92002081}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Answers.Test", "DamageAssesment.Api.Answers.Test\DamageAssesment.Api.Answers.Test.csproj", "{594A47AC-DF50-47E5-903D-A856CADDF573}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Answers.Test", "DamageAssesment.Api.Answers.Test\DamageAssesment.Api.Answers.Test.csproj", "{594A47AC-DF50-47E5-903D-A856CADDF573}"
|
||||||
EndProject
|
EndProject
|
||||||
@ -31,7 +37,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Employe
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Employees.Test", "DamageAssesment.Api.Employees.Test\DamageAssesment.Api.Employees.Test.csproj", "{D6BF9AE9-72FA-4726-A326-35A35D27FFB8}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Employees.Test", "DamageAssesment.Api.Employees.Test\DamageAssesment.Api.Employees.Test.csproj", "{D6BF9AE9-72FA-4726-A326-35A35D27FFB8}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{E305D5CD-E635-4268-9F74-D3FBE0DF16C8}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DamageAssesment.Api.Documents", "DamageAssesment.Api.Documents\DamageAssesment.Api.Documents.csproj", "{977C1053-9D63-4153-B61B-C3D2F1010F9F}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DamageAssesment.Api.Documents.Test", "DamageAssesment.Api.Documents.Test\DamageAssesment.Api.Documents.Test.csproj", "{884BA4AC-9170-49B1-BD6B-850B350C95C0}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -95,10 +103,14 @@ Global
|
|||||||
{D6BF9AE9-72FA-4726-A326-35A35D27FFB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{D6BF9AE9-72FA-4726-A326-35A35D27FFB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{D6BF9AE9-72FA-4726-A326-35A35D27FFB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{D6BF9AE9-72FA-4726-A326-35A35D27FFB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{D6BF9AE9-72FA-4726-A326-35A35D27FFB8}.Release|Any CPU.Build.0 = Release|Any CPU
|
{D6BF9AE9-72FA-4726-A326-35A35D27FFB8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{E305D5CD-E635-4268-9F74-D3FBE0DF16C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{977C1053-9D63-4153-B61B-C3D2F1010F9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{E305D5CD-E635-4268-9F74-D3FBE0DF16C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{977C1053-9D63-4153-B61B-C3D2F1010F9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E305D5CD-E635-4268-9F74-D3FBE0DF16C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{977C1053-9D63-4153-B61B-C3D2F1010F9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E305D5CD-E635-4268-9F74-D3FBE0DF16C8}.Release|Any CPU.Build.0 = Release|Any CPU
|
{977C1053-9D63-4153-B61B-C3D2F1010F9F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{884BA4AC-9170-49B1-BD6B-850B350C95C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{884BA4AC-9170-49B1-BD6B-850B350C95C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{884BA4AC-9170-49B1-BD6B-850B350C95C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{884BA4AC-9170-49B1-BD6B-850B350C95C0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
server {
|
|
||||||
|
|
||||||
listen 80;
|
|
||||||
server_name dev-services.damageasessment.net;
|
|
||||||
|
|
||||||
location /service1 {
|
|
||||||
|
|
||||||
rewrite /service1/(.*) /$1 break;
|
|
||||||
proxy_pass http://172.17.0.1:80/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
location /service2 {
|
|
||||||
|
|
||||||
rewrite /service2/(.*) /$1 break;
|
|
||||||
proxy_pass http://172.17.0.1:80/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
location /service3 {
|
|
||||||
|
|
||||||
rewrite /service3/(.*) /$1 break;
|
|
||||||
proxy_pass http://172.17.0.1:80/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
location /service4 {
|
|
||||||
|
|
||||||
rewrite /service4/(.*) /$1 break;
|
|
||||||
proxy_pass http://172.17.0.1:80/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
location /service5 {
|
|
||||||
|
|
||||||
rewrite /service5/(.*) /$1 break;
|
|
||||||
proxy_pass http://172.17.0.1:80/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
location /service6 {
|
|
||||||
|
|
||||||
rewrite /service6/(.*) /$1 break;
|
|
||||||
proxy_pass http://172.17.0.1:80/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
location /service7 {
|
|
||||||
|
|
||||||
rewrite /service7/(.*) /$1 break;
|
|
||||||
proxy_pass http://172.17.0.1:80/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
server {
|
|
||||||
|
|
||||||
listen 80 default_server;
|
|
||||||
# server_name _;
|
|
||||||
root /var/www/html;
|
|
||||||
|
|
||||||
# Add index.php to the list if you are using PHP
|
|
||||||
# index index.html index.htm index.nginx-debian.html;
|
|
||||||
|
|
||||||
location /service1 {
|
|
||||||
|
|
||||||
rewrite /service1/(.*) /$1 break;
|
|
||||||
proxy_pass http://127.0.0.1:6001/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
location /service2 {
|
|
||||||
|
|
||||||
rewrite /service2/(.*) /$1 break;
|
|
||||||
proxy_pass http://127.0.0.1:6002/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
location /service3 {
|
|
||||||
|
|
||||||
rewrite /service3/(.*) /$1 break;
|
|
||||||
proxy_pass http://127.0.0.1:6003/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
location /service4 {
|
|
||||||
|
|
||||||
rewrite /service4/(.*) /$1 break;
|
|
||||||
proxy_pass http://127.0.0.1:6004/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
location /service5 {
|
|
||||||
|
|
||||||
rewrite /service5/(.*) /$1 break;
|
|
||||||
proxy_pass http://127.0.0.1:6005/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
location /service6 {
|
|
||||||
|
|
||||||
rewrite /service6/(.*) /$1 break;
|
|
||||||
proxy_pass http://127.0.0.1:6006/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
location /service7 {
|
|
||||||
|
|
||||||
rewrite /service7/(.*) /$1 break;
|
|
||||||
proxy_pass http://127.0.0.1:6007/; # Replace with the address of your .NET Core application
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectVersion>2.1</ProjectVersion>
|
|
||||||
<DockerTargetOS>Linux</DockerTargetOS>
|
|
||||||
<ProjectGuid>e305d5cd-e635-4268-9f74-d3fbe0df16c8</ProjectGuid>
|
|
||||||
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
|
|
||||||
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/swagger</DockerServiceUrl>
|
|
||||||
<DockerServiceName>damageassesment.api.surveys</DockerServiceName>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="docker-compose.override.yml">
|
|
||||||
<DependentUpon>docker-compose.yml</DependentUpon>
|
|
||||||
</None>
|
|
||||||
<None Include="docker-compose.yml" />
|
|
||||||
<None Include=".dockerignore" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
@ -1,82 +0,0 @@
|
|||||||
version: '3.4'
|
|
||||||
|
|
||||||
services:
|
|
||||||
#nginx:
|
|
||||||
# container_name: my-nginx
|
|
||||||
# image: nginx:latest
|
|
||||||
# restart: always
|
|
||||||
# ports:
|
|
||||||
# - "80:80"
|
|
||||||
# volumes:
|
|
||||||
# - ./default.conf:/etc/nginx/conf.d/default.conf
|
|
||||||
|
|
||||||
damageassesment.api.answers:
|
|
||||||
environment:
|
|
||||||
- ASPNETCORE_ENVIRONMENT=Development
|
|
||||||
networks:
|
|
||||||
nginx-network:
|
|
||||||
ipv4_address: 172.18.0.150
|
|
||||||
ports:
|
|
||||||
- "6001:80"
|
|
||||||
|
|
||||||
|
|
||||||
damageassesment.api.attachments:
|
|
||||||
environment:
|
|
||||||
- ASPNETCORE_ENVIRONMENT=Development
|
|
||||||
networks:
|
|
||||||
nginx-network:
|
|
||||||
ipv4_address: 172.18.0.151
|
|
||||||
ports:
|
|
||||||
- "6002:80"
|
|
||||||
|
|
||||||
|
|
||||||
damageassesment.api.employees:
|
|
||||||
environment:
|
|
||||||
- ASPNETCORE_ENVIRONMENT=Development
|
|
||||||
networks:
|
|
||||||
nginx-network:
|
|
||||||
ipv4_address: 172.18.0.152
|
|
||||||
ports:
|
|
||||||
- "6003:80"
|
|
||||||
|
|
||||||
damageassesment.api.locations:
|
|
||||||
environment:
|
|
||||||
- ASPNETCORE_ENVIRONMENT=Development
|
|
||||||
networks:
|
|
||||||
nginx-network:
|
|
||||||
ipv4_address: 172.18.0.153
|
|
||||||
ports:
|
|
||||||
- "6004:80"
|
|
||||||
|
|
||||||
damageassesment.api.questions:
|
|
||||||
environment:
|
|
||||||
- ASPNETCORE_ENVIRONMENT=Development
|
|
||||||
networks:
|
|
||||||
nginx-network:
|
|
||||||
ipv4_address: 172.18.0.154
|
|
||||||
ports:
|
|
||||||
- "6005:80"
|
|
||||||
|
|
||||||
damageassesment.api.survey:
|
|
||||||
environment:
|
|
||||||
- ASPNETCORE_ENVIRONMENT=Development
|
|
||||||
networks:
|
|
||||||
nginx-network:
|
|
||||||
ipv4_address: 172.18.0.155
|
|
||||||
ports:
|
|
||||||
- "6006:80"
|
|
||||||
|
|
||||||
damageassesment.api.surveyresponses:
|
|
||||||
environment:
|
|
||||||
- ASPNETCORE_ENVIRONMENT=Development
|
|
||||||
- services__Answers=http://damageassesment.api.answers:80
|
|
||||||
- services__Locations=http://damageassesment.api.locations:80
|
|
||||||
- services__Questions=http://damageassesment.api.questions:80
|
|
||||||
- services__Employees=http://damageassesment.api.employees:80
|
|
||||||
- services__Attachments=http://damageassesment.api.attachments:80
|
|
||||||
- services__Surveys=http://damageassesment.api.survey:80
|
|
||||||
networks:
|
|
||||||
nginx-network:
|
|
||||||
ipv4_address: 172.18.0.156
|
|
||||||
ports:
|
|
||||||
- "6007:80"
|
|
@ -1,8 +0,0 @@
|
|||||||
version: '3.4'
|
|
||||||
|
|
||||||
services:
|
|
||||||
damageassesment.api.surveys:
|
|
||||||
image: ${DOCKER_REGISTRY-}damageassesmentapisurveys
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: DamageAssesment.Api.Surveys/Dockerfile
|
|
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"profiles": {
|
|
||||||
"Docker Compose": {
|
|
||||||
"commandName": "DockerCompose",
|
|
||||||
"commandVersion": "1.0",
|
|
||||||
"serviceActions": {
|
|
||||||
"damageassesment.api.answers": "StartDebugging",
|
|
||||||
"damageassesment.api.attachments": "StartDebugging",
|
|
||||||
"damageassesment.api.employees": "StartDebugging",
|
|
||||||
"damageassesment.api.locations": "StartDebugging",
|
|
||||||
"damageassesment.api.questions": "StartDebugging",
|
|
||||||
"damageassesment.api.survey": "StartDebugging",
|
|
||||||
"damageassesment.api.surveyresponses": "StartDebugging",
|
|
||||||
"damageassesment.api.surveys": "StartDebugging"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user