From 1510c3ab12ba36461c4ee64f1c3bc973f86123a6 Mon Sep 17 00:00:00 2001 From: uppuv Date: Fri, 6 Oct 2023 16:25:38 -0400 Subject: [PATCH] Seed changes for doculink microservice --- .../Providers/DoculinkProvider.cs | 41 +++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/DamageAssesmentApi/DamageAssesment.Api.DocuLinks/Providers/DoculinkProvider.cs b/DamageAssesmentApi/DamageAssesment.Api.DocuLinks/Providers/DoculinkProvider.cs index 9d8eae8..5ae15b1 100644 --- a/DamageAssesmentApi/DamageAssesment.Api.DocuLinks/Providers/DoculinkProvider.cs +++ b/DamageAssesmentApi/DamageAssesment.Api.DocuLinks/Providers/DoculinkProvider.cs @@ -63,16 +63,15 @@ namespace DamageAssesment.Api.DocuLinks.Providers int counter = 0; for (int i = 1; i <= 4; i++) { - FileModel fileModel = new FileModel() { url = "www.google"+i+".com", IsAttachments = false, CustomOrder = 1 }; - ReqDoculink documentInfo = new ReqDoculink() { linkTypeId = i,CustomOrder=i, Files = new List() { fileModel } }; - List documents = new List(); - documents.Add(new Db.DoculinkTranslation { DocumentId = i, title = "test" + i, description = "test" + i, Language = "en" }); - documents.Add(new Db.DoculinkTranslation { DocumentId = i, title = "prueba" + i, description = "prueba" + i, Language = "es" }); - documents.Add(new Db.DoculinkTranslation { DocumentId = i, title = "test" + i, description = "test" + i, Language = "fr" }); + FileModel fileModel = new FileModel(); + if (i < 3) + fileModel = new FileModel() { FileName = "Sample" + i, FileExtension = ".txt", FileContent = "c2FtcGxl", IsAttachments = true, CustomOrder = 1 }; + else + fileModel = new FileModel() { url = "www.google" + i + ".com", IsAttachments = false, CustomOrder = 1 }; + ReqDoculink documentInfo = new ReqDoculink() { linkTypeId = i, CustomOrder = i, Files = new List() { fileModel } }; Models.Doculink document = uploadservice.UploadDocument(counter, documentInfo); DocumentDbContext.Documents.Add(mapper.Map(document)); DocumentDbContext.SaveChanges(); - DocumentDbContext.DocumentsTranslations.AddRange(documents); var dbattachments = mapper.Map, List>(document.doclinksAttachments); dbattachments.ForEach(a => a.DocumentId = i); DocumentDbContext.DoclinksAttachments.AddRange(dbattachments); @@ -80,6 +79,34 @@ namespace DamageAssesment.Api.DocuLinks.Providers counter++; } } + if (!DocumentDbContext.DocumentsTranslations.Any()) + { + string[] titles = { + "Mobile App Damage Assessment Instructions", + "PC Damage Assessment Instructions", + "Emergency Evacuation centers", + "Mobile App Damage Assessment Instructions" }; + string[] esTranslations = { + "Instrucciones de Evaluación de Daños de la Aplicación Móvil", + "Instrucciones de Evaluación de Daños del PC", + "Centros de Evacuación de Emergencia", + "Instrucciones de Evaluación de Daños de la Aplicación Móvil" }; + string[] frTranslations = { + "Instructions d'Évaluation des Dommages de l'Application Mobile", + "Instructions d'Évaluation des Dommages du PC", + "Centres d'Évacuation d'Urgence", + "Instructions d'Évaluation des Dommages de l'Application Mobile" }; + List documents = new List(); + for (int i = 0; i < 4; i++) + { + documents.Add(new Db.DoculinkTranslation { DocumentId = i + 1, title = titles[i], description = titles[i], Language = "en" }); + documents.Add(new Db.DoculinkTranslation { DocumentId = i + 1, title = esTranslations[i], description = esTranslations[i], Language = "es" }); + documents.Add(new Db.DoculinkTranslation { DocumentId = i + 1, title = frTranslations[i], description = frTranslations[i], Language = "fr" }); + } + DocumentDbContext.DocumentsTranslations.AddRange(documents); + DocumentDbContext.SaveChanges(); + } + } public List GetDocumentTranslations(int id, string? language) {