Compare commits

...

34 Commits

Author SHA1 Message Date
Santhosh Nair
0c13528940 Revert "Merged PR 53: fixed survey put issue, and added export excel in responses
fixed survey put issue, amd added export excel in responses"
2023-11-01 15:35:20 +00:00
Uppu, Vijay
6fbe21979f Merged PR 53: fixed survey put issue, and added export excel in responses
fixed survey put issue, amd added export excel in responses
2023-11-01 13:29:16 +00:00
uppuv
fc166e65c9 fixed survey put issue, amd added export excel in responses 2023-10-31 16:40:46 -04:00
uppuv
ae6b306290 reverted doculinks grouping by linktype 2023-10-24 12:22:59 -04:00
uppuv
d3a751a6ad added status field in survey micro service 2023-10-23 11:56:39 -04:00
uppuv
2182b9a6b3 added status field in survey micro service 2023-10-23 11:39:56 -04:00
Santhosh S
8624eeeb97 Merge branch 'docker-sql' of https://dev.azure.com/MDCSB-Telecommuters/Emergency%20Preparedness%20Disaster%20Recovery%20Project%20%28EPDRP%29/_git/Backend-API-Services into docker-sql 2023-10-16 22:45:08 -04:00
Santhosh S
16d45d6632 docker-compose.acr added 2023-10-16 22:44:08 -04:00
uppuv
c77e0452c4 added logic to get active surveys from survey responses 2023-10-16 14:13:20 -04:00
uppuv
6ad5bb1572 merged latest changes from docker to dev 2023-10-13 14:48:08 -04:00
uppuv
8e0a7df68b added muilti language return format for question categories for question by survey 2023-10-13 13:29:21 -04:00
uppuv
cb3c7f8f6a added muilti language return format for question categories for question by survey 2023-10-13 13:21:33 -04:00
Santhosh S
01ccd97528 table update tested 2023-10-13 13:17:00 -04:00
Santhosh S
26b360e0a9 Merge branch 'docker-sql' of https://dev.azure.com/MDCSB-Telecommuters/Emergency%20Preparedness%20Disaster%20Recovery%20Project%20%28EPDRP%29/_git/Backend-API-Services into docker-sql 2023-10-13 08:58:24 -04:00
uppuv
360a58c026 Merge branch 'docker-branch' into docker-sql 2023-10-12 16:03:21 -04:00
uppuv
26e79432e2 table name changes 2023-10-12 16:01:24 -04:00
Santhosh S
11c6fc0dc9 Merge branch 'docker-sql' of https://dev.azure.com/MDCSB-Telecommuters/Emergency%20Preparedness%20Disaster%20Recovery%20Project%20%28EPDRP%29/_git/Backend-API-Services into docker-sql 2023-10-11 21:26:04 -04:00
Santhosh S
99633d8dda Connection string sql dev server updated 2023-10-11 21:23:47 -04:00
uppuv
8e3f6674c6 Merge branch 'docker-branch' into docker-sql 2023-10-11 19:25:09 -04:00
uppuv
885fdeb117 updated question category 2023-10-11 19:24:50 -04:00
uppuv
14956057cd Merge branch 'docker-branch' into docker-sql 2023-10-11 15:34:42 -04:00
uppuv
fa3e3bbd99 added seed data for questions and surveys for demo 2023-10-11 15:33:21 -04:00
uppuv
340ba6fa6d removed all migrations 2023-10-10 16:34:56 -04:00
uppuv
46794057c4 Added sql docker logic 2023-10-10 16:28:30 -04:00
uppuv
71d4b524e7 doculinks changes for grouping 2023-10-09 13:29:01 -04:00
uppuv
c7a2dc5910 seed changes for doculinks 2023-10-06 15:53:09 -04:00
uppuv
643bc0c76a Merged docker with docker sql branch 2023-10-06 15:14:13 -04:00
uppuv
d0023114a3 updated doculink changes 2023-09-26 12:40:55 -04:00
uppuv
465bf4b081 Merge branch 'dev' into Database-Integration 2023-09-13 16:52:43 -04:00
uppuv
e04bccfffd Merged new dev changes 2023-09-13 13:16:42 -04:00
uppuv
0544c7397d 314: updated document multi language output format 2023-09-11 13:34:50 -04:00
uppuv
9c536a1c52 Modified Documents api for InMemory Logic 2023-09-11 13:34:50 -04:00
uppuv
48be1a74c9 Merge branch 'DocumentsAPI' into Database-Integration 2023-08-31 19:02:47 -04:00
uppuv
eb07c31ff6 Database integration 2023-08-18 17:14:41 -04:00
82 changed files with 619 additions and 280 deletions

Binary file not shown.

View File

@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\DamageAssesment.sln",
"PreviewInSolutionExplorer": false
}

View File

@ -396,3 +396,4 @@ FodyWeavers.xsd
# JetBrains Rider
*.sln.iml
**/migrations/

View File

@ -13,7 +13,12 @@
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.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.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.Answers.Db
{
[Table("Answers")]
public class Answer
{
[Key]

View File

@ -1,13 +1,19 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
namespace DamageAssesment.Api.Answers.Db
{
public class AnswerDbContext:DbContext
{
public AnswerDbContext(DbContextOptions options):base(options)
private IConfiguration _Configuration { get; set; }
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; }
protected override void OnModelCreating(ModelBuilder modelBuilder)

View File

@ -23,7 +23,7 @@ builder.Services.AddScoped<IAnswersProvider, AnswersProvider>();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
builder.Services.AddDbContext<AnswerDbContext>(option =>
{
option.UseInMemoryDatabase("Answers");
option.UseSqlServer("AnswerConnection");
});
var app = builder.Build();

View File

@ -198,13 +198,12 @@ namespace DamageAssesment.Api.Answers.Providers
{
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() { Id = 2, AnswerText = "No", Comment = "Comment test 5", QuestionId = 2, SurveyResponseId = 1 });
// Uncomment the lines below to add more initial data if needed
//answerDbContext.Answers.Add(new Db.Answer() { Id = 3, AnswerText = "No", Comment = "No Comment", QuestionId = 3, SurveyResponseId = 1 });
//answerDbContext.Answers.Add(new Db.Answer() { Id = 4, AnswerText = "Yes", Comment = "No Comment", QuestionId = 1, 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() { Id = 6, AnswerText = "No", Comment = "No Comment", QuestionId = 3, SurveyResponseId = 2 });
answerDbContext.Answers.Add(new Db.Answer() { AnswerText = "Yes", Comment = "", QuestionId = 1, SurveyResponseId = 1 });
answerDbContext.Answers.Add(new Db.Answer() { AnswerText = "No", Comment = "myComment", QuestionId = 2, SurveyResponseId = 1 });
//answerDbContext.Answers.Add(new Db.Answer() { 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() { 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.SaveChanges();
}
}

View File

@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -8,5 +8,11 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"ConnectionStrings": {
//"AnswerConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
// "AnswerConnection": "Server=localhost,1433;Database=da_survey_dev;User Id=sa;Password=Password123;TrustServerCertificate=True;",
"AnswerConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
}
}

View File

@ -14,8 +14,19 @@
<PackageReference Include="Azure.Storage.Blobs" Version="12.16.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
<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.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" />
</ItemGroup>

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.Attachments.Db
{
[Table("AnswerAttachments")]
public class Attachment
{
[Key]

View File

@ -1,11 +1,19 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
namespace DamageAssesment.Api.Attachments.Db
{
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; }
protected override void OnModelCreating(ModelBuilder modelBuilder)

View File

@ -27,7 +27,7 @@ builder.Services.AddScoped<IAzureBlobService,AzureBlobService>();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
builder.Services.AddDbContext<AttachmentsDbContext>(option =>
{
option.UseInMemoryDatabase("Attachments");
option.UseSqlServer("AttachmentConnection");
});
builder.Services.Configure<FormOptions>(o =>
{

View File

@ -21,7 +21,7 @@ namespace DamageAssesment.Api.Attachments.Providers
this.logger = logger;
this.mapper = mapper;
this.uploadservice = uploadservice;
SeedData();
//SeedData();
}
public async Task<(bool IsSuccess, IEnumerable<Models.Attachment> Attachments, string ErrorMessage)> GetAttachmentsAsync()
{

View File

@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -12,5 +12,11 @@
"Fileupload": {
"folderpath": "DMS_Attachments/Active",
"Deletepath": "DMS_Attachments/Deleted"
},
"ConnectionStrings": {
//"AttachmentConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
// "AttachmentConnection": "Server=localhost,1433;Database=da_survey_dev;User Id=sa;Password=Password123;TrustServerCertificate=True;"
"AttachmentConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
}
}

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.DocuLinks.Db
{
[Table("Doculinks")]
public class Doculink
{
[Key]

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
namespace DamageAssesment.Api.DocuLinks.Db
{
[Table("DoculinkAttachments")]
public class DoculinkAttachments
{

View File

@ -7,8 +7,15 @@ namespace DamageAssesment.Api.DocuLinks.Db
{
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("DoculinConnection"));
}
public DbSet<Db.Doculink> Documents { get; set; }
public DbSet<Db.LinkType> LinkTypes { get; set; }

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.DocuLinks.Db
{
[Table("DoculinkTrans")]
public class DoculinkTranslation
{
[Key]

View File

@ -1,7 +1,9 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.DocuLinks.Db
{
[Table("DoculinkTypes")]
public class LinkType
{
[Key]

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
namespace DamageAssesment.Api.DocuLinks.Db
{
[Table("DoculinkTypeTrans")]
public class LinksTranslation
{
[Key]

View File

@ -25,7 +25,7 @@ builder.Services.AddScoped<IAzureBlobService, AzureBlobService>();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
builder.Services.AddDbContext<DoculinkDbContext>(option =>
{
option.UseInMemoryDatabase("DocumentConnection");
option.UseSqlServer("DoculinConnection");
});
var app = builder.Build();

View File

@ -75,7 +75,7 @@ namespace DamageAssesment.Api.DocuLinks.Providers
}
else
fileModel = new FileModel() { url = "www.google" + i + ".com", IsAttachments = false, CustomOrder = 1 };
ReqDoculink documentInfo = new ReqDoculink() { linkTypeId = linkTypeId, CustomOrder = i, Files = new List<FileModel>() { fileModel } };
ReqDoculink documentInfo = new ReqDoculink() { linkTypeId = i, CustomOrder = i, Files = new List<FileModel>() { fileModel } };
Models.Doculink document = uploadservice.UploadDocument(counter, documentInfo);
DocumentDbContext.Documents.Add(mapper.Map<Models.Doculink, Db.Doculink>(document));
DocumentDbContext.SaveChanges();

View File

@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -6,6 +6,12 @@
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
//"DoculinConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;",
//"DoculinConnection": "Server=localhost,1433;Database=da_survey_dev;User Id=sa;Password=Password123;TrustServerCertificate=True;"
"DoculinConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
},
"Fileupload": {
"folderpath": "DASA_Documents/Active",
"Deletepath": "DASA_Documents/Deleted"

View File

@ -12,8 +12,18 @@
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" 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.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>

View File

@ -1,7 +1,9 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.Employees.Db
{
[Table("Employees")]
public class Employee
{
[Key]

View File

@ -4,18 +4,23 @@ namespace DamageAssesment.Api.Employees.Db
{
public class EmployeeDbContext: DbContext
{
public DbSet<Db.Employee> Employees { get; set; }
public EmployeeDbContext(DbContextOptions options) : base(options)
private IConfiguration _Configuration { get; set; }
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)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Employee>()
.Property(item => item.Id)
.ValueGeneratedOnAdd();
}
public DbSet<Db.Employee> Employees { get; set; }
}
}

View File

@ -24,7 +24,7 @@ builder.Services.AddScoped<IEmployeesProvider, EmployeesProvider>();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
builder.Services.AddDbContext<EmployeeDbContext>(option =>
{
option.UseInMemoryDatabase("Employees");
option.UseSqlServer("EmployeeConnection");
});
var app = builder.Build();

View File

@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -13,5 +13,11 @@
"endpoint1": "xxx",
"endpoint2": "xxx",
"endpoint3": "xxx"
},
"ConnectionStrings": {
//"EmployeeConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;",
//"EmployeeConnection": "Server=localhost,1433;Database=da_survey_dev;User Id=sa;Password=Password123;TrustServerCertificate=True;"
"EmployeeConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
}
}

View File

@ -11,6 +11,17 @@
<ItemGroup>
<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.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.Locations.Db
{
[Table("Locations")]
public class Location
{
[Key]

View File

@ -4,6 +4,16 @@ namespace DamageAssesment.Api.Locations.Db
{
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.Region> Regions { get; set; }
public LocationDbContext(DbContextOptions options) : base(options)

View File

@ -1,7 +1,9 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.Locations.Db
{
[Table("Regions")]
public class Region
{
[Key]

View File

@ -24,7 +24,7 @@ builder.Services.AddScoped<IRegionsProvider, RegionsProvider>();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
builder.Services.AddDbContext<LocationDbContext>(option =>
{
option.UseInMemoryDatabase("Locations");
option.UseSqlServer("LocationConnection");
});
var app = builder.Build();

View File

@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -8,5 +8,11 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"ConnectionStrings": {
//"LocationConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;",
// "LocationConnection": "Server=localhost,1433;Database=da_survey_dev;User Id=sa;Password=Password123;TrustServerCertificate=True;"
"LocationConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
}
}

View File

@ -11,6 +11,17 @@
<ItemGroup>
<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.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
namespace DamageAssesment.Api.Questions.Db
{
[Table("QuestionCategoryTrans")]
public class CategoryTranslation
{
[Key]

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.Questions.Db
{
[Table("Questions")]
public class Question
{
[Key]

View File

@ -1,8 +1,10 @@
using System.Buffers.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.Questions.Db
{
[Table("QuestionCategories")]
public class QuestionCategory
{
[Key]

View File

@ -6,6 +6,16 @@ namespace DamageAssesment.Api.Questions.Db
{
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.QuestionType> QuestionTypes { get; set; }
public DbSet<Db.QuestionsTranslation> QuestionsTranslations { get; set; }

View File

@ -1,7 +1,9 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.Questions.Db
{
[Table("QuestionTypes")]
public class QuestionType
{
[Key]

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.Questions.Db
{
[Table("QuestionTrans")]
public class QuestionsTranslation
{
[Key]

View File

@ -5,6 +5,7 @@
public int CategoryId { get; set; }
public string IconName { get; set; }
public string IconLibrary { get; set; }
public object CategoryNames { get; set; }
public List<MultiLanguage> QuestionsText { get; set; }
}
}

View File

@ -26,7 +26,7 @@ builder.Services.AddSwaggerGen(c =>
});
builder.Services.AddDbContext<QuestionDbContext>(option =>
{
option.UseInMemoryDatabase("Questions");
option.UseSqlServer("QuestionConnection");
});
var app = builder.Build();

View File

@ -31,8 +31,7 @@ namespace DamageAssesment.Api.Questions.Providers
questionDbContext.QuestionTypes.Add(new Db.QuestionType() { TypeText = "TextBox" });
questionDbContext.SaveChanges();
}
if (!questionDbContext.QuestionCategories.Any())
if (!questionDbContext.QuestionsTranslations.Any())
{
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { IconName = "Flooding", IconLibrary = "https://example.com/images/img1.png" });
questionDbContext.QuestionCategories.Add(new Db.QuestionCategory() { IconName = "Electrical", IconLibrary = "https://example.com/images/img2.png" });
@ -65,14 +64,51 @@ namespace DamageAssesment.Api.Questions.Providers
if (!questionDbContext.Questions.Any())
{
var question1 = new Db.Question() { QuestionTypeId = 1, SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId = 1 };
var question2 = new Db.Question() { QuestionTypeId = 1, SurveyId = 1, QuestionNumber = 2, IsRequired = false, Comment = true, Key = false, CategoryId = 1 };
var question2 = new Db.Question() { QuestionTypeId = 1, SurveyId = 1, QuestionNumber = 2, IsRequired = false, Comment = true, Key = false, CategoryId = 2 };
var question3 = new Db.Question() { QuestionTypeId = 1, SurveyId = 2, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId = 1 };
var question4 = new Db.Question() { QuestionTypeId = 1, SurveyId = 2, QuestionNumber = 2, IsRequired = false, Comment = true, Key = false, CategoryId = 1 };
var question4 = new Db.Question() { QuestionTypeId = 1, SurveyId = 2, QuestionNumber = 2, IsRequired = false, Comment = true, Key = false, CategoryId = 2 };
var question5 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId = 1 };
var question6 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 2, IsRequired = false, Comment = true, Key = false, CategoryId = 2 };
var question7 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId = 3};
var question8 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 2, IsRequired = false, Comment = true, Key = false, CategoryId = 4 };
var question9 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 1, IsRequired = true, Comment = true, Key = true, CategoryId = 5 };
var question10 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 2, IsRequired = false, Comment = false, Key = true, CategoryId = 1 };
var question11 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 1, IsRequired = true, Comment = false, Key = false, CategoryId = 2 };
var question12 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 2, IsRequired = false, Comment = true, Key = true, CategoryId = 3 };
var question13 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId = 4 };
var question14 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 2, IsRequired = false, Comment = true, Key = false, CategoryId = 5 };
var question15 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 1, IsRequired = true, Comment = false, Key = false, CategoryId = 1 };
var question16 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 2, IsRequired = false, Comment = true, Key = true, CategoryId = 2 };
var question17 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 1, IsRequired = true, Comment = false, Key = false, CategoryId = 3 };
var question18 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 2, IsRequired = false, Comment = true, Key = false, CategoryId = 4 };
var question19 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId = 5 };
var question20 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 2, IsRequired = false, Comment = true, Key = false, CategoryId = 1 };
var question21 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId = 2 };
var question22 = new Db.Question() { QuestionTypeId = 1, SurveyId = 3, QuestionNumber = 2, IsRequired = false, Comment = true, Key = true, CategoryId = 3 };
questionDbContext.Questions.Add(question1);
questionDbContext.Questions.Add(question2);
questionDbContext.Questions.Add(question3);
questionDbContext.Questions.Add(question4);
questionDbContext.Questions.Add(question5);
questionDbContext.Questions.Add(question6);
questionDbContext.Questions.Add(question7);
questionDbContext.Questions.Add(question8);
questionDbContext.Questions.Add(question9);
questionDbContext.Questions.Add(question10);
questionDbContext.Questions.Add(question11);
questionDbContext.Questions.Add(question12);
questionDbContext.Questions.Add(question13);
questionDbContext.Questions.Add(question14);
questionDbContext.Questions.Add(question15);
questionDbContext.Questions.Add(question16);
questionDbContext.Questions.Add(question17);
questionDbContext.Questions.Add(question18);
questionDbContext.Questions.Add(question19);
questionDbContext.Questions.Add(question20);
questionDbContext.Questions.Add(question21);
questionDbContext.Questions.Add(question22);
questionDbContext.SaveChanges();
}
@ -90,6 +126,64 @@ namespace DamageAssesment.Api.Questions.Providers
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 4, QuestionText = "Are the grounds flooded ?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 4, QuestionText = "Les terrains sont-ils inondés ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 4, QuestionText = "¿Están inundados los terrenos?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 5, QuestionText = "Can you open?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 6, QuestionText = "Is debris blocking access?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 7, QuestionText = "Are the grounds flooded?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 8, QuestionText = "Is the access blocked by flooding?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 9, QuestionText = "Are any utility wires down?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 10, QuestionText = "Do you have damage to windows, doors, or walls?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 11, QuestionText = "Do you have roof damage?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 12, QuestionText = "Do you have major water intrusion?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 13, QuestionText = "Are any portable classrooms damaged and unusable?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 14, QuestionText = "Does your facility need to be secured/boarded?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 15, QuestionText = "Are you without commercial power?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 16, QuestionText = "Are you without water pressure?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 17, QuestionText = "Are you without telephones?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 18, QuestionText = "Are traffic signals damaged/missing?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 19, QuestionText = "Are you without an operable fire alarm?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 20, QuestionText = "Are you without an operable public address?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 21, QuestionText = "Do you have major debris?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 22, QuestionText = "Are there any problems or issues not addressed above that would impede you from opening? If yes, please explain below?", Language = "en" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 5, QuestionText = "Pouvez-vous ouvrir ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 6, QuestionText = "Est-ce que des débris bloquent l'accès ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 7, QuestionText = "Les terrains sont-ils inondés ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 8, QuestionText = "L'accès est-il bloqué par des inondations ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 9, QuestionText = "Des câbles d'utilité sont-ils tombés ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 10, QuestionText = "Avez-vous des dommages aux fenêtres, portes ou murs ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 11, QuestionText = "Avez-vous des dommages au toit ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 12, QuestionText = "Avez-vous une intrusion d'eau majeure ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 13, QuestionText = "Les salles de classe portables sont-elles endommagées et inutilisables ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 14, QuestionText = "Votre établissement a-t-il besoin d'être sécurisé/protégé ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 15, QuestionText = "Êtes-vous sans alimentation électrique commerciale ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 16, QuestionText = "Êtes-vous sans pression d'eau ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 17, QuestionText = "Êtes-vous sans téléphones ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 18, QuestionText = "Les feux de circulation sont-ils endommagés/absents ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 19, QuestionText = "N'avez-vous pas d'alarme incendie fonctionnelle ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 20, QuestionText = "N'avez-vous pas de système de sonorisation opérationnel ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 21, QuestionText = "Avez-vous une grande quantité de débris ?", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 22, QuestionText = "Y a-t-il des problèmes ou des problèmes non abordés ci-dessus qui vous empêcheraient d'ouvrir ? Si oui, veuillez expliquer ci-dessous.", Language = "fr" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 5, QuestionText = "¿Puedes abrir ?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 6, QuestionText = "¿Los escombros bloquean el acceso?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 7, QuestionText = "¿Están inundados los terrenos?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 8, QuestionText = "¿El acceso está bloqueado por inundaciones?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 9, QuestionText = "¿Hay cables de utilidad caídos?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 10, QuestionText = "¿Tienes daños en ventanas, puertas o paredes?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 11, QuestionText = "¿Tienes daños en el techo?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 12, QuestionText = "¿Tienes una gran intrusión de agua?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 13, QuestionText = "¿Hay aulas portátiles dañadas e inutilizables?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 14, QuestionText = "¿Tu instalación necesita ser asegurada/tabicada?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 15, QuestionText = "¿No tienes energía comercial?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 16, QuestionText = "¿No tienes presión de agua?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 17, QuestionText = "¿No tienes teléfonos?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 18, QuestionText = "¿Los semáforos están dañados/faltan?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 19, QuestionText = "¿No tienes una alarma de incendios operativa?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 20, QuestionText = "¿No tienes un sistema de megafonía operativo?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 21, QuestionText = "¿Tienes una gran cantidad de escombros?", Language = "es" });
questionDbContext.QuestionsTranslations.Add(new Db.QuestionsTranslation() { QuestionId = 22, QuestionText = "¿Hay algún problema o asunto no abordado anteriormente que le impida abrir? Si es así, por favor explíquelo a continuación.", Language = "es" });
questionDbContext.SaveChanges();
}
}
@ -219,6 +313,7 @@ namespace DamageAssesment.Api.Questions.Providers
CategoryId = item.Id,
IconLibrary = item.IconLibrary,
IconName = item.IconName,
CategoryNames= CreateCategoryMultiLanguageObject(GetCategoryTranslations(item.Id, language)),
QuestionsText = GetSurveyQuestion(mapper.Map<List<Db.Question>, List<Models.MultiLanguage>>(questions.Where(a => a.CategoryId == item.Id).ToList()), language)
});
}

View File

@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -8,5 +8,11 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"ConnectionStrings": {
//"QuestionConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
// "QuestionConnection": "Server=localhost,1433;Database=da_survey_dev;User Id=sa;Password=Password123;TrustServerCertificate=True;"
"QuestionConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
}
}

View File

@ -10,7 +10,7 @@
</PropertyGroup>
<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="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.4.2" />

View File

@ -198,6 +198,7 @@ namespace DamageAssesment.Api.Responses.Controllers
else
return BadRequest(result.ErrorMessage);
}
[Route("responses/surveys/active")]
[Route("responses/surveys/active/{language:alpha}")]
[Route("responses/surveys/active/{employeeid:int}")]
@ -212,18 +213,7 @@ namespace DamageAssesment.Api.Responses.Controllers
}
return NoContent();
}
//[Route("responses/surveys/active")]
//[Route("responses/surveys/active/{language:alpha}")]
//[HttpGet]
//public async Task<ActionResult> GetActiveSurveysAsync( string? language)
//{
// var result = await this.surveyResponseProvider.GetActiveSurveysAsync(null, language);
// if (result.IsSuccess)
// {
// return Ok(result.Surveys);
// }
// return NoContent();
//}
[Route("responses/surveys/historic")]
[Route("responses/surveys/historic/{language:alpha}")]
[Route("responses/surveys/historic/{employeeid:int}")]

View File

@ -11,6 +11,19 @@
<ItemGroup>
<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.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.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.Responses.Db
{
[Table("SurveyResponses")]
public class SurveyResponse
{
[Key]

View File

@ -4,12 +4,17 @@ namespace DamageAssesment.Api.Responses.Db
{
public class SurveyResponseDbContext:DbContext
{
public DbSet<Db.SurveyResponse> SurveyResponses { get; set; }
public SurveyResponseDbContext(DbContextOptions options) : base(options)
private IConfiguration _Configuration { get; set; }
public SurveyResponseDbContext(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("ResponsesConnection"));
}
public DbSet<Db.SurveyResponse> SurveyResponses { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{

View File

@ -44,7 +44,7 @@ builder.Services.AddSwaggerGen(c =>
});
builder.Services.AddDbContext<SurveyResponseDbContext>(option =>
{
option.UseInMemoryDatabase("Responses");
option.UseSqlServer("ResponsesConnection");
});
var app = builder.Build();

View File

@ -120,9 +120,9 @@ namespace DamageAssesment.Api.Responses.Providers
//get all the survey that already taken by the employee
var surveys = await surveyServiceProvider.getSurveysAsync(language);
surveys = surveys.Where(s => s.IsEnabled == true && s.StartDate <= DateTime.Now && s.EndDate >= DateTime.Now).ToList();
if (employeeid==null || employeeid==0)
if (employeeid == null || employeeid == 0)
return (true, surveys, null);
List<int> listOfsurveysId = await surveyResponseDbContext.SurveyResponses.Where(x => x.EmployeeId == employeeid.Value).Select(y => y.SurveyId).ToListAsync();
List<int> listOfsurveysId = await surveyResponseDbContext.SurveyResponses.Where(x => x.EmployeeId == employeeid.Value).Select(y => y.SurveyId).ToListAsync();
var activeSurveys = surveys.Where(s => !listOfsurveysId.Contains(s.Id));
return (true, activeSurveys, null);
}
@ -142,10 +142,9 @@ namespace DamageAssesment.Api.Responses.Providers
var surveys = await surveyServiceProvider.getSurveysAsync(language);
// returning only historic data: end date is less than current date.
surveys = surveys.Where(s => s.EndDate < DateTime.Now).ToList();
if(employeeid==null|| employeeid==0)
if (employeeid == null || employeeid == 0)
return (true, surveys, null);
var surveyResponses = await surveyResponseDbContext.SurveyResponses.Where(x => x.EmployeeId == employeeid).ToListAsync();
var historicSurveys = from s in surveys
from r in surveyResponses
where s.Id == r.SurveyId

View File

@ -39,5 +39,10 @@
"AnswerByResponse": "/answers/byresponse/{0}",
"Location": "/locations",
"Region": "/regions"
},
"ConnectionStrings": {
//"SurveyResponseConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
// "ResponsesConnection": "Server=localhost,1433;Database=da_survey_dev;User Id=sa;Password=Password123;TrustServerCertificate=True;",
"ResponsesConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
}
}

View File

@ -0,0 +1,55 @@
// <auto-generated />
using DamageAssesment.Api.SurveyResponses.Db;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DamageAssesment.Api.SurveyResponses.Migrations
{
[DbContext(typeof(SurveyResponseDbContext))]
[Migration("20230817221348_InitialSurveyResponse")]
partial class InitialSurveyResponse
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.9")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DamageAssesment.Api.SurveyResponses.Db.SurveyResponse", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("EmployeeId")
.IsRequired()
.HasMaxLength(6)
.HasColumnType("nvarchar(6)");
b.Property<string>("LocationId")
.IsRequired()
.HasMaxLength(4)
.HasColumnType("nvarchar(4)");
b.Property<int>("SurveyId")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("SurveyResponses");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DamageAssesment.Api.SurveyResponses.Migrations
{
/// <inheritdoc />
public partial class InitialSurveyResponse : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "SurveyResponses",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
SurveyId = table.Column<int>(type: "int", nullable: false),
LocationId = table.Column<string>(type: "nvarchar(4)", maxLength: 4, nullable: false),
EmployeeId = table.Column<string>(type: "nvarchar(6)", maxLength: 6, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SurveyResponses", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "SurveyResponses");
}
}
}

View File

@ -0,0 +1,52 @@
// <auto-generated />
using DamageAssesment.Api.SurveyResponses.Db;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DamageAssesment.Api.SurveyResponses.Migrations
{
[DbContext(typeof(SurveyResponseDbContext))]
partial class SurveyResponseDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.9")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DamageAssesment.Api.SurveyResponses.Db.SurveyResponse", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("EmployeeId")
.IsRequired()
.HasMaxLength(6)
.HasColumnType("nvarchar(6)");
b.Property<string>("LocationId")
.IsRequired()
.HasMaxLength(4)
.HasColumnType("nvarchar(4)");
b.Property<int>("SurveyId")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("SurveyResponses");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -11,6 +11,17 @@
<ItemGroup>
<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.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace DamageAssesment.Api.Surveys.Db
{
[Table("Surveys")]
public class Survey
{
[Key]

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
namespace DamageAssesment.Api.Surveys.Db
{
[Table("SurveyTrans")]
public class SurveyTranslation
{
[Key]

View File

@ -4,11 +4,18 @@ namespace DamageAssesment.Api.Surveys.Db
{
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.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)
{

View File

@ -44,7 +44,7 @@ builder.Services.AddSwaggerGen(c =>
});
builder.Services.AddDbContext<SurveysDbContext>(option =>
{
option.UseInMemoryDatabase("Surveys");
option.UseSqlServer("SurveyConnection");
});
var app = builder.Build();

View File

@ -18,7 +18,7 @@ namespace DamageAssesment.Api.Surveys.Providers
this.surveyDbContext = surveysDbContext;
this.logger = logger;
this.mapper = mapper;
// seedData();
//seedData();
}
// Method to seed initial data into the database
@ -45,9 +45,9 @@ namespace DamageAssesment.Api.Surveys.Providers
surveyDbContext.SurveysTranslation.Add(new Db.SurveyTranslation { SurveyId = survey2.Id, Language = "es", Title = "Encuesta sobre las secuelas del huracán Andrew" });
surveyDbContext.SurveysTranslation.Add(new Db.SurveyTranslation { SurveyId = survey2.Id, Language = "fr", Title = "Enquête sur les conséquences de l'ouragan Andrew" });
surveyDbContext.SurveysTranslation.Add(new Db.SurveyTranslation { SurveyId = survey3.Id, Language = "en", Title = "Hurricane Idalia Aftermath Survey" });
surveyDbContext.SurveysTranslation.Add(new Db.SurveyTranslation { SurveyId = survey3.Id, Language = "es", Title = "Encuesta sobre las secuelas del huracán Idalia" });
surveyDbContext.SurveysTranslation.Add(new Db.SurveyTranslation { SurveyId = survey3.Id, Language = "fr", Title = "Enquête sur les conséquences de l'ouragan Idalia" });
surveyDbContext.SurveysTranslation.Add(new Db.SurveyTranslation { SurveyId = survey3.Id, Language = "en", Title = "Hurricane Irma" });
surveyDbContext.SurveysTranslation.Add(new Db.SurveyTranslation { SurveyId = survey3.Id, Language = "es", Title = "Huracán Irma" });
surveyDbContext.SurveysTranslation.Add(new Db.SurveyTranslation { SurveyId = survey3.Id, Language = "fr", Title = "Ouragan Irma" });
surveyDbContext.SaveChanges();
}

View File

@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -8,5 +8,10 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"ConnectionStrings": {
//"SurveyConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;"
//"SurveyConnection": "Server=localhost,1433;Database=da_survey_dev;User Id=sa;Password=Password123;TrustServerCertificate=True;",
"SurveyConnection": "Server=207.180.248.35;Database=da_survey_dev;User Id=sa;Password=YourStrongPassw0rd;TrustServerCertificate=True;"
}
}

View File

@ -11,6 +11,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DamageAssesment.Api.Attachm
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4CB40DC2-D9D2-4384-A7A6-9968F5C777A2}"
ProjectSection(SolutionItems) = preProject
..\..\..\..\Sample\Migrations.ps1 = ..\..\..\..\Sample\Migrations.ps1
ReadMe.txt = ReadMe.txt
ReadMe4Dev.txt = ReadMe4Dev.txt
EndProjectSection

View File

@ -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'

View 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"

View File

@ -9,6 +9,7 @@
<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">

View File

@ -1,78 +1,13 @@
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
- SA_PASSWORD=Test123
- ACCEPT_EULA=Y
ports:
- "1433:1433"
volumes:
- ./data:/var/opt/mssql # Mount a volume to persist data

View File

@ -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"
}

View File

@ -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
View 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."