Modified Documents api for InMemory Logic

This commit is contained in:
uppuv 2023-08-31 19:12:47 -04:00
parent 48be1a74c9
commit 9c536a1c52
4 changed files with 3 additions and 13 deletions

View File

@ -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<Db.Document> Documents { get; set; }
public DbSet<Db.LinkType> LinkTypes { get; set; }
public DbSet<Db.DocumentsTranslation> 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);

View File

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

View File

@ -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();
}

View File

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