added multi language support for doculink attachments
This commit is contained in:
parent
a2b6e078e2
commit
101ed7ee04
@ -32,7 +32,8 @@ namespace DamageAssesment.Api.DocuLinks.Test
|
|||||||
doclinksAttachments.Add(new DoculinkAttachments()
|
doclinksAttachments.Add(new DoculinkAttachments()
|
||||||
{
|
{
|
||||||
docName = "",Path="www.google.com",
|
docName = "",Path="www.google.com",
|
||||||
IsAttachments=false,CustomOrder=1
|
Language = "en",
|
||||||
|
IsAttachments =false,CustomOrder=1
|
||||||
});
|
});
|
||||||
list.Add(new DocuLinks.Models.ResDoculink()
|
list.Add(new DocuLinks.Models.ResDoculink()
|
||||||
{
|
{
|
||||||
@ -74,6 +75,7 @@ namespace DamageAssesment.Api.DocuLinks.Test
|
|||||||
docName = "",
|
docName = "",
|
||||||
Path = "www.google.com",
|
Path = "www.google.com",
|
||||||
IsAttachments = false,
|
IsAttachments = false,
|
||||||
|
Language = "en",
|
||||||
CustomOrder = 1
|
CustomOrder = 1
|
||||||
});
|
});
|
||||||
list.Add(new DocuLinks.Models.ResDoculink()
|
list.Add(new DocuLinks.Models.ResDoculink()
|
||||||
@ -138,6 +140,7 @@ namespace DamageAssesment.Api.DocuLinks.Test
|
|||||||
docName = "",
|
docName = "",
|
||||||
Path = "www.google.com",
|
Path = "www.google.com",
|
||||||
IsAttachments = false,
|
IsAttachments = false,
|
||||||
|
Language = "en",
|
||||||
CustomOrder = 1
|
CustomOrder = 1
|
||||||
});
|
});
|
||||||
return new Models.Doculink
|
return new Models.Doculink
|
||||||
@ -165,6 +168,7 @@ namespace DamageAssesment.Api.DocuLinks.Test
|
|||||||
docName = "",
|
docName = "",
|
||||||
Path = "www.google.com",
|
Path = "www.google.com",
|
||||||
IsAttachments = false,
|
IsAttachments = false,
|
||||||
|
Language = "en",
|
||||||
CustomOrder = 1
|
CustomOrder = 1
|
||||||
});
|
});
|
||||||
List<DocuLinks.Models.Doculink> DocuLinks = new List<Models.Doculink>();
|
List<DocuLinks.Models.Doculink> DocuLinks = new List<Models.Doculink>();
|
||||||
|
@ -14,5 +14,6 @@ namespace DamageAssesment.Api.DocuLinks.Db
|
|||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
public bool IsAttachments { get; set; }
|
public bool IsAttachments { get; set; }
|
||||||
public int CustomOrder { get; set; }
|
public int CustomOrder { get; set; }
|
||||||
|
public string Language { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ namespace DamageAssesment.Api.DocuLinks.Models
|
|||||||
public string docName { get; set; }
|
public string docName { get; set; }
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
public bool IsAttachments { get; set; }
|
public bool IsAttachments { get; set; }
|
||||||
|
public string Language { get; set; }
|
||||||
public int CustomOrder { get; set; }
|
public int CustomOrder { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,6 @@ namespace DamageAssesment.Api.DocuLinks.Models
|
|||||||
public int CustomOrder { get; set; }
|
public int CustomOrder { get; set; }
|
||||||
public string url { get;set; }
|
public string url { get;set; }
|
||||||
public bool IsAttachments { get; set; }
|
public bool IsAttachments { get; set; }
|
||||||
|
public string Language { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using System;
|
|||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Diagnostics.Eventing.Reader;
|
using System.Diagnostics.Eventing.Reader;
|
||||||
using System.Reflection.Metadata;
|
using System.Reflection.Metadata;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
@ -71,11 +72,11 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
{
|
{
|
||||||
linkTypeId = 1;
|
linkTypeId = 1;
|
||||||
|
|
||||||
fileModel = new FileModel() { FileName = "Sample" + i, FileExtension = ".txt", FileContent = "c2FtcGxl", IsAttachments = true, CustomOrder = 1 };
|
fileModel = new FileModel() { FileName = "Sample" + i, FileExtension = ".txt", FileContent = "c2FtcGxl", IsAttachments = true, CustomOrder = 1, Language = "en" };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fileModel = new FileModel() { url = "www.google" + i + ".com", IsAttachments = false, CustomOrder = 1 };
|
fileModel = new FileModel() { url = "www.google" + i + ".com", IsAttachments = false, CustomOrder = 1,Language="en" };
|
||||||
ReqDoculink documentInfo = new ReqDoculink() { linkTypeId = linkTypeId, CustomOrder = i, Files = new List<FileModel>() { fileModel } };
|
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();
|
||||||
@ -170,7 +171,19 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
MultiLanguage = dicttitle;
|
MultiLanguage = dicttitle;
|
||||||
return MultiLanguage;
|
return MultiLanguage;
|
||||||
}
|
}
|
||||||
|
private List<Models.DoculinkAttachments> GetDocumentAttachment(int id,string? language)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(language))
|
||||||
|
{
|
||||||
|
return mapper.Map<List<Db.DoculinkAttachments>, List<Models.DoculinkAttachments>>(
|
||||||
|
DocumentDbContext.DoclinksAttachments.AsNoTracking().Where(a => a.DocumentId == id).ToList());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return mapper.Map<List<Db.DoculinkAttachments>, List<Models.DoculinkAttachments>>(
|
||||||
|
DocumentDbContext.DoclinksAttachments.AsNoTracking().Where(a => a.DocumentId == id && a.Language == language).ToList());
|
||||||
|
}
|
||||||
|
}
|
||||||
public async Task<(bool IsSuccess, IEnumerable<Models.ResDoculink> documents, string ErrorMessage)> GetdocumentsByLinkTypeIdAsync(int? linkTypeId, string? language, bool? isactive)
|
public async Task<(bool IsSuccess, IEnumerable<Models.ResDoculink> documents, string ErrorMessage)> GetdocumentsByLinkTypeIdAsync(int? linkTypeId, string? language, bool? isactive)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -192,8 +205,7 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
item.titles = multilan.titles;
|
item.titles = multilan.titles;
|
||||||
item.description = multilan.description;
|
item.description = multilan.description;
|
||||||
item.linktypes = CreateMultiLanguageLinkTypeObject(GetLinkTypeTranslations(item.linkTypeId, language));
|
item.linktypes = CreateMultiLanguageLinkTypeObject(GetLinkTypeTranslations(item.linkTypeId, language));
|
||||||
item.doclinksAttachments = mapper.Map<List<Db.DoculinkAttachments>, List<Models.DoculinkAttachments>>(
|
item.doclinksAttachments = GetDocumentAttachment(item.Id,language);
|
||||||
DocumentDbContext.DoclinksAttachments.AsNoTracking().Where(a => a.DocumentId == item.Id).ToList());
|
|
||||||
}
|
}
|
||||||
// List<ResDoculinks> doculinks = result.GroupBy(a => a.linkTypeId).Select(a => new ResDoculinks() { linkTypeId = a.Key, doculinks = a.ToList() }).ToList();
|
// List<ResDoculinks> doculinks = result.GroupBy(a => a.linkTypeId).Select(a => new ResDoculinks() { linkTypeId = a.Key, doculinks = a.ToList() }).ToList();
|
||||||
return (true, result, null);
|
return (true, result, null);
|
||||||
@ -228,8 +240,7 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
item.titles = multilan.titles;
|
item.titles = multilan.titles;
|
||||||
item.description = multilan.description;
|
item.description = multilan.description;
|
||||||
item.linktypes = CreateMultiLanguageLinkTypeObject(GetLinkTypeTranslations(item.linkTypeId, language));
|
item.linktypes = CreateMultiLanguageLinkTypeObject(GetLinkTypeTranslations(item.linkTypeId, language));
|
||||||
item.doclinksAttachments = mapper.Map<List<Db.DoculinkAttachments>, List<Models.DoculinkAttachments>>(
|
item.doclinksAttachments = GetDocumentAttachment(item.Id, language);
|
||||||
DocumentDbContext.DoclinksAttachments.AsNoTracking().Where(a => a.DocumentId == item.Id).ToList());
|
|
||||||
}
|
}
|
||||||
//List<ResDoculinks> doculinks = result.GroupBy(a => a.linkTypeId).Select(a => new ResDoculinks() { linkTypeId = a.Key, doculinks = a.ToList() }).ToList();
|
//List<ResDoculinks> doculinks = result.GroupBy(a => a.linkTypeId).Select(a => new ResDoculinks() { linkTypeId = a.Key, doculinks = a.ToList() }).ToList();
|
||||||
return (true, result, null);
|
return (true, result, null);
|
||||||
@ -284,8 +295,7 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
result.documentsTranslations = mapper.Map<List<Db.DoculinkTranslation>, List<Models.DoculinkTranslation>>(
|
result.documentsTranslations = mapper.Map<List<Db.DoculinkTranslation>, List<Models.DoculinkTranslation>>(
|
||||||
DocumentDbContext.DocumentsTranslations.Where(a => a.DocumentId == result.Id).ToList());
|
DocumentDbContext.DocumentsTranslations.Where(a => a.DocumentId == result.Id).ToList());
|
||||||
|
|
||||||
result.doclinksAttachments = mapper.Map<List<Db.DoculinkAttachments>, List<Models.DoculinkAttachments>>(
|
result.doclinksAttachments = GetDocumentAttachment(id, "");
|
||||||
DocumentDbContext.DoclinksAttachments.AsNoTracking().Where(a => a.DocumentId == id).ToList());
|
|
||||||
return (true, result, null);
|
return (true, result, null);
|
||||||
}
|
}
|
||||||
return (false, null, "Not found");
|
return (false, null, "Not found");
|
||||||
@ -317,8 +327,7 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
result.linktypes = CreateMultiLanguageLinkTypeObject(GetLinkTypeTranslations(result.linkTypeId, language));
|
result.linktypes = CreateMultiLanguageLinkTypeObject(GetLinkTypeTranslations(result.linkTypeId, language));
|
||||||
result.titles = multilan.titles;
|
result.titles = multilan.titles;
|
||||||
result.description = multilan.description;
|
result.description = multilan.description;
|
||||||
result.doclinksAttachments = mapper.Map<List<Db.DoculinkAttachments>, List<Models.DoculinkAttachments>>(
|
result.doclinksAttachments = GetDocumentAttachment(id, language);
|
||||||
DocumentDbContext.DoclinksAttachments.AsNoTracking().Where(a => a.DocumentId == id).ToList());
|
|
||||||
return (true, result, null);
|
return (true, result, null);
|
||||||
}
|
}
|
||||||
return (false, null, "Not found");
|
return (false, null, "Not found");
|
||||||
@ -429,8 +438,7 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
result.titles = multilan.titles;
|
result.titles = multilan.titles;
|
||||||
result.description = multilan.description;
|
result.description = multilan.description;
|
||||||
result.linktypes = CreateMultiLanguageLinkTypeObject(GetLinkTypeTranslations(result.linkTypeId, ""));
|
result.linktypes = CreateMultiLanguageLinkTypeObject(GetLinkTypeTranslations(result.linkTypeId, ""));
|
||||||
result.doclinksAttachments = mapper.Map<List<Db.DoculinkAttachments>, List<Models.DoculinkAttachments>>(
|
result.doclinksAttachments = GetDocumentAttachment(id, "");
|
||||||
DocumentDbContext.DoclinksAttachments.AsNoTracking().Where(a => a.DocumentId == id).ToList());
|
|
||||||
Document.IsActive = false;
|
Document.IsActive = false;
|
||||||
DocumentDbContext.Documents.Update(Document);
|
DocumentDbContext.Documents.Update(Document);
|
||||||
DocumentDbContext.SaveChanges();
|
DocumentDbContext.SaveChanges();
|
||||||
|
@ -51,7 +51,7 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
path = item.url;
|
path = item.url;
|
||||||
attachments.Add(new Models.DoculinkAttachments { docName=UserfileName,Path=path,IsAttachments=item.IsAttachments,CustomOrder=item.CustomOrder });
|
attachments.Add(new Models.DoculinkAttachments { docName=UserfileName,Path=path,IsAttachments=item.IsAttachments,CustomOrder=item.CustomOrder,Language=item.Language });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Documents=new Models.Doculink (){ linkTypeId = documentInfo.linkTypeId,
|
Documents=new Models.Doculink (){ linkTypeId = documentInfo.linkTypeId,
|
||||||
@ -92,7 +92,7 @@ namespace DamageAssesment.Api.DocuLinks.Providers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
path = item.url;
|
path = item.url;
|
||||||
attachments.Add(new Models.DoculinkAttachments { docName = UserfileName, Path = path,IsAttachments=item.IsAttachments,CustomOrder=item.CustomOrder });
|
attachments.Add(new Models.DoculinkAttachments { docName = UserfileName, Path = path,IsAttachments=item.IsAttachments,CustomOrder=item.CustomOrder,Language=item.Language });
|
||||||
}
|
}
|
||||||
Models.Doculink Documents = new Models.Doculink()
|
Models.Doculink Documents = new Models.Doculink()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user