forked from MDCPS/DamageAssessment_Backend
		
	Modified Documents api for InMemory Logic
This commit is contained in:
		| @ -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); | ||||
|  | ||||
| @ -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(); | ||||
|  | ||||
|  | ||||
| @ -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(); | ||||
|             } | ||||
|  | ||||
| @ -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;" | ||||
|   } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user