forked from MDCPS/DamageAssessment_Backend
Compare commits
41 Commits
user-acces
...
user-acces
Author | SHA1 | Date | |
---|---|---|---|
59f547d49d | |||
09fcae68a4 | |||
5e5f8068d8 | |||
e96e1812cc | |||
cf68398a56 | |||
b355109391 | |||
deb9a823f0 | |||
da51cc1a1e | |||
84bdb1249f | |||
6505c504d1 | |||
fb5355ddcd | |||
cd982d160a | |||
9b88029a09 | |||
3b9e13ad35 | |||
dca119758a | |||
8285588db9 | |||
fc166e65c9 | |||
ae6b306290 | |||
d3a751a6ad | |||
e2bed66428 | |||
8624eeeb97 | |||
16d45d6632 | |||
c77e0452c4 | |||
8e0a7df68b | |||
01ccd97528 | |||
26b360e0a9 | |||
360a58c026 | |||
11c6fc0dc9 | |||
99633d8dda | |||
8e3f6674c6 | |||
14956057cd | |||
340ba6fa6d | |||
46794057c4 | |||
643bc0c76a | |||
d0023114a3 | |||
465bf4b081 | |||
e04bccfffd | |||
0544c7397d | |||
9c536a1c52 | |||
48be1a74c9 | |||
eb07c31ff6 |
BIN
.vs/Backend-API-Services/v17/.wsuo
Normal file
BIN
.vs/Backend-API-Services/v17/.wsuo
Normal file
Binary file not shown.
7
.vs/VSWorkspaceState.json
Normal file
7
.vs/VSWorkspaceState.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ExpandedNodes": [
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"SelectedNode": "\\DamageAssesment.sln",
|
||||||
|
"PreviewInSolutionExplorer": false
|
||||||
|
}
|
25
DamageAssesmentApi/.dockerignore
Normal file
25
DamageAssesmentApi/.dockerignore
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
**/.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
|
1
DamageAssesmentApi/.gitignore
vendored
1
DamageAssesmentApi/.gitignore
vendored
@ -396,3 +396,4 @@ FodyWeavers.xsd
|
|||||||
|
|
||||||
# JetBrains Rider
|
# JetBrains Rider
|
||||||
*.sln.iml
|
*.sln.iml
|
||||||
|
**/migrations/
|
@ -1,17 +1,25 @@
|
|||||||
<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>
|
||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||||
<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.Design" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.9" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
namespace DamageAssesment.Api.Answers.Db
|
namespace DamageAssesment.Api.Answers.Db
|
||||||
{
|
{
|
||||||
public class AnswerDbContext:DbContext
|
public class AnswerDbContext:DbContext
|
||||||
{
|
{
|
||||||
|
private IConfiguration _Configuration { get; set; }
|
||||||
public AnswerDbContext(DbContextOptions options):base(options)
|
public AnswerDbContext(DbContextOptions options,IConfiguration configuration):base(options)
|
||||||
{
|
{
|
||||||
|
_Configuration= configuration;
|
||||||
|
}
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
|
{
|
||||||
|
// connect to sql server with connection string from app settings
|
||||||
|
options.UseSqlServer(_Configuration.GetConnectionString("AnswerConnection"));
|
||||||
}
|
}
|
||||||
public DbSet<Db.Answer> Answers { get; set; }
|
public DbSet<Db.Answer> Answers { get; set; }
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
21
DamageAssesmentApi/DamageAssesment.Api.Answers/Dockerfile
Normal file
21
DamageAssesmentApi/DamageAssesment.Api.Answers/Dockerfile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#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.
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["DamageAssesment.Api.Answers/DamageAssesment.Api.Answers.csproj", "DamageAssesment.Api.Answers/"]
|
||||||
|
RUN dotnet restore "DamageAssesment.Api.Answers/DamageAssesment.Api.Answers.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/DamageAssesment.Api.Answers"
|
||||||
|
RUN dotnet build "DamageAssesment.Api.Answers.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "DamageAssesment.Api.Answers.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Answers.dll"]
|
@ -73,7 +73,7 @@ builder.Services.AddScoped<IAnswersProvider, AnswersProvider>();
|
|||||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
|
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
|
||||||
builder.Services.AddDbContext<AnswerDbContext>(option =>
|
builder.Services.AddDbContext<AnswerDbContext>(option =>
|
||||||
{
|
{
|
||||||
option.UseInMemoryDatabase("Answers");
|
option.UseSqlServer("AnswerConnection");
|
||||||
});
|
});
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
@ -1,23 +1,14 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:18005",
|
|
||||||
"sslPort": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"DamageAssesment.Api.Answers": {
|
"DamageAssesment.Api.Answers": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "http://localhost:5200",
|
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
},
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"applicationUrl": "http://localhost:5200"
|
||||||
},
|
},
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
@ -26,6 +17,24 @@
|
|||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Docker": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_URLS": "http://+:80"
|
||||||
|
},
|
||||||
|
"publishAllPorts": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:18005",
|
||||||
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -198,13 +198,12 @@ namespace DamageAssesment.Api.Answers.Providers
|
|||||||
{
|
{
|
||||||
if (!answerDbContext.Answers.Any())
|
if (!answerDbContext.Answers.Any())
|
||||||
{
|
{
|
||||||
answerDbContext.Answers.Add(new Db.Answer() { Id = 1, AnswerText = "Yes", Comment = "Comment test 4", QuestionId = 1, SurveyResponseId = 1 });
|
answerDbContext.Answers.Add(new Db.Answer() { AnswerText = "Yes", Comment = "", QuestionId = 1, SurveyResponseId = 1 });
|
||||||
answerDbContext.Answers.Add(new Db.Answer() { Id = 2, AnswerText = "No", Comment = "Comment test 5", QuestionId = 2, SurveyResponseId = 1 });
|
answerDbContext.Answers.Add(new Db.Answer() { AnswerText = "No", Comment = "myComment", QuestionId = 2, SurveyResponseId = 1 });
|
||||||
// Uncomment the lines below to add more initial data if needed
|
//answerDbContext.Answers.Add(new Db.Answer() { AnswerText = "No", Comment = "No Comment", QuestionId = 3, SurveyResponseId = 1 });
|
||||||
//answerDbContext.Answers.Add(new Db.Answer() { Id = 3, AnswerText = "No", Comment = "No Comment", QuestionId = 3, SurveyResponseId = 1 });
|
//answerDbContext.Answers.Add(new Db.Answer() { AnswerText = "Yes", Comment = "No Comment", QuestionId = 1, SurveyResponseId = 2 });
|
||||||
//answerDbContext.Answers.Add(new Db.Answer() { Id = 4, AnswerText = "Yes", Comment = "No Comment", QuestionId = 1, SurveyResponseId = 2 });
|
//answerDbContext.Answers.Add(new Db.Answer() { AnswerText = "No", Comment = "No Comment", QuestionId = 2, SurveyResponseId = 2 });
|
||||||
//answerDbContext.Answers.Add(new Db.Answer() { Id = 5, AnswerText = "No", Comment = "No Comment", QuestionId = 2, SurveyResponseId = 2 });
|
//answerDbContext.Answers.Add(new Db.Answer() { AnswerText = "No", Comment = "No Comment", QuestionId = 3, SurveyResponseId = 2 });
|
||||||
//answerDbContext.Answers.Add(new Db.Answer() { Id = 6, AnswerText = "No", Comment = "No Comment", QuestionId = 3, SurveyResponseId = 2 });
|
|
||||||
answerDbContext.SaveChanges();
|
answerDbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,10 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"ConnectionStrings": {
|
||||||
|
//"AnswerConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
|
||||||
|
"AnswerConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,12 @@ namespace DamageAssesment.Api.Attachments.Controllers
|
|||||||
{
|
{
|
||||||
private IAttachmentsProvider AttachmentProvider;
|
private IAttachmentsProvider AttachmentProvider;
|
||||||
private IUploadService UploadService;
|
private IUploadService UploadService;
|
||||||
|
private IAzureBlobService azureBlobService;
|
||||||
|
|
||||||
public AttachmentsController(IAttachmentsProvider AttachmentsProvider, IUploadService uploadService)
|
public AttachmentsController(IAttachmentsProvider AttachmentsProvider, IUploadService UploadService)
|
||||||
{
|
{
|
||||||
this.AttachmentProvider = AttachmentsProvider;
|
this.AttachmentProvider = AttachmentsProvider;
|
||||||
this.UploadService = uploadService;
|
this.UploadService = UploadService;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get all attachments.
|
/// Get all attachments.
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
<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>
|
||||||
@ -12,8 +14,20 @@
|
|||||||
<PackageReference Include="Azure.Storage.Blobs" Version="12.16.0" />
|
<PackageReference Include="Azure.Storage.Blobs" Version="12.16.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
||||||
<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.9" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.1.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
namespace DamageAssesment.Api.Attachments.Db
|
namespace DamageAssesment.Api.Attachments.Db
|
||||||
{
|
{
|
||||||
public class AttachmentsDbContext:DbContext
|
public class AttachmentsDbContext:DbContext
|
||||||
{
|
{
|
||||||
public AttachmentsDbContext(DbContextOptions options) : base(options)
|
private IConfiguration _Configuration { get; set; }
|
||||||
|
public AttachmentsDbContext(DbContextOptions options, IConfiguration configuration) : base(options)
|
||||||
{
|
{
|
||||||
|
_Configuration = configuration;
|
||||||
|
}
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
|
{
|
||||||
|
// connect to sql server with connection string from app settings
|
||||||
|
options.UseSqlServer(_Configuration.GetConnectionString("AttachmentConnection"));
|
||||||
}
|
}
|
||||||
public DbSet<Db.Attachment> Attachments { get; set; }
|
public DbSet<Db.Attachment> Attachments { get; set; }
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
#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.
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj", "DamageAssesment.Api.Attachments/"]
|
||||||
|
RUN dotnet restore "DamageAssesment.Api.Attachments/DamageAssesment.Api.Attachments.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/DamageAssesment.Api.Attachments"
|
||||||
|
RUN dotnet build "DamageAssesment.Api.Attachments.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "DamageAssesment.Api.Attachments.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
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
|
||||||
|
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Attachments.dll"]
|
@ -1,10 +1,15 @@
|
|||||||
using Azure.Storage.Blobs.Models;
|
using Azure.Storage.Blobs.Models;
|
||||||
|
using DamageAssesment.Api.Attachments.Models;
|
||||||
|
|
||||||
namespace DamageAssesment.Api.Attachments.Interfaces
|
namespace DamageAssesment.Api.Attachments.Interfaces
|
||||||
{
|
{
|
||||||
public interface IAzureBlobService
|
public interface IAzureBlobService
|
||||||
{
|
{
|
||||||
Task<List<Azure.Response<BlobContentInfo>>> UploadFiles(List<IFormFile> files);
|
Task<List<Azure.Response<BlobContentInfo>>> UploadFiles(List<IFormFile> files);
|
||||||
void DeleteFile(string path);
|
Task<List<Attachment>> UploadAttachment(int responseId, int answerId, int counter, List<IFormFile> postedFile);
|
||||||
|
Task<List<Attachment>> UploadAttachment(int responseId, int counter, List<AnswerInfo> answers);
|
||||||
|
Task<List<Attachment>> UpdateAttachments(int responseId, List<AnswerInfo> answers, IEnumerable<Models.Attachment> attachments);
|
||||||
|
void Deletefile(string path);
|
||||||
|
void Movefile(string path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ builder.Services.AddScoped<IAzureBlobService,AzureBlobService>();
|
|||||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
|
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
|
||||||
builder.Services.AddDbContext<AttachmentsDbContext>(option =>
|
builder.Services.AddDbContext<AttachmentsDbContext>(option =>
|
||||||
{
|
{
|
||||||
option.UseInMemoryDatabase("Attachments");
|
option.UseSqlServer("AttachmentConnection");
|
||||||
});
|
});
|
||||||
builder.Services.Configure<FormOptions>(o =>
|
builder.Services.Configure<FormOptions>(o =>
|
||||||
{
|
{
|
||||||
|
@ -1,23 +1,14 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:65305",
|
|
||||||
"sslPort": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"DamageAssesment.Api.Attachments": {
|
"DamageAssesment.Api.Attachments": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "http://localhost:5243",
|
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
},
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"applicationUrl": "http://localhost:5243"
|
||||||
},
|
},
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
@ -26,6 +17,24 @@
|
|||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Docker": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_URLS": "http://+:80"
|
||||||
|
},
|
||||||
|
"publishAllPorts": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:65305",
|
||||||
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ namespace DamageAssesment.Api.Attachments.Providers
|
|||||||
this.httpContextAccessor = httpContextAccessor;
|
this.httpContextAccessor = httpContextAccessor;
|
||||||
baseUrl = $"{httpContextAccessor.HttpContext.Request.Scheme}://{httpContextAccessor.HttpContext.Request.Host}";
|
baseUrl = $"{httpContextAccessor.HttpContext.Request.Scheme}://{httpContextAccessor.HttpContext.Request.Host}";
|
||||||
baseUrl = baseUrl + "/attachments/download";
|
baseUrl = baseUrl + "/attachments/download";
|
||||||
SeedData();
|
//SeedData();
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> GetAttachmentsAsync()
|
public async Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> GetAttachmentsAsync()
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,9 @@ using Azure.Storage.Blobs;
|
|||||||
using Azure.Storage.Blobs.Models;
|
using Azure.Storage.Blobs.Models;
|
||||||
using Azure.Storage.Blobs.Specialized;
|
using Azure.Storage.Blobs.Specialized;
|
||||||
using DamageAssesment.Api.Attachments.Interfaces;
|
using DamageAssesment.Api.Attachments.Interfaces;
|
||||||
|
using DamageAssesment.Api.Attachments.Models;
|
||||||
|
using System.Diagnostics.Metrics;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace DamageAssesment.Api.Attachments.Providers
|
namespace DamageAssesment.Api.Attachments.Providers
|
||||||
{
|
{
|
||||||
@ -10,11 +13,95 @@ namespace DamageAssesment.Api.Attachments.Providers
|
|||||||
{
|
{
|
||||||
BlobServiceClient _blobClient;
|
BlobServiceClient _blobClient;
|
||||||
BlobContainerClient _containerClient;
|
BlobContainerClient _containerClient;
|
||||||
string azureConnectionString = "<Primary Connection String>";
|
string azureConnectionString;
|
||||||
public AzureBlobService()
|
private string uploadpath = "";
|
||||||
|
private string Deletepath = "";
|
||||||
|
public AzureBlobService(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
_blobClient = new BlobServiceClient(azureConnectionString);
|
uploadpath = configuration.GetValue<string>("Fileupload:folderpath");
|
||||||
_containerClient = _blobClient.GetBlobContainerClient("apiimages");
|
Deletepath = configuration.GetValue<string>("Fileupload:Deletepath");
|
||||||
|
_blobClient = new BlobServiceClient(configuration.GetValue<string>("Fileupload:BlobConnectionString"));
|
||||||
|
_containerClient = _blobClient.GetBlobContainerClient(configuration.GetValue<string>("Fileupload:BlobContainerName"));
|
||||||
|
}
|
||||||
|
public async Task<List<Attachment>> UploadAttachment(int responseId, int answerId, int counter, List<IFormFile> postedFile)
|
||||||
|
{
|
||||||
|
var pathToSave = Path.Combine(uploadpath, "Response-" + responseId);
|
||||||
|
String fullDirectoryPath = Path.Combine(pathToSave, "Answer-" + answerId);
|
||||||
|
List<Models.Attachment> attachments = new List<Models.Attachment>();
|
||||||
|
foreach (IFormFile item in postedFile)
|
||||||
|
{
|
||||||
|
|
||||||
|
counter++;
|
||||||
|
var UserfileName = Path.GetFileName(item.FileName);
|
||||||
|
var extension = System.IO.Path.GetExtension(UserfileName);
|
||||||
|
var fileName = String.Format("Attachment_{0}{1}", counter, extension);
|
||||||
|
var stream = item.OpenReadStream();
|
||||||
|
BlobClient client = _containerClient.GetBlobClient(fullDirectoryPath + "/" + fileName);
|
||||||
|
string dbPath = fullDirectoryPath + "/" + fileName;
|
||||||
|
var result = await client.UploadAsync(stream, true);
|
||||||
|
attachments.Add(new Models.Attachment { AnswerId = answerId, ResponseId = responseId, IsDeleted = false, FileName = UserfileName, URI = dbPath });
|
||||||
|
}
|
||||||
|
return attachments;
|
||||||
|
}
|
||||||
|
public async Task<List<Attachment>> UploadAttachment(int responseId, int counter, List<AnswerInfo> answers)
|
||||||
|
{
|
||||||
|
List<Models.Attachment> attachments = new List<Models.Attachment>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var item in answers)
|
||||||
|
{
|
||||||
|
int answerId = item.AnswerId;
|
||||||
|
var pathToSave = Path.Combine(uploadpath, "Response-" + responseId);
|
||||||
|
String fullDirectoryPath = Path.Combine(pathToSave, "Answer-" + answerId);
|
||||||
|
foreach (var file in item.postedFiles)
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
|
||||||
|
var UserfileName = Path.GetFileName(file.FileName);
|
||||||
|
var fileName = String.Format("Attachment_{0}{1}", counter, file.FileExtension);
|
||||||
|
byte[] byteArray = Convert.FromBase64String(file.FileContent);
|
||||||
|
MemoryStream stream = new MemoryStream(byteArray);
|
||||||
|
BlobClient client = _containerClient.GetBlobClient(fullDirectoryPath + "/" + fileName);
|
||||||
|
string dbPath = fullDirectoryPath + "/" + fileName;
|
||||||
|
var result = await client.UploadAsync(stream, true);
|
||||||
|
attachments.Add(new Models.Attachment { AnswerId = answerId, ResponseId = responseId, IsDeleted = false, FileName = UserfileName, URI = dbPath });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return attachments;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return new List<Models.Attachment>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public async Task<List<Attachment>> UpdateAttachments(int responseId, List<AnswerInfo> answers, IEnumerable<Models.Attachment> attachments)
|
||||||
|
{
|
||||||
|
List<Models.Attachment> Dbattachments = new List<Models.Attachment>();
|
||||||
|
foreach (Models.Attachment searchFile in attachments)
|
||||||
|
{
|
||||||
|
Movefile(searchFile.URI);
|
||||||
|
}
|
||||||
|
foreach (var item in answers)
|
||||||
|
{
|
||||||
|
int answerId = item.AnswerId;
|
||||||
|
var pathToSave = Path.Combine(uploadpath, "Response-" + responseId);
|
||||||
|
String fullDirectoryPath = Path.Combine(pathToSave, "Answer-" + answerId);
|
||||||
|
foreach (var file in item.postedFiles)
|
||||||
|
{
|
||||||
|
Models.Attachment attachment = attachments.Where(a => a.Id == file.AttachmentId).FirstOrDefault();
|
||||||
|
var UserfileName = Path.GetFileName(file.FileName);
|
||||||
|
var fileName = String.Format("Attachment_{0}{1}", attachment?.Id, file.FileExtension);
|
||||||
|
byte[] byteArray = Convert.FromBase64String(file.FileContent);
|
||||||
|
MemoryStream stream = new MemoryStream(byteArray);
|
||||||
|
BlobClient client = _containerClient.GetBlobClient(fullDirectoryPath + "/" + fileName);
|
||||||
|
string dbPath = fullDirectoryPath + "/" + fileName;
|
||||||
|
var result = await client.UploadAsync(stream, true);
|
||||||
|
Dbattachments.Add(new Models.Attachment { Id = attachment.Id, AnswerId = answerId, ResponseId = responseId, IsDeleted = false, FileName = UserfileName, URI = dbPath });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Dbattachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<Azure.Response<BlobContentInfo>>> UploadFiles(List<IFormFile> files)
|
public async Task<List<Azure.Response<BlobContentInfo>>> UploadFiles(List<IFormFile> files)
|
||||||
@ -35,10 +122,52 @@ namespace DamageAssesment.Api.Attachments.Providers
|
|||||||
|
|
||||||
return azureResponse;
|
return azureResponse;
|
||||||
}
|
}
|
||||||
public void DeleteFile(string url)
|
public string getMovefilename(string movefilename)
|
||||||
{
|
{
|
||||||
var blob = _containerClient.GetBlockBlobClient(url);
|
var list = movefilename.Split('.');
|
||||||
blob.DeleteIfExists();
|
if (list.Length > 0)
|
||||||
|
list[list.Length - 1] = DateTime.Now.ToShortDateString().Replace("/", "_") + "_" + DateTime.Now.ToShortTimeString().Replace("/", "_") + "." + list[list.Length - 1];
|
||||||
|
return string.Join("_", list);
|
||||||
|
}
|
||||||
|
public void Movefile(string path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (path != "")
|
||||||
|
{
|
||||||
|
string MovePath = getMovefilename(path.Replace(uploadpath, Deletepath));
|
||||||
|
// Get references to the source and destination blobs
|
||||||
|
BlobClient sourceBlobClient = _containerClient.GetBlobClient(path);
|
||||||
|
BlobClient destinationBlobClient = _containerClient.GetBlobClient(MovePath);
|
||||||
|
// Start the copy operation from the source to the destination
|
||||||
|
destinationBlobClient.StartCopyFromUri(sourceBlobClient.Uri);
|
||||||
|
|
||||||
|
// Check if the copy operation completed successfully
|
||||||
|
WaitForCopyToComplete(destinationBlobClient);
|
||||||
|
|
||||||
|
// Delete the source blob after a successful copy
|
||||||
|
sourceBlobClient.DeleteIfExists();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void WaitForCopyToComplete(BlobClient blobClient)
|
||||||
|
{
|
||||||
|
BlobProperties properties = blobClient.GetProperties();
|
||||||
|
|
||||||
|
while (properties.CopyStatus == CopyStatus.Pending)
|
||||||
|
{
|
||||||
|
Task.Delay(TimeSpan.FromSeconds(1));
|
||||||
|
properties = blobClient.GetProperties();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Deletefile(string url)
|
||||||
|
{
|
||||||
|
BlobClient sourceBlobClient = _containerClient.GetBlobClient(url);
|
||||||
|
sourceBlobClient.DeleteIfExists();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,6 +11,14 @@
|
|||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"Fileupload": {
|
"Fileupload": {
|
||||||
"folderpath": "DMS_Attachments/Active",
|
"folderpath": "DMS_Attachments/Active",
|
||||||
"Deletepath": "DMS_Attachments/Deleted"
|
"Deletepath": "DMS_Attachments/Deleted",
|
||||||
|
"BlobConnectionString": "DefaultEndpointsProtocol=https;AccountName=damagedoculink;AccountKey=blynpwrAQtthEneXC5f4vFewJ3tPV+QZUt1AX3nefZScPPjkr5hMoC18B9ni6/ZYdhRiERPQw+hB+AStonf+iw==;EndpointSuffix=core.windows.net",
|
||||||
|
"BlobContainerName": "doculinks"
|
||||||
|
},
|
||||||
|
"ConnectionStrings": {
|
||||||
|
//"AttachmentConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
|
||||||
|
"AttachmentConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
@ -5,7 +5,6 @@ using DamageAssesment.Api.DocuLinks.Providers;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Data;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.DocuLinks.Controllers
|
namespace DamageAssesment.Api.DocuLinks.Controllers
|
||||||
{
|
{
|
||||||
@ -14,6 +13,7 @@ namespace DamageAssesment.Api.DocuLinks.Controllers
|
|||||||
{
|
{
|
||||||
private readonly IDoculinkProvider documentsProvider;
|
private readonly IDoculinkProvider documentsProvider;
|
||||||
private readonly IUploadService uploadService;
|
private readonly IUploadService uploadService;
|
||||||
|
private readonly IAzureBlobService azureBlobService;
|
||||||
|
|
||||||
public DoculinkController(IDoculinkProvider documentsProvider, IUploadService uploadService)
|
public DoculinkController(IDoculinkProvider documentsProvider, IUploadService uploadService)
|
||||||
{
|
{
|
||||||
@ -41,8 +41,8 @@ namespace DamageAssesment.Api.DocuLinks.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a Doculink type by id.
|
/// Get a Doculink type by id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpGet]
|
|
||||||
[Authorize(Roles = "admin")]
|
[Authorize(Roles = "admin")]
|
||||||
|
[HttpGet]
|
||||||
[Route("doculinks/types/{id}")]
|
[Route("doculinks/types/{id}")]
|
||||||
[Route("doculinks/types/{id}/{language:alpha}")]
|
[Route("doculinks/types/{id}/{language:alpha}")]
|
||||||
public async Task<IActionResult> GetLinkTypeAsync(int id, string? language)
|
public async Task<IActionResult> GetLinkTypeAsync(int id, string? language)
|
||||||
@ -206,7 +206,6 @@ namespace DamageAssesment.Api.DocuLinks.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get all active Doculink.
|
/// Get all active Doculink.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize(Roles = "admin")]
|
|
||||||
[Route("doculinks/active")]
|
[Route("doculinks/active")]
|
||||||
[Route("doculinks/active/{linktype:alpha}")]
|
[Route("doculinks/active/{linktype:alpha}")]
|
||||||
[Route("doculinks/active/{linktype:alpha}/{language:alpha}")]
|
[Route("doculinks/active/{linktype:alpha}/{language:alpha}")]
|
||||||
@ -223,7 +222,6 @@ namespace DamageAssesment.Api.DocuLinks.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get all active Doculink.
|
/// Get all active Doculink.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize(Roles = "admin")]
|
|
||||||
[Route("doculinks/active/{linktypeid:int}")]
|
[Route("doculinks/active/{linktypeid:int}")]
|
||||||
[Route("doculinks/active/{linktypeid:int}/{language:alpha}")]
|
[Route("doculinks/active/{linktypeid:int}/{language:alpha}")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -254,7 +252,7 @@ namespace DamageAssesment.Api.DocuLinks.Controllers
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Upload new document.
|
/// update existing doclink.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize(Roles = "admin")]
|
[Authorize(Roles = "admin")]
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
@ -296,7 +294,7 @@ namespace DamageAssesment.Api.DocuLinks.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create new doclink.
|
/// Create new doclink.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize(Roles = "admin")]
|
// [Authorize(Roles = "admin")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("doculinks")]
|
[Route("doculinks")]
|
||||||
public async Task<IActionResult> CreateDocument(ReqDoculink documentInfo)
|
public async Task<IActionResult> CreateDocument(ReqDoculink documentInfo)
|
||||||
@ -322,7 +320,7 @@ namespace DamageAssesment.Api.DocuLinks.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete document by id.
|
/// Delete Doculink by id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize(Roles = "admin")]
|
[Authorize(Roles = "admin")]
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
<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>
|
||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||||
<PackageReference Include="Azure.Storage.Blobs" Version="12.16.0" />
|
<PackageReference Include="Azure.Storage.Blobs" Version="12.18.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
|
||||||
<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.9" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
|
||||||
@ -23,6 +25,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -7,8 +7,15 @@ namespace DamageAssesment.Api.DocuLinks.Db
|
|||||||
{
|
{
|
||||||
public class DoculinkDbContext : DbContext
|
public class DoculinkDbContext : DbContext
|
||||||
{
|
{
|
||||||
public DoculinkDbContext(DbContextOptions options) : base(options)
|
private IConfiguration _Configuration { get; set; }
|
||||||
|
public DoculinkDbContext(DbContextOptions options, IConfiguration configuration) : base(options)
|
||||||
{
|
{
|
||||||
|
_Configuration = configuration;
|
||||||
|
}
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
|
{
|
||||||
|
// connect to sql server with connection string from app settings
|
||||||
|
options.UseSqlServer(_Configuration.GetConnectionString("DoculinkConnection"));
|
||||||
}
|
}
|
||||||
public DbSet<Db.Doculink> Documents { get; set; }
|
public DbSet<Db.Doculink> Documents { get; set; }
|
||||||
public DbSet<Db.LinkType> LinkTypes { get; set; }
|
public DbSet<Db.LinkType> LinkTypes { get; set; }
|
||||||
|
30
DamageAssesmentApi/DamageAssesment.Api.DocuLinks/Dockerfile
Normal file
30
DamageAssesmentApi/DamageAssesment.Api.DocuLinks/Dockerfile
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#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.
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["DamageAssesment.Api.DocuLinks/DamageAssesment.Api.DocuLinks.csproj", "DamageAssesment.Api.DocuLinks/"]
|
||||||
|
RUN dotnet restore "DamageAssesment.Api.DocuLinks/DamageAssesment.Api.DocuLinks.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/DamageAssesment.Api.DocuLinks"
|
||||||
|
RUN dotnet build "DamageAssesment.Api.DocuLinks.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "DamageAssesment.Api.DocuLinks.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
# Create directories for attachments and set permissions
|
||||||
|
RUN mkdir -p /app/DASA_Documents/Active && \
|
||||||
|
mkdir -p /app/DASA_Documents/Deleted && \
|
||||||
|
chown -R www-data:www-data /app/DASA_Documents
|
||||||
|
|
||||||
|
# Update appsettings.json with the correct paths for attachments
|
||||||
|
RUN sed -i 's#"folderpath": "DASA_Documents/Active"#"folderpath": "/app/DASA_Documents/Active"#' appsettings.json && \
|
||||||
|
sed -i 's#"Deletepath": "DASA_Documents/Deleted"#"Deletepath": "/app/DASA_Documents/Deleted"#' appsettings.json
|
||||||
|
|
||||||
|
ENTRYPOINT ["dotnet", "DamageAssesment.Api.DocuLinks.dll"]
|
@ -1,10 +1,14 @@
|
|||||||
using Azure.Storage.Blobs.Models;
|
using Azure.Storage.Blobs.Models;
|
||||||
|
using DamageAssesment.Api.DocuLinks.Models;
|
||||||
|
|
||||||
namespace DamageAssesment.Api.DocuLinks.Interfaces
|
namespace DamageAssesment.Api.DocuLinks.Interfaces
|
||||||
{
|
{
|
||||||
public interface IAzureBlobService
|
public interface IAzureBlobService
|
||||||
{
|
{
|
||||||
Task<List<Azure.Response<BlobContentInfo>>> UploadFiles(List<IFormFile> files);
|
Task<List<Azure.Response<BlobContentInfo>>> UploadFiles(List<IFormFile> files);
|
||||||
|
Task<Models.Doculink> UploadDocument(int counter, ReqDoculink documentInfo);
|
||||||
|
Task<Models.Doculink> UpdateDocuments(int counter, Models.Doculink document, ReqDoculink documentInfo);
|
||||||
void DeleteFile(string path);
|
void DeleteFile(string path);
|
||||||
|
void Movefile(string path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ builder.Services.AddScoped<IAzureBlobService, AzureBlobService>();
|
|||||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
|
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
|
||||||
builder.Services.AddDbContext<DoculinkDbContext>(option =>
|
builder.Services.AddDbContext<DoculinkDbContext>(option =>
|
||||||
{
|
{
|
||||||
option.UseInMemoryDatabase("DocumentConnection");
|
option.UseSqlServer("DoculinkConnection");
|
||||||
});
|
});
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
@ -1,23 +1,14 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:60754",
|
|
||||||
"sslPort": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"DamageAssesment.Api.Questions": {
|
"DamageAssesment.Api.Doculinks": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "http://localhost:5133",
|
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
},
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"applicationUrl": "http://localhost:5136"
|
||||||
},
|
},
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
@ -26,6 +17,24 @@
|
|||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Docker": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_URLS": "http://+:80"
|
||||||
|
},
|
||||||
|
"publishAllPorts": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:14425",
|
||||||
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,17 @@
|
|||||||
|
|
||||||
|
using Azure;
|
||||||
using Azure.Storage.Blobs;
|
using Azure.Storage.Blobs;
|
||||||
using Azure.Storage.Blobs.Models;
|
using Azure.Storage.Blobs.Models;
|
||||||
using Azure.Storage.Blobs.Specialized;
|
using Azure.Storage.Blobs.Specialized;
|
||||||
using DamageAssesment.Api.DocuLinks.Interfaces;
|
using DamageAssesment.Api.DocuLinks.Interfaces;
|
||||||
|
using DamageAssesment.Api.DocuLinks.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.VisualBasic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DamageAssesment.Api.DocuLinks.Providers
|
namespace DamageAssesment.Api.DocuLinks.Providers
|
||||||
{
|
{
|
||||||
@ -10,11 +19,111 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
{
|
{
|
||||||
BlobServiceClient _blobClient;
|
BlobServiceClient _blobClient;
|
||||||
BlobContainerClient _containerClient;
|
BlobContainerClient _containerClient;
|
||||||
string azureConnectionString = "<Primary Connection String>";
|
string azureConnectionString;
|
||||||
public AzureBlobService()
|
private string uploadpath = "";
|
||||||
|
private string Deletepath = "";
|
||||||
|
public AzureBlobService(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
_blobClient = new BlobServiceClient(azureConnectionString);
|
uploadpath = configuration.GetValue<string>("Fileupload:folderpath");
|
||||||
_containerClient = _blobClient.GetBlobContainerClient("apiimages");
|
Deletepath = configuration.GetValue<string>("Fileupload:Deletepath");
|
||||||
|
_blobClient = new BlobServiceClient(configuration.GetValue<string>("Fileupload:BlobConnectionString"));
|
||||||
|
_containerClient = _blobClient.GetBlobContainerClient(configuration.GetValue<string>("Fileupload:BlobContainerName"));
|
||||||
|
}
|
||||||
|
public async Task<Models.Doculink> UploadDocument(int counter, ReqDoculink documentInfo)
|
||||||
|
{
|
||||||
|
Models.Doculink Documents = new Models.Doculink();
|
||||||
|
List <Models.DoculinkAttachments> attachments = new List<Models.DoculinkAttachments>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string path = "", UserfileName = "";
|
||||||
|
if (documentInfo.Files != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
int counter1 = 1;
|
||||||
|
foreach (var item in documentInfo.Files)
|
||||||
|
{
|
||||||
|
if (item.IsAttachments)
|
||||||
|
{
|
||||||
|
UserfileName = Path.GetFileName(item.FileName);
|
||||||
|
var fileName = String.Format("Document_{0}_{1}{2}", counter, counter1, item.FileExtension);
|
||||||
|
byte[] byteArray = Convert.FromBase64String(item.FileContent);
|
||||||
|
MemoryStream stream = new MemoryStream(byteArray);
|
||||||
|
BlobClient client = _containerClient.GetBlobClient(uploadpath + "/" + fileName);
|
||||||
|
var result = await client.UploadAsync(stream, true);
|
||||||
|
path = uploadpath + "/" + fileName;
|
||||||
|
counter1++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
path = item.url;
|
||||||
|
attachments.Add(new Models.DoculinkAttachments { docName = UserfileName, Path = path, IsAttachments = item.IsAttachments, CustomOrder = item.CustomOrder });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Documents = new Models.Doculink()
|
||||||
|
{
|
||||||
|
linkTypeId = documentInfo.linkTypeId,
|
||||||
|
documentsTranslations = documentInfo.documentsTranslations,
|
||||||
|
doclinksAttachments = attachments,
|
||||||
|
IsDeleted = false,
|
||||||
|
CustomOrder = documentInfo.CustomOrder,
|
||||||
|
IsActive = true
|
||||||
|
};
|
||||||
|
|
||||||
|
return Documents;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return new Models.Doculink();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Models.Doculink> UpdateDocuments(int counter, Models.Doculink document, ReqDoculink documentInfo)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var item in document.doclinksAttachments)
|
||||||
|
{
|
||||||
|
Movefile(item.Path);
|
||||||
|
}
|
||||||
|
string path = "", UserfileName = "";
|
||||||
|
List<Models.DoculinkAttachments> attachments = new List<Models.DoculinkAttachments>();
|
||||||
|
int counter1 = 1;
|
||||||
|
foreach (var item in documentInfo.Files)
|
||||||
|
{
|
||||||
|
if (item.IsAttachments)
|
||||||
|
{
|
||||||
|
UserfileName = Path.GetFileName(item.FileName);
|
||||||
|
var fileName = String.Format("Document_{0}_{1}{2)", document.Id, counter1, item.FileExtension);
|
||||||
|
byte[] byteArray = Encoding.UTF8.GetBytes(item.FileContent);
|
||||||
|
MemoryStream stream = new MemoryStream(byteArray);
|
||||||
|
BlobClient client = _containerClient.GetBlobClient(uploadpath + "/" + fileName);
|
||||||
|
path = uploadpath + "/" + fileName;
|
||||||
|
var result = await client.UploadAsync(stream, true);
|
||||||
|
counter1++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
path = item.url;
|
||||||
|
attachments.Add(new Models.DoculinkAttachments { docName = UserfileName, Path = path, IsAttachments = item.IsAttachments, CustomOrder = item.CustomOrder });
|
||||||
|
}
|
||||||
|
Models.Doculink Documents = new Models.Doculink()
|
||||||
|
{
|
||||||
|
Id = documentInfo.Id,
|
||||||
|
linkTypeId = documentInfo.linkTypeId,
|
||||||
|
documentsTranslations = documentInfo.documentsTranslations,
|
||||||
|
IsActive = true,
|
||||||
|
IsDeleted = false,
|
||||||
|
CustomOrder = documentInfo.CustomOrder,
|
||||||
|
doclinksAttachments = attachments
|
||||||
|
};
|
||||||
|
|
||||||
|
return Documents;
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return new Models.Doculink();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<Azure.Response<BlobContentInfo>>> UploadFiles(List<IFormFile> files)
|
public async Task<List<Azure.Response<BlobContentInfo>>> UploadFiles(List<IFormFile> files)
|
||||||
@ -35,10 +144,52 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
|
|
||||||
return azureResponse;
|
return azureResponse;
|
||||||
}
|
}
|
||||||
|
public string getMovefilename(string movefilename)
|
||||||
|
{
|
||||||
|
var list = movefilename.Split('.');
|
||||||
|
if (list.Length > 0)
|
||||||
|
list[list.Length - 1] = DateTime.Now.ToShortDateString().Replace("/", "_") +"_"+ DateTime.Now.ToShortTimeString().Replace("/", "_")+"." + list[list.Length - 1];
|
||||||
|
return string.Join("_", list);
|
||||||
|
}
|
||||||
|
public void Movefile(string path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (path != "")
|
||||||
|
{
|
||||||
|
string MovePath = getMovefilename(path.Replace(uploadpath, Deletepath));
|
||||||
|
// Get references to the source and destination blobs
|
||||||
|
BlobClient sourceBlobClient = _containerClient.GetBlobClient(path);
|
||||||
|
BlobClient destinationBlobClient = _containerClient.GetBlobClient(MovePath);
|
||||||
|
// Start the copy operation from the source to the destination
|
||||||
|
destinationBlobClient.StartCopyFromUri(sourceBlobClient.Uri);
|
||||||
|
|
||||||
|
// Check if the copy operation completed successfully
|
||||||
|
WaitForCopyToComplete(destinationBlobClient);
|
||||||
|
|
||||||
|
// Delete the source blob after a successful copy
|
||||||
|
sourceBlobClient.DeleteIfExists();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static void WaitForCopyToComplete(BlobClient blobClient)
|
||||||
|
{
|
||||||
|
BlobProperties properties = blobClient.GetProperties();
|
||||||
|
|
||||||
|
while (properties.CopyStatus == CopyStatus.Pending)
|
||||||
|
{
|
||||||
|
Task.Delay(TimeSpan.FromSeconds(1));
|
||||||
|
properties = blobClient.GetProperties();
|
||||||
|
}
|
||||||
|
}
|
||||||
public void DeleteFile(string url)
|
public void DeleteFile(string url)
|
||||||
{
|
{
|
||||||
var blob = _containerClient.GetBlockBlobClient(url);
|
BlobClient sourceBlobClient = _containerClient.GetBlobClient(url);
|
||||||
blob.DeleteIfExists();
|
sourceBlobClient.DeleteIfExists();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,11 +24,12 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
private DoculinkDbContext DocumentDbContext;
|
private DoculinkDbContext DocumentDbContext;
|
||||||
private ILogger<DoculinkProvider> logger;
|
private ILogger<DoculinkProvider> logger;
|
||||||
private IUploadService uploadservice;
|
private IUploadService uploadservice;
|
||||||
|
private IAzureBlobService azureBlobService;
|
||||||
private IMapper mapper;
|
private IMapper mapper;
|
||||||
private readonly IHttpContextAccessor httpContextAccessor;
|
private readonly IHttpContextAccessor httpContextAccessor;
|
||||||
private string baseUrl;
|
private string baseUrl;
|
||||||
|
|
||||||
public DoculinkProvider(DoculinkDbContext DocumentDbContext, ILogger<DoculinkProvider> logger, IMapper mapper, IUploadService uploadservice, IHttpContextAccessor httpContextAccessor)
|
public DoculinkProvider(DoculinkDbContext DocumentDbContext, ILogger<DoculinkProvider> logger, IMapper mapper, IUploadService uploadservice, IAzureBlobService azureBlobService, IHttpContextAccessor httpContextAccessor)
|
||||||
{
|
{
|
||||||
this.DocumentDbContext = DocumentDbContext;
|
this.DocumentDbContext = DocumentDbContext;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
@ -37,12 +38,13 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
this.httpContextAccessor = httpContextAccessor;
|
this.httpContextAccessor = httpContextAccessor;
|
||||||
baseUrl = $"{httpContextAccessor.HttpContext.Request.Scheme}://{httpContextAccessor.HttpContext.Request.Host}";
|
baseUrl = $"{httpContextAccessor.HttpContext.Request.Scheme}://{httpContextAccessor.HttpContext.Request.Host}";
|
||||||
baseUrl = baseUrl + "/doculinks/download";
|
baseUrl = baseUrl + "/doculinks/download";
|
||||||
SeedData();
|
this.azureBlobService = azureBlobService;
|
||||||
|
//SeedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void SeedData()
|
private async Task SeedDataAsync()
|
||||||
{
|
{
|
||||||
if (!DocumentDbContext.LinkTypes.Any())
|
if (!DocumentDbContext.LinkTypes.Any())
|
||||||
{
|
{
|
||||||
|
@ -116,15 +116,16 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
|
|
||||||
string path = "", UserfileName = "";
|
string path = "", UserfileName = "";
|
||||||
List<Models.DoculinkAttachments> attachments = new List<Models.DoculinkAttachments>();
|
List<Models.DoculinkAttachments> attachments = new List<Models.DoculinkAttachments>();
|
||||||
|
int counter1 = 1;
|
||||||
foreach (var item in documentInfo.Files)
|
foreach (var item in documentInfo.Files)
|
||||||
{
|
{
|
||||||
counter++;
|
|
||||||
if (item.IsAttachments)
|
if (item.IsAttachments)
|
||||||
{
|
{
|
||||||
UserfileName = Path.GetFileName(item.FileName+item.FileExtension);
|
UserfileName = Path.GetFileName(item.FileName+item.FileExtension);
|
||||||
var fileName = String.Format("Document_{0}{1}", counter, item.FileExtension);
|
var fileName = String.Format("Document_{0}_{1}{2}", document.Id, counter1, item.FileExtension);
|
||||||
path = Path.Combine(fullDirectoryPath, fileName);
|
path = Path.Combine(fullDirectoryPath, fileName);
|
||||||
File.WriteAllBytes(path, Convert.FromBase64String(item.FileContent));
|
File.WriteAllBytes(path, Convert.FromBase64String(item.FileContent));
|
||||||
|
counter1++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
path = item.url;
|
path = item.url;
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
"JwtSettings": {
|
||||||
|
"securitykey": "bWlhbWkgZGFkZSBzY2hvb2xzIHNlY3JldCBrZXk="
|
||||||
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
@ -6,12 +9,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"JwtSettings": {
|
"ConnectionStrings": {
|
||||||
"securitykey": "bWlhbWkgZGFkZSBzY2hvb2xzIHNlY3JldCBrZXk="
|
//"DoculinkConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
|
||||||
|
"DoculinkConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
|
||||||
|
|
||||||
},
|
},
|
||||||
"Fileupload": {
|
"Fileupload": {
|
||||||
"folderpath": "DASA_Documents/Active",
|
"folderpath": "DASA_Documents/Active",
|
||||||
"Deletepath": "DASA_Documents/Deleted"
|
"Deletepath": "DASA_Documents/Deleted",
|
||||||
|
"BlobConnectionString": "DefaultEndpointsProtocol=https;AccountName=damagedoculink;AccountKey=blynpwrAQtthEneXC5f4vFewJ3tPV+QZUt1AX3nefZScPPjkr5hMoC18B9ni6/ZYdhRiERPQw+hB+AStonf+iw==;EndpointSuffix=core.windows.net",
|
||||||
|
"BlobContainerName": "doculinks"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,13 +5,26 @@
|
|||||||
<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>
|
||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||||
<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.9" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -4,18 +4,23 @@ namespace DamageAssesment.Api.Employees.Db
|
|||||||
{
|
{
|
||||||
public class EmployeeDbContext: DbContext
|
public class EmployeeDbContext: DbContext
|
||||||
{
|
{
|
||||||
public DbSet<Db.Employee> Employees { get; set; }
|
private IConfiguration _Configuration { get; set; }
|
||||||
public EmployeeDbContext(DbContextOptions options) : base(options)
|
public EmployeeDbContext(DbContextOptions options, IConfiguration configuration) : base(options)
|
||||||
{
|
{
|
||||||
|
_Configuration = configuration;
|
||||||
|
}
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
|
{
|
||||||
|
// connect to sql server with connection string from app settings
|
||||||
|
options.UseSqlServer(_Configuration.GetConnectionString("EmployeeConnection"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity<Employee>()
|
modelBuilder.Entity<Employee>()
|
||||||
.Property(item => item.Id)
|
.Property(item => item.Id)
|
||||||
.ValueGeneratedOnAdd();
|
.ValueGeneratedOnAdd();
|
||||||
}
|
}
|
||||||
|
public DbSet<Db.Employee> Employees { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
21
DamageAssesmentApi/DamageAssesment.Api.Employees/Dockerfile
Normal file
21
DamageAssesmentApi/DamageAssesment.Api.Employees/Dockerfile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#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.
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["DamageAssesment.Api.Employees/DamageAssesment.Api.Employees.csproj", "DamageAssesment.Api.Employees/"]
|
||||||
|
RUN dotnet restore "DamageAssesment.Api.Employees/DamageAssesment.Api.Employees.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/DamageAssesment.Api.Employees"
|
||||||
|
RUN dotnet build "DamageAssesment.Api.Employees.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "DamageAssesment.Api.Employees.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Employees.dll"]
|
@ -75,7 +75,7 @@ builder.Services.AddScoped<IEmployeesProvider, EmployeesProvider>();
|
|||||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
|
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
|
||||||
builder.Services.AddDbContext<EmployeeDbContext>(option =>
|
builder.Services.AddDbContext<EmployeeDbContext>(option =>
|
||||||
{
|
{
|
||||||
option.UseInMemoryDatabase("Employees");
|
option.UseSqlServer("EmployeeConnection");
|
||||||
});
|
});
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
@ -1,23 +1,14 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:14425",
|
|
||||||
"sslPort": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"DamageAssesment.Api.Employees": {
|
"DamageAssesment.Api.Employees": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "http://localhost:5135",
|
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
},
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"applicationUrl": "http://localhost:5135"
|
||||||
},
|
},
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
@ -26,6 +17,24 @@
|
|||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Docker": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_URLS": "http://+:80"
|
||||||
|
},
|
||||||
|
"publishAllPorts": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:14425",
|
||||||
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,5 +8,10 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"ConnectionStrings": {
|
||||||
|
//"EmployeeConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
|
||||||
|
"EmployeeConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,27 @@
|
|||||||
<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>
|
||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<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.19.4" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -4,6 +4,16 @@ namespace DamageAssesment.Api.Locations.Db
|
|||||||
{
|
{
|
||||||
public class LocationDbContext : DbContext
|
public class LocationDbContext : DbContext
|
||||||
{
|
{
|
||||||
|
private IConfiguration _Configuration { get; set; }
|
||||||
|
public LocationDbContext(DbContextOptions options, IConfiguration configuration) : base(options)
|
||||||
|
{
|
||||||
|
_Configuration = configuration;
|
||||||
|
}
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
|
{
|
||||||
|
// connect to sql server with connection string from app settings
|
||||||
|
options.UseSqlServer(_Configuration.GetConnectionString("LocationConnection"));
|
||||||
|
}
|
||||||
public DbSet<Db.Location> Locations { get; set; }
|
public DbSet<Db.Location> Locations { get; set; }
|
||||||
public DbSet<Db.Region> Regions { get; set; }
|
public DbSet<Db.Region> Regions { get; set; }
|
||||||
public LocationDbContext(DbContextOptions options) : base(options)
|
public LocationDbContext(DbContextOptions options) : base(options)
|
||||||
|
21
DamageAssesmentApi/DamageAssesment.Api.Locations/Dockerfile
Normal file
21
DamageAssesmentApi/DamageAssesment.Api.Locations/Dockerfile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#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.
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["DamageAssesment.Api.Locations/DamageAssesment.Api.Locations.csproj", "DamageAssesment.Api.Locations/"]
|
||||||
|
RUN dotnet restore "DamageAssesment.Api.Locations/DamageAssesment.Api.Locations.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/DamageAssesment.Api.Locations"
|
||||||
|
RUN dotnet build "DamageAssesment.Api.Locations.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "DamageAssesment.Api.Locations.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Locations.dll"]
|
@ -74,7 +74,7 @@ builder.Services.AddScoped<IRegionsProvider, RegionsProvider>();
|
|||||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
|
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
|
||||||
builder.Services.AddDbContext<LocationDbContext>(option =>
|
builder.Services.AddDbContext<LocationDbContext>(option =>
|
||||||
{
|
{
|
||||||
option.UseInMemoryDatabase("Locations");
|
option.UseSqlServer("LocationConnection");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,23 +1,14 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:20458",
|
|
||||||
"sslPort": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"DamageAssesment.Api.Locations": {
|
"DamageAssesment.Api.Locations": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "http://localhost:5213",
|
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
},
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"applicationUrl": "http://localhost:5213"
|
||||||
},
|
},
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
@ -26,6 +17,24 @@
|
|||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Docker": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_URLS": "http://+:80"
|
||||||
|
},
|
||||||
|
"publishAllPorts": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:20458",
|
||||||
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,5 +8,10 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"ConnectionStrings": {
|
||||||
|
//"LocationConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
|
||||||
|
"LocationConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using DamageAssesment.Api.Questions.Interfaces;
|
using DamageAssesment.Api.Questions.Interfaces;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using DamageAssesment.Api.Questions.Models;
|
using DamageAssesment.Api.Questions.Models;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace DamageAssesment.Api.Questions.Controllers
|
namespace DamageAssesment.Api.Questions.Controllers
|
||||||
|
@ -5,13 +5,27 @@
|
|||||||
<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>
|
||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<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.19.4" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -6,6 +6,16 @@ namespace DamageAssesment.Api.Questions.Db
|
|||||||
{
|
{
|
||||||
public class QuestionDbContext : DbContext
|
public class QuestionDbContext : DbContext
|
||||||
{
|
{
|
||||||
|
private IConfiguration _Configuration { get; set; }
|
||||||
|
public QuestionDbContext(DbContextOptions options, IConfiguration configuration) : base(options)
|
||||||
|
{
|
||||||
|
_Configuration = configuration;
|
||||||
|
}
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
|
{
|
||||||
|
// connect to sql server with connection string from app settings
|
||||||
|
options.UseSqlServer(_Configuration.GetConnectionString("QuestionConnection"));
|
||||||
|
}
|
||||||
public DbSet<Db.Question> Questions { get; set; }
|
public DbSet<Db.Question> Questions { get; set; }
|
||||||
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; }
|
||||||
|
21
DamageAssesmentApi/DamageAssesment.Api.Questions/Dockerfile
Normal file
21
DamageAssesmentApi/DamageAssesment.Api.Questions/Dockerfile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#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.
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["DamageAssesment.Api.Questions/DamageAssesment.Api.Questions.csproj", "DamageAssesment.Api.Questions/"]
|
||||||
|
RUN dotnet restore "DamageAssesment.Api.Questions/DamageAssesment.Api.Questions.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/DamageAssesment.Api.Questions"
|
||||||
|
RUN dotnet build "DamageAssesment.Api.Questions.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "DamageAssesment.Api.Questions.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Questions.dll"]
|
@ -76,7 +76,7 @@ builder.Services.AddSwaggerGen(options =>
|
|||||||
|
|
||||||
builder.Services.AddDbContext<QuestionDbContext>(option =>
|
builder.Services.AddDbContext<QuestionDbContext>(option =>
|
||||||
{
|
{
|
||||||
option.UseInMemoryDatabase("Questions");
|
option.UseSqlServer("QuestionConnection");
|
||||||
});
|
});
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
@ -1,23 +1,14 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:60754",
|
|
||||||
"sslPort": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"DamageAssesment.Api.Questions": {
|
"DamageAssesment.Api.Questions": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "http://localhost:5133",
|
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
},
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"applicationUrl": "http://localhost:5133"
|
||||||
},
|
},
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
@ -26,6 +17,24 @@
|
|||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Docker": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_URLS": "http://+:80"
|
||||||
|
},
|
||||||
|
"publishAllPorts": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:60754",
|
||||||
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,5 +8,10 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"ConnectionStrings": {
|
||||||
|
//"QuestionConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
|
||||||
|
"QuestionConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||||
<PackageReference Include="Moq" Version="4.18.4" />
|
<PackageReference Include="Moq" Version="4.18.4" />
|
||||||
<PackageReference Include="xunit" Version="2.4.2" />
|
<PackageReference Include="xunit" Version="2.4.2" />
|
||||||
|
@ -89,5 +89,6 @@ namespace DamageAssesment.Api.Questions.Test
|
|||||||
Questions.Add(question);
|
Questions.Add(question);
|
||||||
return Questions;
|
return Questions;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -356,6 +356,5 @@ namespace DamageAssesment.Api.Questions.Test
|
|||||||
|
|
||||||
Assert.Equal(404, result.StatusCode);
|
Assert.Equal(404, result.StatusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,15 +5,32 @@
|
|||||||
<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>
|
||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||||
<PackageReference Include="EPPlus" Version="7.0.0" />
|
<PackageReference Include="ClosedXML" Version="0.102.1" />
|
||||||
|
<PackageReference Include="EPPlus" Version="6.2.10" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.9" />
|
||||||
<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.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.19.4" />
|
||||||
<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>
|
||||||
|
@ -4,12 +4,17 @@ namespace DamageAssesment.Api.Responses.Db
|
|||||||
{
|
{
|
||||||
public class SurveyResponseDbContext:DbContext
|
public class SurveyResponseDbContext:DbContext
|
||||||
{
|
{
|
||||||
public DbSet<Db.SurveyResponse> SurveyResponses { get; set; }
|
private IConfiguration _Configuration { get; set; }
|
||||||
|
public SurveyResponseDbContext(DbContextOptions options, IConfiguration configuration) : base(options)
|
||||||
public SurveyResponseDbContext(DbContextOptions options) : base(options)
|
|
||||||
{
|
{
|
||||||
|
_Configuration = configuration;
|
||||||
}
|
}
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
|
{
|
||||||
|
// connect to sql server with connection string from app settings
|
||||||
|
options.UseSqlServer(_Configuration.GetConnectionString("ResponsesConnection"));
|
||||||
|
}
|
||||||
|
public DbSet<Db.SurveyResponse> SurveyResponses { get; set; }
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
21
DamageAssesmentApi/DamageAssesment.Api.Responses/Dockerfile
Normal file
21
DamageAssesmentApi/DamageAssesment.Api.Responses/Dockerfile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#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.
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["DamageAssesment.Api.Responses/DamageAssesment.Api.Responses.csproj", "DamageAssesment.Api.Responses/"]
|
||||||
|
RUN dotnet restore "DamageAssesment.Api.Responses/DamageAssesment.Api.Responses.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/DamageAssesment.Api.Responses"
|
||||||
|
RUN dotnet build "DamageAssesment.Api.Responses.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "DamageAssesment.Api.Responses.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Responses.dll"]
|
@ -5,7 +5,6 @@
|
|||||||
public int CategoryId { get; set; }
|
public int CategoryId { get; set; }
|
||||||
public string CategoryName { get; set; }
|
public string CategoryName { get; set; }
|
||||||
public string CategoryImage { get; set; }
|
public string CategoryImage { get; set; }
|
||||||
public object CategoryNames { get; set; }
|
|
||||||
public List<Question> Questions { get; set; }
|
public List<Question> Questions { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,8 @@ builder.Services.AddScoped<IQuestionServiceProvider, QuestionServiceProvider>();
|
|||||||
builder.Services.AddScoped<IEmployeeServiceProvider, EmployeeServiceProvider>();
|
builder.Services.AddScoped<IEmployeeServiceProvider, EmployeeServiceProvider>();
|
||||||
builder.Services.AddScoped<IAttachmentServiceProvider, AttachmentServiceProvider>();
|
builder.Services.AddScoped<IAttachmentServiceProvider, AttachmentServiceProvider>();
|
||||||
builder.Services.AddScoped<ISurveyServiceProvider, SurveyServiceProvider>();
|
builder.Services.AddScoped<ISurveyServiceProvider, SurveyServiceProvider>();
|
||||||
builder.Services.AddHttpContextAccessor();
|
|
||||||
builder.Services.AddScoped<IExcelExportService, ExcelExportService>();
|
builder.Services.AddScoped<IExcelExportService, ExcelExportService>();
|
||||||
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
|
||||||
builder.Services.AddHttpClient<IHttpUtil, HttpUtil>().
|
builder.Services.AddHttpClient<IHttpUtil, HttpUtil>().
|
||||||
AddTransientHttpErrorPolicy(policy => policy.WaitAndRetryAsync(maxApiCallRetries, _ => TimeSpan.FromSeconds(intervalToRetry))).
|
AddTransientHttpErrorPolicy(policy => policy.WaitAndRetryAsync(maxApiCallRetries, _ => TimeSpan.FromSeconds(intervalToRetry))).
|
||||||
@ -96,7 +96,7 @@ builder.Services.AddSwaggerGen(options =>
|
|||||||
});
|
});
|
||||||
builder.Services.AddDbContext<SurveyResponseDbContext>(option =>
|
builder.Services.AddDbContext<SurveyResponseDbContext>(option =>
|
||||||
{
|
{
|
||||||
option.UseInMemoryDatabase("Responses");
|
option.UseSqlServer("ResponsesConnection");
|
||||||
});
|
});
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
@ -1,23 +1,14 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:58856",
|
|
||||||
"sslPort": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"DamageAssesment.Api.Responses": {
|
"DamageAssesment.Api.Responses": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "http://localhost:5104",
|
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
},
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"applicationUrl": "http://localhost:5104"
|
||||||
},
|
},
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
@ -26,6 +17,24 @@
|
|||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Docker": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_URLS": "http://+:80"
|
||||||
|
},
|
||||||
|
"publishAllPorts": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:58856",
|
||||||
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
using DamageAssesment.Api.Responses.Interfaces;
|
using ClosedXML.Excel;
|
||||||
|
using DamageAssesment.Api.Responses.Interfaces;
|
||||||
using DamageAssesment.Api.Responses.Models;
|
using DamageAssesment.Api.Responses.Models;
|
||||||
using OfficeOpenXml;
|
using OfficeOpenXml;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.Responses.Providers
|
namespace DamageAssesment.Api.Responses.Providers
|
||||||
{
|
{
|
||||||
@ -10,7 +10,7 @@ namespace DamageAssesment.Api.Responses.Providers
|
|||||||
{
|
{
|
||||||
public byte[] ExportToExcel<T1>(List<object> responses)
|
public byte[] ExportToExcel<T1>(List<object> responses)
|
||||||
{
|
{
|
||||||
ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;
|
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||||
using (var package = new ExcelPackage())
|
using (var package = new ExcelPackage())
|
||||||
{
|
{
|
||||||
// Create the first worksheet and populate it with responses
|
// Create the first worksheet and populate it with responses
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using DamageAssesment.Api.Responses.Interfaces;
|
using DamageAssesment.Api.Responses.Interfaces;
|
||||||
using DamageAssesment.Api.Responses.Models;
|
using DamageAssesment.Api.Responses.Models;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using OfficeOpenXml.FormulaParsing.LexicalAnalysis;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.Responses.Services
|
namespace DamageAssesment.Api.Responses.Services
|
||||||
{
|
{
|
||||||
|
@ -6,15 +6,31 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"EndPointSettings": {
|
"JwtSettings": {
|
||||||
"AnswerUrlBase": "http://localhost:5200",
|
"securitykey": "bWlhbWkgZGFkZSBzY2hvb2xzIHNlY3JldCBrZXk="
|
||||||
"LocationUrlBase": "http://localhost:5213",
|
|
||||||
"RegionUrlBase": "http://localhost:5211",
|
|
||||||
"QuestionUrlBase": "http://localhost:5133",
|
|
||||||
"EmployeeUrlBase": "http://localhost:5135",
|
|
||||||
"AttachmentUrlBase": "http://localhost:5243",
|
|
||||||
"SurveyUrlBase": "http://localhost:5009"
|
|
||||||
},
|
},
|
||||||
|
"ConnectionStrings": {
|
||||||
|
//"ResponsesConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
|
||||||
|
"ResponsesConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
|
||||||
|
},
|
||||||
|
//"EndPointSettings": {
|
||||||
|
// "AnswerUrlBase": "http://localhost:5200",
|
||||||
|
// "LocationUrlBase": "http://localhost:5213",
|
||||||
|
// "RegionUrlBase": "http://localhost:5211",
|
||||||
|
// "QuestionUrlBase": "http://localhost:5133",
|
||||||
|
// "EmployeeUrlBase": "http://localhost:5135",
|
||||||
|
// "AttachmentUrlBase": "http://localhost:5243",
|
||||||
|
// "SurveyUrlBase": "http://localhost:5009"
|
||||||
|
//},
|
||||||
|
"EndPointSettings": {
|
||||||
|
"AnswerUrlBase": "http://damageassesment.api.answers:80",
|
||||||
|
"LocationUrlBase": "http://damageassesment.api.locations:80",
|
||||||
|
"QuestionUrlBase": "http://damageassesment.api.questions:80",
|
||||||
|
"EmployeeUrlBase": "http://damageassesment.api.employees:80",
|
||||||
|
"AttachmentUrlBase": "http://damageassesment.api.attachments:80",
|
||||||
|
"SurveyUrlBase": "http://damageassesment.api.surveys:80"
|
||||||
|
},
|
||||||
|
|
||||||
"RessourceSettings": {
|
"RessourceSettings": {
|
||||||
"Employee": "/employees",
|
"Employee": "/employees",
|
||||||
"EmployeeById": "/employees/{0}",
|
"EmployeeById": "/employees/{0}",
|
||||||
|
@ -5,13 +5,27 @@
|
|||||||
<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>
|
||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<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.19.4" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -4,11 +4,18 @@ namespace DamageAssesment.Api.Surveys.Db
|
|||||||
{
|
{
|
||||||
public class SurveysDbContext : DbContext
|
public class SurveysDbContext : DbContext
|
||||||
{
|
{
|
||||||
|
private IConfiguration _Configuration { get; set; }
|
||||||
|
public SurveysDbContext(DbContextOptions options, IConfiguration configuration) : base(options)
|
||||||
|
{
|
||||||
|
_Configuration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
public DbSet<Db.Survey> Surveys { get; set; }
|
public DbSet<Db.Survey> Surveys { get; set; }
|
||||||
public DbSet<Db.SurveyTranslation> SurveysTranslation { get; set; }
|
public DbSet<Db.SurveyTranslation> SurveysTranslation { get; set; }
|
||||||
public SurveysDbContext(DbContextOptions options) : base(options)
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
{
|
{
|
||||||
|
// connect to sql server with connection string from app settings
|
||||||
|
options.UseSqlServer(_Configuration.GetConnectionString("SurveyConnection"));
|
||||||
}
|
}
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
21
DamageAssesmentApi/DamageAssesment.Api.Surveys/Dockerfile
Normal file
21
DamageAssesmentApi/DamageAssesment.Api.Surveys/Dockerfile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#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.
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["DamageAssesment.Api.Surveys/DamageAssesment.Api.Surveys.csproj", "DamageAssesment.Api.Surveys/"]
|
||||||
|
RUN dotnet restore "DamageAssesment.Api.Surveys/DamageAssesment.Api.Surveys.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/DamageAssesment.Api.Surveys"
|
||||||
|
RUN dotnet build "DamageAssesment.Api.Surveys.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "DamageAssesment.Api.Surveys.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "DamageAssesment.Api.Surveys.dll"]
|
@ -75,7 +75,7 @@ builder.Services.AddSwaggerGen(options =>
|
|||||||
|
|
||||||
builder.Services.AddDbContext<SurveysDbContext>(option =>
|
builder.Services.AddDbContext<SurveysDbContext>(option =>
|
||||||
{
|
{
|
||||||
option.UseInMemoryDatabase("Surveys");
|
option.UseSqlServer("SurveyConnection");
|
||||||
});
|
});
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
@ -1,23 +1,14 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:51498",
|
|
||||||
"sslPort": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"DamageAssesment.Api.Surveys": {
|
"DamageAssesment.Api.Surveys": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "http://localhost:5009",
|
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
},
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"applicationUrl": "http://localhost:5009"
|
||||||
},
|
},
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
@ -26,6 +17,24 @@
|
|||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Docker": {
|
||||||
|
"commandName": "Docker",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_URLS": "http://+:80"
|
||||||
|
},
|
||||||
|
"publishAllPorts": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:51498",
|
||||||
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -110,7 +110,6 @@ namespace DamageAssesment.Api.Surveys.Providers
|
|||||||
logger?.LogInformation("Get all Surveys from DB");
|
logger?.LogInformation("Get all Surveys from DB");
|
||||||
//checking is enabled in survey response
|
//checking is enabled in survey response
|
||||||
var surveys = await surveyDbContext.Surveys.ToListAsync();//Where(s => s.IsEnabled == true)
|
var surveys = await surveyDbContext.Surveys.ToListAsync();//Where(s => s.IsEnabled == true)
|
||||||
|
|
||||||
if (surveys != null)
|
if (surveys != null)
|
||||||
{
|
{
|
||||||
surveysList = from s in surveys
|
surveysList = from s in surveys
|
||||||
|
@ -8,5 +8,10 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"ConnectionStrings": {
|
||||||
|
//"SurveyConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
|
||||||
|
"SurveyConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,17 @@
|
|||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||||
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
|
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
|
||||||
<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.9" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.10" />
|
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.10" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
|
<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" />
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Db
|
namespace DamageAssesment.Api.UsersAccess.Db
|
||||||
{
|
{
|
||||||
@ -7,9 +8,15 @@ namespace DamageAssesment.Api.UsersAccess.Db
|
|||||||
public DbSet<Db.User> Users { get; set; }
|
public DbSet<Db.User> Users { get; set; }
|
||||||
public DbSet<Db.Role> Roles { get; set; }
|
public DbSet<Db.Role> Roles { get; set; }
|
||||||
public DbSet<Db.Token> Tokens { get; set; }
|
public DbSet<Db.Token> Tokens { get; set; }
|
||||||
public UsersAccessDbContext(DbContextOptions options) : base(options)
|
private IConfiguration _Configuration { get; set; }
|
||||||
|
public UsersAccessDbContext(DbContextOptions options, IConfiguration configuration) : base(options)
|
||||||
{
|
{
|
||||||
|
_Configuration = configuration;
|
||||||
|
}
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
|
{
|
||||||
|
// connect to sql server with connection string from app settings
|
||||||
|
options.UseSqlServer(_Configuration.GetConnectionString("UsersAccessConnection"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
#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.
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["DamageAssesment.Api.UsersAccess/DamageAssesment.Api.UsersAccess.csproj", "DamageAssesment.Api.UsersAccess/"]
|
||||||
|
RUN dotnet restore "DamageAssesment.Api.UsersAccess/DamageAssesment.Api.UsersAccess.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/DamageAssesment.Api.UsersAccess"
|
||||||
|
RUN dotnet build "DamageAssesment.Api.UsersAccess.csproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "DamageAssesment.Api.UsersAccess.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "DamageAssesment.Api.UsersAccess.dll"]
|
@ -1,10 +1,10 @@
|
|||||||
using DamageAssesment.Api.UsersAccess.Models;
|
using DamageAssesment.Api.UsersAccess.Models;
|
||||||
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Interfaces
|
namespace DamageAssesment.Api.UsersAccess.Interfaces
|
||||||
{
|
{
|
||||||
public interface IEmployeeServiceProvider
|
public interface IEmployeeServiceProvider
|
||||||
{
|
{
|
||||||
Task<List<Employee>> getEmployeesAsync(string token);
|
Task<List<Employee>> getEmployeesAsync();
|
||||||
Task<Employee> getEmployeeAsync(int employeeId, string token);
|
Task<Employee> getEmployeeAsync(int employeeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
using DamageAssesment.Api.UsersAccess.Models;
|
|
||||||
|
|
||||||
namespace DamageAssesment.Api.UsersAccess.Interfaces
|
|
||||||
{
|
|
||||||
public interface IHttpUtil
|
|
||||||
{
|
|
||||||
Task<string> SendAsync(HttpMethod method, string url, string JsonInput, string token);
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,8 +4,8 @@ namespace DamageAssesment.Api.UsersAccess.Interfaces
|
|||||||
{
|
{
|
||||||
public interface IUsersAccessProvider
|
public interface IUsersAccessProvider
|
||||||
{
|
{
|
||||||
public Task<(bool IsSuccess, IEnumerable<object> Users, string ErrorMessage)> GetUsersAsync();
|
public Task<(bool IsSuccess, IEnumerable< Models.User> Users, string ErrorMessage)> GetUsersAsync();
|
||||||
public Task<(bool IsSuccess, object User, string ErrorMessage)> GetUsersAsync(int Id);
|
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)> 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)> PutUserAsync(int Id,Models.User User);
|
||||||
public Task<(bool IsSuccess, Models.User User, string ErrorMessage)> DeleteUserAsync(int Id);
|
public Task<(bool IsSuccess, Models.User User, string ErrorMessage)> DeleteUserAsync(int Id);
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
namespace DamageAssesment.Api.UsersAccess.Interfaces
|
||||||
|
{
|
||||||
|
public interface IHttpUtil
|
||||||
|
{
|
||||||
|
Task<string> SendAsync(HttpMethod method, string url, string JsonInput);
|
||||||
|
}
|
||||||
|
}
|
@ -66,7 +66,6 @@ builder.Services.AddAuthorization(options =>
|
|||||||
|
|
||||||
var _jwtsettings = builder.Configuration.GetSection("JwtSettings");
|
var _jwtsettings = builder.Configuration.GetSection("JwtSettings");
|
||||||
builder.Services.Configure<JwtSettings>(_jwtsettings);
|
builder.Services.Configure<JwtSettings>(_jwtsettings);
|
||||||
builder.Services.AddHttpContextAccessor();
|
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
@ -122,7 +121,7 @@ builder.Services.AddSwaggerGen(options =>
|
|||||||
|
|
||||||
builder.Services.AddDbContext<UsersAccessDbContext>(option =>
|
builder.Services.AddDbContext<UsersAccessDbContext>(option =>
|
||||||
{
|
{
|
||||||
option.UseInMemoryDatabase("UsersAccess");
|
option.UseSqlServer("UsersAccessConnection");
|
||||||
});
|
});
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
@ -2,13 +2,11 @@
|
|||||||
using DamageAssesment.Api.UsersAccess.Db;
|
using DamageAssesment.Api.UsersAccess.Db;
|
||||||
using DamageAssesment.Api.UsersAccess.Interfaces;
|
using DamageAssesment.Api.UsersAccess.Interfaces;
|
||||||
using DamageAssesment.Api.UsersAccess.Models;
|
using DamageAssesment.Api.UsersAccess.Models;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -20,86 +18,55 @@ namespace DamageAssesment.Api.UsersAccess.Providers
|
|||||||
private readonly UsersAccessDbContext userAccessDbContext;
|
private readonly UsersAccessDbContext userAccessDbContext;
|
||||||
private readonly ILogger<UsersAccessProvider> logger;
|
private readonly ILogger<UsersAccessProvider> logger;
|
||||||
private readonly IMapper mapper;
|
private readonly IMapper mapper;
|
||||||
private readonly IEmployeeServiceProvider employeeServiceProvider;
|
//private readonly IEmployeeServiceProvider employeeServiceProvider;
|
||||||
private readonly JwtSettings jwtSettings;
|
private readonly JwtSettings jwtSettings;
|
||||||
private readonly ITokenServiceProvider tokenServiceProvider;
|
private readonly ITokenServiceProvider tokenServiceProvider;
|
||||||
private readonly IConfiguration configuration;
|
private readonly IConfiguration configuration;
|
||||||
private readonly IHttpContextAccessor httpContextAccessor;
|
|
||||||
|
|
||||||
public UsersAccessProvider(IConfiguration configuration,IOptions<JwtSettings> options, ITokenServiceProvider tokenServiceProvider, IHttpContextAccessor httpContextAccessor, UsersAccessDbContext userAccessDbContext, IEmployeeServiceProvider employeeServiceProvider, ILogger<UsersAccessProvider> logger, IMapper mapper)
|
public UsersAccessProvider(IConfiguration configuration,IOptions<JwtSettings> options, ITokenServiceProvider tokenServiceProvider, UsersAccessDbContext userAccessDbContext, IEmployeeServiceProvider employeeServiceProvider, ILogger<UsersAccessProvider> logger, IMapper mapper)
|
||||||
{
|
{
|
||||||
this.userAccessDbContext = userAccessDbContext;
|
this.userAccessDbContext = userAccessDbContext;
|
||||||
this.employeeServiceProvider = employeeServiceProvider;
|
//this.employeeServiceProvider = employeeServiceProvider;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
jwtSettings = options.Value;
|
jwtSettings = options.Value;
|
||||||
this.tokenServiceProvider = tokenServiceProvider;
|
this.tokenServiceProvider = tokenServiceProvider;
|
||||||
this.httpContextAccessor = httpContextAccessor;
|
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
seedData();
|
// seedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void seedData()
|
public void seedData()
|
||||||
{
|
{
|
||||||
if (!userAccessDbContext.Users.Any())
|
if (!userAccessDbContext.Users.Any())
|
||||||
{
|
{
|
||||||
userAccessDbContext.Users.Add(new Db.User { Id = 1, EmployeeId = 1, EmployeeCode = "Emp1", RoleId = 1, IsActive = true, CreateDate = DateTime.Now });
|
userAccessDbContext.Users.Add(new Db.User { EmployeeId = 1, EmployeeCode = "Emp1", RoleId = 1, IsActive = true, CreateDate = DateTime.Now });
|
||||||
userAccessDbContext.Users.Add(new Db.User { Id = 2, EmployeeId = 2, EmployeeCode = "Emp2", RoleId = 2, IsActive = true, CreateDate = DateTime.Now });
|
userAccessDbContext.Users.Add(new Db.User { EmployeeId = 2, EmployeeCode = "Emp2", RoleId = 2, IsActive = true, CreateDate = DateTime.Now });
|
||||||
userAccessDbContext.Users.Add(new Db.User { Id = 3, EmployeeId = 3, EmployeeCode = "Emp3", RoleId = 3, IsActive = true, CreateDate = DateTime.Now });
|
//userAccessDbContext.Users.Add(new Db.User { EmployeeId = 3, EmployeeCode = "Emp3", RoleId = 3, IsActive = true, CreateDate = DateTime.Now });
|
||||||
userAccessDbContext.SaveChanges();
|
userAccessDbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!userAccessDbContext.Roles.Any())
|
if (!userAccessDbContext.Roles.Any())
|
||||||
{
|
{
|
||||||
userAccessDbContext.Roles.Add(new Db.Role { Id = 1, Name = "admin", Description ="Administrator role have full access" });
|
userAccessDbContext.Roles.Add(new Db.Role { Name = "admin", Description ="Administrator role have full access" });
|
||||||
userAccessDbContext.Roles.Add(new Db.Role { Id = 2, Name = "user", Description =" User role"});
|
userAccessDbContext.Roles.Add(new Db.Role { Name = "user", Description =" User role"});
|
||||||
userAccessDbContext.Roles.Add(new Db.Role { Id = 3, Name = "survey", Description ="Survey role" });
|
userAccessDbContext.Roles.Add(new Db.Role { Name = "survey", Description ="Survey role" });
|
||||||
userAccessDbContext.Roles.Add(new Db.Role { Id = 4, Name = "report", Description ="Report role"});
|
userAccessDbContext.Roles.Add(new Db.Role { Name = "report", Description ="Report role"});
|
||||||
userAccessDbContext.Roles.Add(new Db.Role { Id = 5, Name = "document", Description ="Document role" });
|
userAccessDbContext.Roles.Add(new Db.Role { Name = "document", Description ="Document role" });
|
||||||
userAccessDbContext.SaveChanges();
|
userAccessDbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private string GetToken()
|
|
||||||
{
|
public async Task<(bool IsSuccess, IEnumerable<Models.User> Users, string ErrorMessage)> GetUsersAsync()
|
||||||
string token = httpContextAccessor.HttpContext.Request.Headers.Authorization;
|
|
||||||
if (token != null)
|
|
||||||
{
|
|
||||||
token = token.Replace("Bearer ", string.Empty);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
token = "";
|
|
||||||
}
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
public async Task<(bool IsSuccess, IEnumerable<object> Users, string ErrorMessage)> GetUsersAsync()
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger?.LogInformation("Gell all Users from DB");
|
logger?.LogInformation("Gell all Users from DB");
|
||||||
var users = await userAccessDbContext.Users.ToListAsync();
|
var users = await userAccessDbContext.Users.ToListAsync();
|
||||||
List<object> userslist= new List<object>();
|
|
||||||
if (users != null)
|
if (users != null)
|
||||||
{
|
{
|
||||||
var employees = await employeeServiceProvider.getEmployeesAsync( GetToken());
|
|
||||||
var roles = await userAccessDbContext.Roles.ToListAsync();
|
|
||||||
foreach (Db.User user in users)
|
|
||||||
{
|
|
||||||
var employee = employees.SingleOrDefault(a=>a.Id==user.EmployeeId);
|
|
||||||
var role = roles.SingleOrDefault(s => s.Id == user.RoleId);
|
|
||||||
userslist.Add(new
|
|
||||||
{
|
|
||||||
Id = user.Id,
|
|
||||||
EmployeeId = user.EmployeeId,
|
|
||||||
EmployeeCode = user.EmployeeCode,
|
|
||||||
EmployeeName = (employee != null) ? employee.Name : null,
|
|
||||||
RoleId = user.RoleId,
|
|
||||||
RoleName = (role != null) ? role.Name : null
|
|
||||||
});
|
|
||||||
}
|
|
||||||
logger?.LogInformation($"{users.Count} Items(s) found");
|
logger?.LogInformation($"{users.Count} Items(s) found");
|
||||||
// var result = mapper.Map<IEnumerable<Db.User>, IEnumerable<Models.User>>(users);
|
var result = mapper.Map<IEnumerable<Db.User>, IEnumerable<Models.User>>(users);
|
||||||
return (true, userslist, null);
|
return (true, result, null);
|
||||||
}
|
}
|
||||||
return (false, null, "Not found");
|
return (false, null, "Not found");
|
||||||
}
|
}
|
||||||
@ -109,29 +76,18 @@ namespace DamageAssesment.Api.UsersAccess.Providers
|
|||||||
return (false, null, ex.Message);
|
return (false, null, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess, object User, string ErrorMessage)> GetUsersAsync(int Id)
|
|
||||||
|
public async Task<(bool IsSuccess, Models.User User, string ErrorMessage)> GetUsersAsync(int Id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger?.LogInformation("Querying Users table");
|
logger?.LogInformation("Querying Users table");
|
||||||
|
|
||||||
var user = await userAccessDbContext.Users.SingleOrDefaultAsync(s => s.Id == Id);
|
var user = await userAccessDbContext.Users.SingleOrDefaultAsync(s => s.Id == Id);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
var employee = await employeeServiceProvider.getEmployeeAsync(user.EmployeeId,GetToken());
|
|
||||||
var role = await userAccessDbContext.Roles.SingleOrDefaultAsync(s => s.Id == user.RoleId);
|
|
||||||
var data = new
|
|
||||||
{
|
|
||||||
Id = user.Id,
|
|
||||||
EmployeeId = user.EmployeeId,
|
|
||||||
EmployeeCode=user.EmployeeCode,
|
|
||||||
EmployeeName = (employee != null) ? employee.Name : null,
|
|
||||||
RoleId = user.RoleId,
|
|
||||||
RoleName = (role!=null)?role.Name:null
|
|
||||||
};
|
|
||||||
logger?.LogInformation($"User Id: {Id} found");
|
logger?.LogInformation($"User Id: {Id} found");
|
||||||
var result = mapper.Map<Db.User, Models.User>(user);
|
var result = mapper.Map<Db.User, Models.User>(user);
|
||||||
return (true, data, null);
|
return (true, result, null);
|
||||||
}
|
}
|
||||||
return (false, null, "Not found");
|
return (false, null, "Not found");
|
||||||
}
|
}
|
||||||
@ -234,7 +190,35 @@ namespace DamageAssesment.Api.UsersAccess.Providers
|
|||||||
return (false, null, ex.Message);
|
return (false, null, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public async Task<(bool IsSuccess, DadeSchoolToken TokenResponse, string ErrorMessage)> DadeSchoolAuthenticateAsync(string username, string password)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var client = new HttpClient();
|
||||||
|
var request = new HttpRequestMessage(HttpMethod.Post, configuration.GetValue<string>("Dadeschools:TokenUrl"));
|
||||||
|
var collection = new List<KeyValuePair<string, string>>();
|
||||||
|
collection.Add(new("client_id", configuration.GetValue<string>("Dadeschools:TokenClientId")));
|
||||||
|
collection.Add(new("client_secret", configuration.GetValue<string>("Dadeschools:TokenClientSecret")));
|
||||||
|
collection.Add(new("scope", configuration.GetValue<string>("Dadeschools:scope")));
|
||||||
|
collection.Add(new("grant_type", configuration.GetValue<string>("Dadeschools:grant_type")));
|
||||||
|
collection.Add(new("username", username));
|
||||||
|
collection.Add(new("password", password));
|
||||||
|
var content = new FormUrlEncodedContent(collection);
|
||||||
|
request.Content = content;
|
||||||
|
var response = await client.SendAsync(request);
|
||||||
|
var responseString = await response.Content.ReadAsStringAsync();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return (true, JsonConvert.DeserializeObject<DadeSchoolToken>(responseString), "");
|
||||||
|
}
|
||||||
|
return (false, null, responseString);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return (false, null, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
public async Task<(bool IsSuccess, TokenResponse TokenResponse, string ErrorMessage)> AuthenticateAsync(string employecode)
|
public async Task<(bool IsSuccess, TokenResponse TokenResponse, string ErrorMessage)> AuthenticateAsync(string employecode)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -286,35 +270,6 @@ namespace DamageAssesment.Api.UsersAccess.Providers
|
|||||||
return (false, null, "Credentials are required to authenticate.");
|
return (false, null, "Credentials are required to authenticate.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async Task<(bool IsSuccess, DadeSchoolToken TokenResponse, string ErrorMessage)> DadeSchoolAuthenticateAsync(string username, string password)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var client = new HttpClient();
|
|
||||||
var request = new HttpRequestMessage(HttpMethod.Post, configuration.GetValue<string>("Dadeschools:TokenUrl"));
|
|
||||||
var collection = new List<KeyValuePair<string, string>>();
|
|
||||||
collection.Add(new("client_id", configuration.GetValue<string>("Dadeschools:TokenClientId")));
|
|
||||||
collection.Add(new("client_secret", configuration.GetValue<string>("Dadeschools:TokenClientSecret")));
|
|
||||||
collection.Add(new("scope", configuration.GetValue<string>("Dadeschools:scope")));
|
|
||||||
collection.Add(new("grant_type", configuration.GetValue<string>("Dadeschools:grant_type")));
|
|
||||||
collection.Add(new("username", username));
|
|
||||||
collection.Add(new("password", password));
|
|
||||||
var content = new FormUrlEncodedContent(collection);
|
|
||||||
request.Content = content;
|
|
||||||
var response = await client.SendAsync(request);
|
|
||||||
var responseString = await response.Content.ReadAsStringAsync();
|
|
||||||
if (response.IsSuccessStatusCode)
|
|
||||||
{
|
|
||||||
return (true, JsonConvert.DeserializeObject<DadeSchoolToken>(responseString), "");
|
|
||||||
}
|
|
||||||
return (false, null, responseString);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
return (false, null, ex.Message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public async Task<(bool IsSuccess, IEnumerable<Models.Role> Roles, string ErrorMessage)> GetRolesAsync()
|
public async Task<(bool IsSuccess, IEnumerable<Models.Role> Roles, string ErrorMessage)> GetRolesAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using DamageAssesment.Api.UsersAccess.Interfaces;
|
using DamageAssesment.Api.UsersAccess.Interfaces;
|
||||||
using DamageAssesment.Api.UsersAccess.Models;
|
using DamageAssesment.Api.UsersAccess.Models;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
@ -10,11 +10,11 @@ namespace DamageAssesment.Api.UsersAccess.Services
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<Employee>> getEmployeesAsync(string token)
|
public async Task<List<Employee>> getEmployeesAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null,token);
|
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
|
||||||
var employees = JsonConvert.DeserializeObject<List<Employee>>(responseJsonString);
|
var employees = JsonConvert.DeserializeObject<List<Employee>>(responseJsonString);
|
||||||
|
|
||||||
if (employees == null || !employees.Any())
|
if (employees == null || !employees.Any())
|
||||||
@ -28,12 +28,12 @@ namespace DamageAssesment.Api.UsersAccess.Services
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Employee> getEmployeeAsync(int employeeId, string token)
|
public async Task<Employee> getEmployeeAsync(int employeeId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
url = urlBase + string.Format(configuration.GetValue<string>("RessourceSettings:EmployeeById"), employeeId);
|
url = urlBase + string.Format(configuration.GetValue<string>("RessourceSettings:EmployeeById"), employeeId);
|
||||||
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null,token);
|
var responseJsonString = await httpUtil.SendAsync(HttpMethod.Get, url, null);
|
||||||
var employee = JsonConvert.DeserializeObject<Employee>(responseJsonString);
|
var employee = JsonConvert.DeserializeObject<Employee>(responseJsonString);
|
||||||
|
|
||||||
if (employee == null)
|
if (employee == null)
|
||||||
|
@ -14,7 +14,7 @@ namespace DamageAssesment.Api.UsersAccess.Services
|
|||||||
this.httpClient = httpClient;
|
this.httpClient = httpClient;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
public async Task<string> SendAsync(HttpMethod method, string url, string JsonInput,string token)
|
public async Task<string> SendAsync(HttpMethod method, string url, string JsonInput)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -22,7 +22,7 @@ namespace DamageAssesment.Api.UsersAccess.Services
|
|||||||
request.Headers.Accept.Clear();
|
request.Headers.Accept.Clear();
|
||||||
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||||
|
|
||||||
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
//request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||||
if (method == HttpMethod.Post)
|
if (method == HttpMethod.Post)
|
||||||
{
|
{
|
||||||
request.Content = new StringContent(JsonInput, Encoding.UTF8, "application/json");
|
request.Content = new StringContent(JsonInput, Encoding.UTF8, "application/json");
|
||||||
|
@ -36,5 +36,10 @@
|
|||||||
"Name": "profile",
|
"Name": "profile",
|
||||||
"Description": "Read basic information about you such as your date of brith and full name"
|
"Description": "Read basic information about you such as your date of brith and full name"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"ConnectionStrings": {
|
||||||
|
// "UsersAccessConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
|
||||||
|
"UsersAccessConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<IsTestProject>true</IsTestProject>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||||
|
<PackageReference Include="Moq" Version="4.18.4" />
|
||||||
|
<PackageReference Include="xunit" Version="2.4.2" />
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="coverlet.collector" Version="3.2.0">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\DamageAssesment.Api.Responses\DamageAssesment.Api.Responses.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
using DamageAssesment.Api.Responses.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace DamageAssesment.Api.Responses.Test
|
||||||
|
{
|
||||||
|
public class MockData
|
||||||
|
{
|
||||||
|
public static async Task<(bool, SurveyResponse, string)> getOkResponse(SurveyResponse data)
|
||||||
|
{
|
||||||
|
return (true, data, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<(bool, dynamic, string)> getOkResponse()
|
||||||
|
{
|
||||||
|
return (true, new { }, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<(bool, Models.SurveyResponse, string)> getResponse()
|
||||||
|
{
|
||||||
|
return (false, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<Models.SurveyResponse> getSurveyResponseObject()
|
||||||
|
{
|
||||||
|
return new Models.SurveyResponse { EmployeeId = 1, LocationId = 1, SurveyId = 1, Id = 1 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,251 @@
|
|||||||
|
using DamageAssesment.Api.Responses.Controllers;
|
||||||
|
using DamageAssesment.Api.Responses.Interfaces;
|
||||||
|
using DamageAssesment.Api.Responses.Models;
|
||||||
|
using DamageAssesment.Api.Responses.Test;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Moq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DamageAssesment.SurveyResponses.Test
|
||||||
|
{
|
||||||
|
public class ResponsesServiceTest
|
||||||
|
{
|
||||||
|
private Mock<ISurveysResponse> mockSurveyResponseService;
|
||||||
|
private string token { get; set; }
|
||||||
|
public ResponsesServiceTest()
|
||||||
|
{
|
||||||
|
mockSurveyResponseService = new Mock<ISurveysResponse>();
|
||||||
|
token = Guid.NewGuid().ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get Responses - Ok case")]
|
||||||
|
public async Task GetSurveyResponsesAsync_ShouldReturnStatusCode200()
|
||||||
|
{
|
||||||
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
|
var mockResponse = await MockData.getOkResponse(mockRequestObject);
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesAsync()).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync();
|
||||||
|
Assert.Equal(200, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get Responses - BadRequest case")]
|
||||||
|
public async Task GetSurveyResponsesAsync_ShouldReturnStatusCode204()
|
||||||
|
{
|
||||||
|
var mockResponse = await MockData.getResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesAsync()).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (BadRequestObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync();
|
||||||
|
Assert.Equal(400, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get Responses by surveyId - Ok case")]
|
||||||
|
public async Task GetSurveyResponsesBySurveyAsync_ShouldReturnStatusCode200()
|
||||||
|
{
|
||||||
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
|
var mockResponse = await MockData.getOkResponse();
|
||||||
|
<<<<<<<< HEAD:DamageAssesmentApi/DamageAssesment.Api.Responses.Test/SurveyResponsesServiceTest.cs
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1,1)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(1,1);
|
||||||
|
========
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesAsync(1);
|
||||||
|
>>>>>>>> Azure-Integration:DamageAssesmentApi/DamageAssesment.Responses.Test/ResponsesServiceTest.cs
|
||||||
|
Assert.Equal(200, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get Responses by surveyId - NoContent case")]
|
||||||
|
public async Task GetSurveyResponsesBySurveyAsync_ShouldReturnStatusCode204()
|
||||||
|
{
|
||||||
|
var mockResponse = await MockData.getResponse();
|
||||||
|
<<<<<<<< HEAD:DamageAssesmentApi/DamageAssesment.Api.Responses.Test/SurveyResponsesServiceTest.cs
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1,1)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new SurveyResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesAsync(1,1);
|
||||||
|
========
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAsync(1)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesAsync(1);
|
||||||
|
>>>>>>>> Azure-Integration:DamageAssesmentApi/DamageAssesment.Responses.Test/ResponsesServiceTest.cs
|
||||||
|
Assert.Equal(204, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get Responses by surveyId and locationId - Ok case")]
|
||||||
|
public async Task GetSurveyResponsesBySurveyLocationAsync_ShouldReturnStatusCode200()
|
||||||
|
{
|
||||||
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
|
var mockResponse = await MockData.getOkResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAndLocationAsync(1, 1)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1);
|
||||||
|
Assert.Equal(200, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get Responses by surveyId and locationId - NoContent case")]
|
||||||
|
public async Task GetSurveyResponsesBySurveyLocationAsync_ShouldReturnStatusCode204()
|
||||||
|
{
|
||||||
|
var mockResponse = await MockData.getResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesBySurveyAndLocationAsync(1, 1)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesBySurveyAndLocationAsync(1, 1);
|
||||||
|
Assert.Equal(204, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get Responses by surveyId and QuestionId and Answer - Ok case")]
|
||||||
|
public async Task GetSurveyResponsesBySurveyQuestionAnswerAsync_ShouldReturnStatusCode200()
|
||||||
|
{
|
||||||
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
|
var mockResponse = await MockData.getOkResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetResponsesByAnswerAsync(1, 1, "Yes")).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes");
|
||||||
|
Assert.Equal(200, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get Responses by surveyId and QuestionId and Answer - NoContent case")]
|
||||||
|
public async Task GetSurveyResponsesBySurveyQuestionAnswerAsync_ShouldReturnStatusCode204()
|
||||||
|
{
|
||||||
|
var mockResponse = await MockData.getResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetResponsesByAnswerAsync(1, 1, "Yes")).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponsesByAnswerAsyncAsync(1, 1, "Yes");
|
||||||
|
Assert.Equal(204, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get Responses by region and surveyId - Ok case")]
|
||||||
|
public async Task GetSurveyResponsesByRegionSurveyAsync_ShouldReturnStatusCode200()
|
||||||
|
{
|
||||||
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
|
var mockResponse = await MockData.getOkResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetAnswersByRegionAsync(1)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (OkObjectResult)await surveyResponseProvider.GetAnswersByRegionAsync(1);
|
||||||
|
Assert.Equal(200, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get Responses by region and surveyId - NoContent Case")]
|
||||||
|
public async Task GetSurveyResponsesByRegionSurveyAsync_ShouldReturnStatusCode204()
|
||||||
|
{
|
||||||
|
var mockResponse = await MockData.getResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetAnswersByRegionAsync(1)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (NoContentResult)await surveyResponseProvider.GetAnswersByRegionAsync(1);
|
||||||
|
Assert.Equal(204, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get Responses by maintenanceCenter and surveyId - Ok case")]
|
||||||
|
public async Task GetSurveyResponsesMaintenanceCenterSurveyAsync_ShouldReturnStatusCode200()
|
||||||
|
{
|
||||||
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
|
var mockResponse = await MockData.getOkResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesByMaintenanceCenterAsync(1)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (OkObjectResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1);
|
||||||
|
Assert.Equal(200, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get Responses by maintenanceCenter and surveyId - No Content Case")]
|
||||||
|
public async Task GetSurveyResponsesMaintenanceCenterSurveyAsync_ShouldReturnStatusCode204()
|
||||||
|
{
|
||||||
|
var mockResponse = await MockData.getResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponsesByMaintenanceCenterAsync(1)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (NoContentResult)await surveyResponseProvider.GetAnswersByMaintenaceCentersync(1);
|
||||||
|
Assert.Equal(204, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get SurveyResponse by responseId- Ok case")]
|
||||||
|
public async Task GetSurveyResponsesByResponseIdyAsync_ShouldReturnStatusCode200()
|
||||||
|
{
|
||||||
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
|
var mockResponse = await MockData.getOkResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponseByIdAsync(1)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (OkObjectResult)await surveyResponseProvider.GetSurveyResponseByIdAsync(1);
|
||||||
|
Assert.Equal(200, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Get Responses by maintenanceCenter and surveyId - NoContent Case")]
|
||||||
|
public async Task GetSurveyResponsesByResponseIdyAsync_ShouldReturnStatusCode204()
|
||||||
|
{
|
||||||
|
var mockResponse = await MockData.getResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.GetSurveyResponseByIdAsync(1)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseProvider = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (NoContentResult)await surveyResponseProvider.GetSurveyResponseByIdAsync(1);
|
||||||
|
Assert.Equal(204, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Post Responses - Ok case")]
|
||||||
|
public async Task PostSurveyAsync_ShouldReturnStatusCode200()
|
||||||
|
{
|
||||||
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
|
var mockResponse = await MockData.getOkResponse(mockRequestObject);
|
||||||
|
mockSurveyResponseService.Setup(service => service.PostSurveyResponseAsync(mockRequestObject)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (OkObjectResult)await surveyResponseController.PostSurveysAsync(mockRequestObject);
|
||||||
|
Assert.Equal(200, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Post Responses - BadRequest case")]
|
||||||
|
public async Task PostSurveyAsync_ShouldReturnStatusCode400()
|
||||||
|
{
|
||||||
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
|
var mockResponse = await MockData.getResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.PostSurveyResponseAsync(mockRequestObject)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (BadRequestObjectResult)await surveyResponseController.PostSurveysAsync(mockRequestObject);
|
||||||
|
Assert.Equal(400, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Put Responses - Ok case")]
|
||||||
|
public async Task PutSurveyAsync_ShouldReturnStatusCode200()
|
||||||
|
{
|
||||||
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
|
var mockResponse = await MockData.getOkResponse(mockRequestObject);
|
||||||
|
mockSurveyResponseService.Setup(service => service.PutSurveyResponseAsync(1, mockRequestObject)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (OkObjectResult)await surveyResponseController.PutSurveyResponseAsync(1, mockRequestObject);
|
||||||
|
Assert.Equal(200, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Put Responses - BadRequest case")]
|
||||||
|
public async Task PutSurveyAsync_ShouldReturnStatusCode404()
|
||||||
|
{
|
||||||
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
|
var mockResponse = await MockData.getResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.PutSurveyResponseAsync(1, mockRequestObject)).ReturnsAsync(mockResponse); ;
|
||||||
|
var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (BadRequestObjectResult)await surveyResponseController.PutSurveyResponseAsync(1, mockRequestObject);
|
||||||
|
Assert.Equal(400, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Delete Responses - Ok case")]
|
||||||
|
public async Task DeleteSurveyAsync_ShouldReturnStatusCode200()
|
||||||
|
{
|
||||||
|
SurveyResponse mockRequestObject = await MockData.getSurveyResponseObject();
|
||||||
|
var mockResponse = await MockData.getOkResponse(mockRequestObject);
|
||||||
|
mockSurveyResponseService.Setup(service => service.DeleteSurveyResponseAsync(1)).ReturnsAsync(mockResponse);
|
||||||
|
var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (OkObjectResult)await surveyResponseController.DeleteSurveyResponseAsync(1);
|
||||||
|
Assert.Equal(200, result.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "Delete Responses - NotFound case")]
|
||||||
|
public async Task DeleteSurveyAsync_ShouldReturnStatusCode404()
|
||||||
|
{
|
||||||
|
var mockResponse = await MockData.getResponse();
|
||||||
|
mockSurveyResponseService.Setup(service => service.DeleteSurveyResponseAsync(1)).ReturnsAsync(mockResponse); ;
|
||||||
|
var surveyResponseController = new ResponsesController(mockSurveyResponseService.Object);
|
||||||
|
var result = (NotFoundResult)await surveyResponseController.DeleteSurveyResponseAsync(1);
|
||||||
|
Assert.Equal(404, result.StatusCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Attachm
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4CB40DC2-D9D2-4384-A7A6-9968F5C777A2}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4CB40DC2-D9D2-4384-A7A6-9968F5C777A2}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
..\..\..\..\Sample\Migrations.ps1 = ..\..\..\..\Sample\Migrations.ps1
|
||||||
ReadMe.txt = ReadMe.txt
|
ReadMe.txt = ReadMe.txt
|
||||||
ReadMe4Dev.txt = ReadMe4Dev.txt
|
ReadMe4Dev.txt = ReadMe4Dev.txt
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
@ -33,18 +34,20 @@ 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("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.DocuLinks", "DamageAssesment.Api.DocuLinks\DamageAssesment.Api.DocuLinks.csproj", "{D356A3C9-B275-4B1A-9B1B-F48600E85E4F}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.DocuLinks.Test", "DamageAssesment.Api.DocuLinks.Test\DamageAssesment.Api.DocuLinks.Test.csproj", "{A7F17ED7-71D2-4FD0-87E5-D83415078FC0}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.DocuLinks.Test", "DamageAssesment.Api.DocuLinks.Test\DamageAssesment.Api.DocuLinks.Test.csproj", "{A7F17ED7-71D2-4FD0-87E5-D83415078FC0}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Responses", "DamageAssesment.Api.Responses\DamageAssesment.Api.Responses.csproj", "{C7F1C88B-B3C1-406E-A741-1D9A07ED18C0}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Responses.Test", "DamageAssesment.Api.Responses.Test\DamageAssesment.Api.Responses.Test.csproj", "{26BFCF59-0D24-41C1-9202-D4FFCC52389B}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.UsersAccess", "DamageAssesment.Api.UsersAccess\DamageAssesment.Api.UsersAccess.csproj", "{40240AD6-90D2-4128-BCDF-12C77D1B1B55}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.UsersAccess", "DamageAssesment.Api.UsersAccess\DamageAssesment.Api.UsersAccess.csproj", "{40240AD6-90D2-4128-BCDF-12C77D1B1B55}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.UsersAccess.Test", "DamageAssesment.Api.UsersAccess.Test\DamageAssesment.Api.UsersAccess.Test.csproj", "{ADAF9385-262C-4A37-A603-A53B77EA515D}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.UsersAccess.Test", "DamageAssesment.Api.UsersAccess.Test\DamageAssesment.Api.UsersAccess.Test.csproj", "{ADAF9385-262C-4A37-A603-A53B77EA515D}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{0DD44934-6826-43C8-A438-320A05209967}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.DocuLinks", "DamageAssesment.Api.DocuLinks\DamageAssesment.Api.DocuLinks.csproj", "{B027FBB9-1357-4FD6-85B3-8ADCE11CAE05}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Responses", "DamageAssesment.Api.Responses\DamageAssesment.Api.Responses.csproj", "{B5C446DF-30DF-46E3-BD87-DA454C8B9C4F}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Responses.Test", "DamageAssesment.Api.Responses.Test\DamageAssesment.Api.Responses.Test.csproj", "{22014966-BF3D-463A-B561-46635BE75C89}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -99,22 +102,10 @@ 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
|
||||||
{D356A3C9-B275-4B1A-9B1B-F48600E85E4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{D356A3C9-B275-4B1A-9B1B-F48600E85E4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{D356A3C9-B275-4B1A-9B1B-F48600E85E4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{D356A3C9-B275-4B1A-9B1B-F48600E85E4F}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{A7F17ED7-71D2-4FD0-87E5-D83415078FC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{A7F17ED7-71D2-4FD0-87E5-D83415078FC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{A7F17ED7-71D2-4FD0-87E5-D83415078FC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{A7F17ED7-71D2-4FD0-87E5-D83415078FC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A7F17ED7-71D2-4FD0-87E5-D83415078FC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{A7F17ED7-71D2-4FD0-87E5-D83415078FC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{A7F17ED7-71D2-4FD0-87E5-D83415078FC0}.Release|Any CPU.Build.0 = Release|Any CPU
|
{A7F17ED7-71D2-4FD0-87E5-D83415078FC0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{C7F1C88B-B3C1-406E-A741-1D9A07ED18C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{C7F1C88B-B3C1-406E-A741-1D9A07ED18C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{C7F1C88B-B3C1-406E-A741-1D9A07ED18C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{C7F1C88B-B3C1-406E-A741-1D9A07ED18C0}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{26BFCF59-0D24-41C1-9202-D4FFCC52389B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{26BFCF59-0D24-41C1-9202-D4FFCC52389B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{26BFCF59-0D24-41C1-9202-D4FFCC52389B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{26BFCF59-0D24-41C1-9202-D4FFCC52389B}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{40240AD6-90D2-4128-BCDF-12C77D1B1B55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{40240AD6-90D2-4128-BCDF-12C77D1B1B55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{40240AD6-90D2-4128-BCDF-12C77D1B1B55}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{40240AD6-90D2-4128-BCDF-12C77D1B1B55}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{40240AD6-90D2-4128-BCDF-12C77D1B1B55}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{40240AD6-90D2-4128-BCDF-12C77D1B1B55}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
@ -123,6 +114,22 @@ Global
|
|||||||
{ADAF9385-262C-4A37-A603-A53B77EA515D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{ADAF9385-262C-4A37-A603-A53B77EA515D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{ADAF9385-262C-4A37-A603-A53B77EA515D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{ADAF9385-262C-4A37-A603-A53B77EA515D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{ADAF9385-262C-4A37-A603-A53B77EA515D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{ADAF9385-262C-4A37-A603-A53B77EA515D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{0DD44934-6826-43C8-A438-320A05209967}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0DD44934-6826-43C8-A438-320A05209967}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0DD44934-6826-43C8-A438-320A05209967}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0DD44934-6826-43C8-A438-320A05209967}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B027FBB9-1357-4FD6-85B3-8ADCE11CAE05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B027FBB9-1357-4FD6-85B3-8ADCE11CAE05}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B027FBB9-1357-4FD6-85B3-8ADCE11CAE05}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B027FBB9-1357-4FD6-85B3-8ADCE11CAE05}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B5C446DF-30DF-46E3-BD87-DA454C8B9C4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B5C446DF-30DF-46E3-BD87-DA454C8B9C4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B5C446DF-30DF-46E3-BD87-DA454C8B9C4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B5C446DF-30DF-46E3-BD87-DA454C8B9C4F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{22014966-BF3D-463A-B561-46635BE75C89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{22014966-BF3D-463A-B561-46635BE75C89}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{22014966-BF3D-463A-B561-46635BE75C89}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{22014966-BF3D-463A-B561-46635BE75C89}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
trigger:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
pr:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
pool:
|
|
||||||
vmImage: 'ubuntu-latest'
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- checkout: self
|
|
||||||
|
|
||||||
- script: |
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
chmod +x ./Scripts/build_and_push_services2acr.sh
|
|
||||||
./Scripts/build_and_push_services2acr.sh
|
|
||||||
displayName: 'Run build_and_push_services2acr.sh'
|
|
75
DamageAssesmentApi/docker-compose.acr.yml
Normal file
75
DamageAssesmentApi/docker-compose.acr.yml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
services:
|
||||||
|
damageassesment.api.answers:
|
||||||
|
image: dadeschoolscontainerregistry.azurecr.io/damageassesmentapianswers
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Answers/Dockerfile
|
||||||
|
ports:
|
||||||
|
- "6001:80"
|
||||||
|
command: bash -c "docker push dadeschoolscontainerregistry.azurecr.io/damageassesmentapianswers"
|
||||||
|
|
||||||
|
damageassesment.api.attachments:
|
||||||
|
image: dadeschoolscontainerregistry.azurecr.io/damageassesmentapiattachments
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Attachments/Dockerfile
|
||||||
|
ports:
|
||||||
|
- "6001:80"
|
||||||
|
command: bash -c "docker push dadeschoolscontainerregistry.azurecr.io/damageassesmentapiattachments"
|
||||||
|
|
||||||
|
damageassesment.api.employees:
|
||||||
|
image: dadeschoolscontainerregistry.azurecr.io/damageassesmentapiemployees
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Employees/Dockerfile
|
||||||
|
ports:
|
||||||
|
- "6003:80"
|
||||||
|
command: bash -c "docker push dadeschoolscontainerregistry.azurecr.io/damageassesmentapiemployees"
|
||||||
|
|
||||||
|
damageassesment.api.locations:
|
||||||
|
image: dadeschoolscontainerregistry.azurecr.io/damageassesmentapilocations
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Locations/Dockerfile
|
||||||
|
ports:
|
||||||
|
- "6004:80"
|
||||||
|
command: bash -c "docker push dadeschoolscontainerregistry.azurecr.io/damageassesmentapilocations"
|
||||||
|
|
||||||
|
damageassesment.api.questions:
|
||||||
|
image: dadeschoolscontainerregistry.azurecr.io/damageassesmentapiquestions
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Questions/Dockerfile
|
||||||
|
ports:
|
||||||
|
- "6005:80"
|
||||||
|
command: bash -c "docker push dadeschoolscontainerregistry.azurecr.io/damageassesmentapiquestions"
|
||||||
|
|
||||||
|
damageassesment.api.surveys:
|
||||||
|
image: dadeschoolscontainerregistry.azurecr.io/damageassesmentapisurveys
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Surveys/Dockerfile
|
||||||
|
ports:
|
||||||
|
- "6006:80"
|
||||||
|
command: bash -c "docker push dadeschoolscontainerregistry.azurecr.io/damageassesmentapisurveys"
|
||||||
|
|
||||||
|
damageassesment.api.doculinks:
|
||||||
|
image: dadeschoolscontainerregistry.azurecr.io/damageassesmentapidoculinks
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.DocuLinks/Dockerfile
|
||||||
|
ports:
|
||||||
|
- "6008:80"
|
||||||
|
command: bash -c "docker push dadeschoolscontainerregistry.azurecr.io/damageassesmentapidoculinks"
|
||||||
|
|
||||||
|
damageassesment.api.responses:
|
||||||
|
image: dadeschoolscontainerregistry.azurecr.io/damageassesmentapiresponses
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Responses/Dockerfile
|
||||||
|
ports:
|
||||||
|
- "6007:80"
|
||||||
|
command: bash -c "docker push dadeschoolscontainerregistry.azurecr.io/damageassesmentapiresponses"
|
||||||
|
|
80
DamageAssesmentApi/docker-compose.asf.yml
Normal file
80
DamageAssesmentApi/docker-compose.asf.yml
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
services:
|
||||||
|
answers:
|
||||||
|
image: santhoshsnair/damageassesmentapianswers:latest
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6001:80"
|
||||||
|
|
||||||
|
attachments:
|
||||||
|
image: santhoshsnair/damageassesmentapiattachments:latest
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6002:80"
|
||||||
|
|
||||||
|
|
||||||
|
employees:
|
||||||
|
image: santhoshsnair/damageassesmentapiemployees:latest
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6003:80"
|
||||||
|
|
||||||
|
|
||||||
|
locations:
|
||||||
|
image: santhoshsnair/damageassesmentapilocations:latest
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6004:80"
|
||||||
|
|
||||||
|
|
||||||
|
questions:
|
||||||
|
image: santhoshsnair/damageassesmentapiquestions:latest
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6005:80"
|
||||||
|
|
||||||
|
|
||||||
|
responses:
|
||||||
|
image: santhoshsnair/damageassesmentapisurveyresponses:latest
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
- services__Answers=http://10.0.0.4:19081/dasapp/answers/
|
||||||
|
- services__Locations=http://10.0.0.4:19081/dasapp/locations/
|
||||||
|
- services__Questions=http://10.0.0.4:19081/dasapp/questions/
|
||||||
|
- services__Employees=http://10.0.0.4:19081/dasapp/employees/
|
||||||
|
- services__Attachments=http://10.0.0.4:19081/dasapp/attachments/
|
||||||
|
- services__Surveys=http://10.0.0.4:19081/dasapp/survey/
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- "6006:80"
|
||||||
|
|
||||||
|
|
||||||
|
surveys:
|
||||||
|
image: santhoshsnair/damageassesmentapisurveys:latest
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6007:80"
|
||||||
|
|
||||||
|
|
||||||
|
doculinks:
|
||||||
|
image: santhoshsnair/damageassesmentapidoculinks:latest
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6009:80"
|
||||||
|
sqlserver:
|
||||||
|
image: mcr.microsoft.com/mssql/server:2019-latest
|
||||||
|
environment:
|
||||||
|
- SA_PASSWORD=your_password
|
||||||
|
- ACCEPT_EULA=Y
|
||||||
|
ports:
|
||||||
|
- "1433:1433"
|
||||||
|
volumes:
|
||||||
|
- ./sql_data:/var/opt/mssql/data
|
21
DamageAssesmentApi/docker-compose.dcproj
Normal file
21
DamageAssesmentApi/docker-compose.dcproj
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?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>0dd44934-6826-43c8-a438-320a05209967</ProjectGuid>
|
||||||
|
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
|
||||||
|
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}/swagger</DockerServiceUrl>
|
||||||
|
<DockerServiceName>damageassesment.api.answers</DockerServiceName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="docker-compos.tst.yml" />
|
||||||
|
<None Include="docker-compose.sql.yml" />
|
||||||
|
<None Include="docker-compose.asf.yml" />
|
||||||
|
<None Include="docker-compose.override.yml">
|
||||||
|
<DependentUpon>docker-compose.yml</DependentUpon>
|
||||||
|
</None>
|
||||||
|
<None Include="docker-compose.yml" />
|
||||||
|
<None Include=".dockerignore" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
74
DamageAssesmentApi/docker-compose.override.yml
Normal file
74
DamageAssesmentApi/docker-compose.override.yml
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
services:
|
||||||
|
damageassesment.api.answers:
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6001:80"
|
||||||
|
|
||||||
|
damageassesment.api.attachments:
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6002:80"
|
||||||
|
|
||||||
|
|
||||||
|
damageassesment.api.employees:
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6003:80"
|
||||||
|
|
||||||
|
|
||||||
|
damageassesment.api.locations:
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6004:80"
|
||||||
|
|
||||||
|
|
||||||
|
damageassesment.api.questions:
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6005:80"
|
||||||
|
|
||||||
|
|
||||||
|
damageassesment.api.responses:
|
||||||
|
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
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- "6006:80"
|
||||||
|
|
||||||
|
|
||||||
|
damageassesment.api.surveys:
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6007:80"
|
||||||
|
|
||||||
|
|
||||||
|
damageassesment.api.usersaccess:
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6008:80"
|
||||||
|
|
||||||
|
damageassesment.api.doculinks:
|
||||||
|
environment:
|
||||||
|
- ASPNETCORE_ENVIRONMENT=Development
|
||||||
|
ports:
|
||||||
|
- "6009:80"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
13
DamageAssesmentApi/docker-compose.sql.yml
Normal file
13
DamageAssesmentApi/docker-compose.sql.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
sqlserver:
|
||||||
|
image: mcr.microsoft.com/mssql/server:2019-latest
|
||||||
|
environment:
|
||||||
|
- SA_PASSWORD=Test123
|
||||||
|
- ACCEPT_EULA=Y
|
||||||
|
ports:
|
||||||
|
- "1433:1433"
|
||||||
|
volumes:
|
||||||
|
- ./data:/var/opt/mssql # Mount a volume to persist data
|
64
DamageAssesmentApi/docker-compose.yml
Normal file
64
DamageAssesmentApi/docker-compose.yml
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
services:
|
||||||
|
damageassesment.api.answers:
|
||||||
|
image: ${DOCKER_REGISTRY-}damageassesmentapianswers
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Answers/Dockerfile
|
||||||
|
|
||||||
|
damageassesment.api.attachments:
|
||||||
|
image: ${DOCKER_REGISTRY-}damageassesmentapiattachments
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Attachments/Dockerfile
|
||||||
|
|
||||||
|
|
||||||
|
damageassesment.api.employees:
|
||||||
|
image: ${DOCKER_REGISTRY-}damageassesmentapiemployees
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Employees/Dockerfile
|
||||||
|
|
||||||
|
|
||||||
|
damageassesment.api.locations:
|
||||||
|
image: ${DOCKER_REGISTRY-}damageassesmentapilocations
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Locations/Dockerfile
|
||||||
|
|
||||||
|
|
||||||
|
damageassesment.api.questions:
|
||||||
|
image: ${DOCKER_REGISTRY-}damageassesmentapiquestions
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Questions/Dockerfile
|
||||||
|
|
||||||
|
|
||||||
|
damageassesment.api.surveys:
|
||||||
|
image: ${DOCKER_REGISTRY-}damageassesmentapisurveys
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Surveys/Dockerfile
|
||||||
|
|
||||||
|
|
||||||
|
damageassesment.api.doculinks:
|
||||||
|
image: ${DOCKER_REGISTRY-}damageassesmentapidoculinks
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.DocuLinks/Dockerfile
|
||||||
|
|
||||||
|
|
||||||
|
damageassesment.api.responses:
|
||||||
|
image: ${DOCKER_REGISTRY-}damageassesmentapiresponses
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.Responses/Dockerfile
|
||||||
|
|
||||||
|
|
||||||
|
damageassesment.api.usersaccess:
|
||||||
|
image: ${DOCKER_REGISTRY-}damageassesmentapiusersaccess
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: DamageAssesment.Api.UsersAccess/Dockerfile
|
||||||
|
|
20
DamageAssesmentApi/launchSettings.json
Normal file
20
DamageAssesmentApi/launchSettings.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"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.surveyresponses": "StartDebugging",
|
||||||
|
"damageassesment.api.surveys": "StartDebugging",
|
||||||
|
"damageassesment.api.doculinks": "StartDebugging",
|
||||||
|
"damageassesment.api.responses": "StartDebugging",
|
||||||
|
"damageassesment.api.usersaccess": "StartDebugging"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,30 +0,0 @@
|
|||||||
# powershell -ExecutionPolicy Bypass -File .\build_and_push_services2acr.ps1
|
|
||||||
# Specify the path to your docker-compose.yml
|
|
||||||
$composeFile = "C:\Users\santh\OneDrive\Desktop\DOCKERS\ubuntu\Sprint6\C1011\Backend-API-Services\DamageAssesmentApi\docker-compose.yml"
|
|
||||||
|
|
||||||
# List of services to build, tag, and push
|
|
||||||
$services = @(
|
|
||||||
"damageassesmentapianswers",
|
|
||||||
"damageassesmentapiattachments",
|
|
||||||
"damageassesmentapiemployees",
|
|
||||||
"damageassesmentapilocations",
|
|
||||||
"damageassesmentapiquestions",
|
|
||||||
"damageassesmentapisurveys",
|
|
||||||
"damageassesmentapidoculinks",
|
|
||||||
"damageassesmentapiresponses"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Log in to ACR (replace ACR_USERNAME and ACR_PASSWORD)
|
|
||||||
docker login dadeschoolscontainerregistry.azurecr.io -u dadeSchoolsContainerRegistry -p k1f8hE0O5hj3tYCCR/5stNrkw5BZoTmAqid/hvaVo8+ACRDc2Arn
|
|
||||||
|
|
||||||
# Loop through the services and build, tag, and push
|
|
||||||
foreach ($service in $services) {
|
|
||||||
# Build the service
|
|
||||||
docker-compose -f $composeFile build $service
|
|
||||||
|
|
||||||
# Tag the image for ACR
|
|
||||||
docker tag "$service" "dadeschoolscontainerregistry.azurecr.io/$service"
|
|
||||||
|
|
||||||
# Push the image to ACR
|
|
||||||
docker push "dadeschoolscontainerregistry.azurecr.io/$service"
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Determine the current directory (where the script is located)
|
|
||||||
script_directory="$( cd "$(dirname "$0")" ; pwd -P )"
|
|
||||||
|
|
||||||
# Use the 'find' command to locate the 'docker-compose.yml' file within the repository directory
|
|
||||||
composeFile=$(find "$script_directory/.." -name "docker-compose.yml" -type f | head -n 1)
|
|
||||||
|
|
||||||
if [ -z "$composeFile" ]; then
|
|
||||||
echo "docker-compose.yml not found."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# List of services to build, tag, and push
|
|
||||||
services=(
|
|
||||||
"damageassesmentapianswers"
|
|
||||||
"damageassesmentapiattachments"
|
|
||||||
"damageassesmentapiemployees"
|
|
||||||
"damageassesmentapilocations"
|
|
||||||
"damageassesmentapiquestions"
|
|
||||||
"damageassesmentapisurveys"
|
|
||||||
"damageassesmentapidoculinks"
|
|
||||||
"damageassesmentapiresponses"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Log in to ACR (replace ACR_USERNAME and ACR_PASSWORD)
|
|
||||||
docker login dadeschoolscontainerregistry.azurecr.io -u dadeSchoolsContainerRegistry -p k1f8hE0O5hj3tYCCR/5stNrkw5BZoTmAqid/hvaVo8+ACRDc2Arn
|
|
||||||
|
|
||||||
# Loop through the services and build, tag, and push
|
|
||||||
for service in "${services[@]}"; do
|
|
||||||
# Build the service
|
|
||||||
docker-compose -f "$composeFile" build "$service"
|
|
||||||
|
|
||||||
# Tag the image for ACR
|
|
||||||
docker tag "$service" "dadeschoolscontainerregistry.azurecr.io/$service"
|
|
||||||
|
|
||||||
# Push the image to ACR
|
|
||||||
docker push "dadeschoolscontainerregistry.azurecr.io/$service"
|
|
||||||
done
|
|
39
db/migrate-sqldb_v1.ps1
Normal file
39
db/migrate-sqldb_v1.ps1
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# Define the path to your application's root directory
|
||||||
|
$applicationRoot = "C:\Users\santh\OneDrive\Desktop\DOCKERS\ubuntu\Sprint6\C1011\Backend-API-Services\DamageAssesmentApi\"
|
||||||
|
#To execute: powershell -ExecutionPolicy Bypass -File .\migrate-sqldb.ps1
|
||||||
|
# Define the list of microservice directories
|
||||||
|
$microservices = @(
|
||||||
|
"DamageAssesment.Api.Answers",
|
||||||
|
"DamageAssesment.Api.Attachments",
|
||||||
|
"DamageAssesment.Api.DocuLinks",
|
||||||
|
"DamageAssesment.Api.Employees",
|
||||||
|
"DamageAssesment.Api.Locations",
|
||||||
|
"DamageAssesment.Api.Questions",
|
||||||
|
"DamageAssesment.Api.Responses",
|
||||||
|
"DamageAssesment.Api.Surveys"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Define the migration name with the current date and time
|
||||||
|
$migrationName = "Migration_" + (Get-Date -Format "yyyyMMdd_HHmmss")
|
||||||
|
|
||||||
|
# Function to run migrations for a microservice
|
||||||
|
Function Run-Migrations {
|
||||||
|
param (
|
||||||
|
[string]$microservicePath
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Host "Running Migrations for $microservicePath..."
|
||||||
|
Set-Location -Path $microservicePath
|
||||||
|
dotnet ef migrations add $migrationName
|
||||||
|
dotnet ef database update
|
||||||
|
Write-Host "Migrations for $microservicePath completed."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run migrations for each microservice
|
||||||
|
$microservices | ForEach-Object {
|
||||||
|
$microservicePath = Join-Path -Path $applicationRoot -ChildPath $_
|
||||||
|
Run-Migrations -microservicePath $microservicePath
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "All Migrations Completed."
|
Reference in New Issue
Block a user