Seed changes for doculink microservice
This commit is contained in:
parent
15b5fba35e
commit
1510c3ab12
@ -63,16 +63,15 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (int i = 1; i <= 4; i++)
|
for (int i = 1; i <= 4; i++)
|
||||||
{
|
{
|
||||||
FileModel fileModel = new FileModel() { url = "www.google"+i+".com", IsAttachments = false, CustomOrder = 1 };
|
FileModel fileModel = new FileModel();
|
||||||
ReqDoculink documentInfo = new ReqDoculink() { linkTypeId = i,CustomOrder=i, Files = new List<FileModel>() { fileModel } };
|
if (i < 3)
|
||||||
List<Db.DoculinkTranslation> documents = new List<Db.DoculinkTranslation>();
|
fileModel = new FileModel() { FileName = "Sample" + i, FileExtension = ".txt", FileContent = "c2FtcGxl", IsAttachments = true, CustomOrder = 1 };
|
||||||
documents.Add(new Db.DoculinkTranslation { DocumentId = i, title = "test" + i, description = "test" + i, Language = "en" });
|
else
|
||||||
documents.Add(new Db.DoculinkTranslation { DocumentId = i, title = "prueba" + i, description = "prueba" + i, Language = "es" });
|
fileModel = new FileModel() { url = "www.google" + i + ".com", IsAttachments = false, CustomOrder = 1 };
|
||||||
documents.Add(new Db.DoculinkTranslation { DocumentId = i, title = "test" + i, description = "test" + i, Language = "fr" });
|
ReqDoculink documentInfo = new ReqDoculink() { linkTypeId = i, CustomOrder = i, Files = new List<FileModel>() { fileModel } };
|
||||||
Models.Doculink document = uploadservice.UploadDocument(counter, documentInfo);
|
Models.Doculink document = uploadservice.UploadDocument(counter, documentInfo);
|
||||||
DocumentDbContext.Documents.Add(mapper.Map<Models.Doculink, Db.Doculink>(document));
|
DocumentDbContext.Documents.Add(mapper.Map<Models.Doculink, Db.Doculink>(document));
|
||||||
DocumentDbContext.SaveChanges();
|
DocumentDbContext.SaveChanges();
|
||||||
DocumentDbContext.DocumentsTranslations.AddRange(documents);
|
|
||||||
var dbattachments = mapper.Map<List<Models.DoculinkAttachments>, List<Db.DoculinkAttachments>>(document.doclinksAttachments);
|
var dbattachments = mapper.Map<List<Models.DoculinkAttachments>, List<Db.DoculinkAttachments>>(document.doclinksAttachments);
|
||||||
dbattachments.ForEach(a => a.DocumentId = i);
|
dbattachments.ForEach(a => a.DocumentId = i);
|
||||||
DocumentDbContext.DoclinksAttachments.AddRange(dbattachments);
|
DocumentDbContext.DoclinksAttachments.AddRange(dbattachments);
|
||||||
@ -80,6 +79,34 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
counter++;
|
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)
|
public List<Models.DoculinkTranslation> GetDocumentTranslations(int id, string? language)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user