2025-03-20 16:25:23 +01:00

63 lines
2.2 KiB
C#

using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section article
/// </summary>
public class SectionArticle: Section
{
[Required]
[Column(TypeName = "jsonb")]
public List<Translation> ArticleContent { get; set; }
public bool ArticleIsContentTop { get; set; } // MyVisit - True if content is displayed at top, false otherwise
[Required]
[Column(TypeName = "jsonb")]
public List<Translation> ArticleAudioIds { get; set; }
public bool ArticleIsReadAudioAuto { get; set; } // MyVisit - True for audio play when open the article / false otherwise
[Required]
public List<Content> ArticleContents { get; set; }
public ArticleDTO ToDTO()
{
return new ArticleDTO()
{
id = Id,
label = Label,
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).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,
content = ArticleContent.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
isContentTop = ArticleIsContentTop,
audioIds = ArticleAudioIds.Select(a=> a.ToDTO()).ToList(),
isReadAudioAuto = ArticleIsReadAudioAuto,
contents = ArticleContents.Select(c => c.ToDTO()).ToList(),
};
}
}
}