From d78d5e0ba444615f924b3cba521462b92f090c9d Mon Sep 17 00:00:00 2001 From: uppuv Date: Thu, 31 Aug 2023 19:12:47 -0400 Subject: [PATCH] Modified Documents api for InMemory Logic --- .../Db/DocumentDbContext.cs | 9 +-------- .../DamageAssesment.Api.Documents/Program.cs | 2 +- .../Providers/DocumentsProvider.cs | 2 +- .../DamageAssesment.Api.Documents/appsettings.json | 3 --- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/DamageAssesmentApi/DamageAssesment.Api.Documents/Db/DocumentDbContext.cs b/DamageAssesmentApi/DamageAssesment.Api.Documents/Db/DocumentDbContext.cs index f0ddc60..4df2f77 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Documents/Db/DocumentDbContext.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Documents/Db/DocumentDbContext.cs @@ -7,19 +7,12 @@ namespace DamageAssesment.Api.Documents.Db { public class DocumentDbContext : DbContext { - private IConfiguration _Configuration { get; set; } - public DocumentDbContext(DbContextOptions options, IConfiguration configuration) : base(options) + public DocumentDbContext(DbContextOptions options) : base(options) { - _Configuration = configuration; } public DbSet Documents { get; set; } public DbSet LinkTypes { get; set; } public DbSet DocumentsTranslations { get; set; } - protected override void OnConfiguring(DbContextOptionsBuilder options) - { - // connect to sql server with connection string from app settings - options.UseSqlServer(_Configuration.GetConnectionString("DocumentConnection")); - } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); diff --git a/DamageAssesmentApi/DamageAssesment.Api.Documents/Program.cs b/DamageAssesmentApi/DamageAssesment.Api.Documents/Program.cs index a1e9361..af38287 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Documents/Program.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Documents/Program.cs @@ -17,7 +17,7 @@ builder.Services.AddScoped(); builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30 builder.Services.AddDbContext(option => { - option.UseSqlServer("DocumentConnection"); + option.UseInMemoryDatabase("DocumentConnection"); }); var app = builder.Build(); diff --git a/DamageAssesmentApi/DamageAssesment.Api.Documents/Providers/DocumentsProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.Documents/Providers/DocumentsProvider.cs index 8b6c1ee..4af3174 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Documents/Providers/DocumentsProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.Documents/Providers/DocumentsProvider.cs @@ -49,7 +49,7 @@ namespace DamageAssesment.Api.Documents.Providers } if (!DocumentDbContext.DocumentsTranslations.Any()) { - Db.DocumentsTranslation documents = new Db.DocumentsTranslation { Id = 0, DocumentId = 1, title = "Test", description = "ss", Language = "en" }; + Db.DocumentsTranslation documents = new Db.DocumentsTranslation { DocumentId = 1, title = "Test", description = "ss", Language = "en" }; DocumentDbContext.DocumentsTranslations.Add(documents); DocumentDbContext.SaveChanges(); } diff --git a/DamageAssesmentApi/DamageAssesment.Api.Documents/appsettings.json b/DamageAssesmentApi/DamageAssesment.Api.Documents/appsettings.json index 5006fa8..e38d9fb 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.Documents/appsettings.json +++ b/DamageAssesmentApi/DamageAssesment.Api.Documents/appsettings.json @@ -9,8 +9,5 @@ "Fileupload": { "folderpath": "DASA_Documents/Active", "Deletepath": "DASA_Documents/Deleted" - }, - "ConnectionStrings": { - "DocumentConnection": "Server=DESKTOP-OF5DPLQ\\SQLEXPRESS;Database=da_survey_dev;Trusted_Connection=True;TrustServerCertificate=True;" } }