using Manager.DTOs; using ManagerService.DTOs; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using static ManagerService.Data.SectionText; namespace ManagerService.Data.SubSection { /// /// Section Pdf /// public class SectionPdf : Section { [Required] [Column(TypeName = "jsonb")] public List PDFOrderedTranslationAndResources { get; set; } // All json files for all languages // Le texte des PDF eux-mêmes relève de l'ingestion documentaire (V2) : ici on n'indexe // que les libellés saisis dans le CMS. public override string GetEmbeddableText(string language) => JoinText(new[] { BaseText(language) } .Concat((PDFOrderedTranslationAndResources ?? new List()) .OrderBy(p => p.order ?? 0) .Select(p => Translate(p.translationAndResourceDTOs, language))) .ToArray()); public override IEnumerable GetReferencedResourceIds(string language = null) => BaseResourceIds() .Concat((PDFOrderedTranslationAndResources ?? new List()) .SelectMany(p => ResourceIds(p.translationAndResourceDTOs, language))); public PdfDTO ToDTO() { return new PdfDTO() { id = Id, label = Label, title = Title.ToList(), description = Description.ToList(), order = Order, type = Type, imageId = ImageId, imageSource = ImageSource, configurationId = ConfigurationId, isSubSection = IsSubSection, parentId = ParentId, dateCreation = DateCreation, instanceId = InstanceId, isBeacon = IsBeacon, beaconId = BeaconId, latitude = Latitude, longitude = Longitude, meterZoneGPS = MeterZoneGPS, pdfs = PDFOrderedTranslationAndResources }; } } }