Seed changes for doculink microservice

This commit is contained in:
uppuv 2023-10-06 16:25:38 -04:00
parent 15b5fba35e
commit 1510c3ab12

View File

@ -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>() { fileModel } };
List<Db.DoculinkTranslation> documents = new List<Db.DoculinkTranslation>();
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>() { fileModel } };
Models.Doculink document = uploadservice.UploadDocument(counter, documentInfo);
DocumentDbContext.Documents.Add(mapper.Map<Models.Doculink, Db.Doculink>(document));
DocumentDbContext.SaveChanges();
DocumentDbContext.DocumentsTranslations.AddRange(documents);
var dbattachments = mapper.Map<List<Models.DoculinkAttachments>, List<Db.DoculinkAttachments>>(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<Db.DoculinkTranslation> documents = new List<Db.DoculinkTranslation>();
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<Models.DoculinkTranslation> GetDocumentTranslations(int id, string? language)
{